« get me outta code hell

mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
path: root/crawlers.js
diff options
context:
space:
mode:
Diffstat (limited to 'crawlers.js')
-rw-r--r--crawlers.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/crawlers.js b/crawlers.js
index f665c17..578a9f2 100644
--- a/crawlers.js
+++ b/crawlers.js
@@ -257,11 +257,12 @@ function crawlLocal(dirPath, extensions = [
 
     return Promise.all(items.map(item => {
       const itemPath = path.join(dirPath, item)
+      const itemURL = url.pathToFileURL(itemPath).href
 
       return stat(itemPath).then(stats => {
         if (stats.isDirectory()) {
           return crawlLocal(itemPath, extensions, false)
-            .then(group => Object.assign({name: item}, group))
+            .then(group => Object.assign({name: item, url: itemURL}, group))
         } else if (stats.isFile()) {
           // Extname returns a string starting with a dot; we don't want the
           // dot, so we slice it off of the front.
@@ -273,10 +274,9 @@ function crawlLocal(dirPath, extensions = [
             // playlist, or want them in an auto-generated one.
             const basename = path.basename(item, path.extname(item))
 
-            const track = {name: basename, downloaderArg: itemPath}
-            return track
+            return {name: basename, downloaderArg: itemPath, url: itemURL}
           } else {
-            return null
+            return {name: item, url: itemURL}
           }
         }
       }, statErr => null)