« get me outta code hell

(o) to open through system; show non-music files - 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:
authorFlorrie <towerofnix@gmail.com>2019-10-15 17:55:58 -0300
committerFlorrie <towerofnix@gmail.com>2019-10-15 17:55:58 -0300
commitc0d6ea0363473cbb43e4f1f50c92803ed14742cb (patch)
tree883b8602584f66e9ddeb53cfe32b2d96dbfd909f /crawlers.js
parentb2b424c977099d5fc9d49a9bbba6d911e2bc7901 (diff)
(o) to open through system; show non-music files
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)