« get me outta code hell

Clean up things, de-break everything - http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2018-03-19 23:17:26 -0300
committerFlorrie <towerofnix@gmail.com>2018-03-19 23:17:26 -0300
commit8dcffcb19d6ea454675f03810b1e5d8b9e6c3f4f (patch)
treea88fc5f93d514b66da060855f44dc29fb8012dcf
parentbf0a68349b69fb5b8bd50b7e38ad6a88540e431a (diff)
Clean up things, de-break everything
-rw-r--r--src/duration-graph.js2
-rw-r--r--src/smart-playlist.js20
2 files changed, 14 insertions, 8 deletions
diff --git a/src/duration-graph.js b/src/duration-graph.js
index c8fce75..ee6113c 100644
--- a/src/duration-graph.js
+++ b/src/duration-graph.js
@@ -268,8 +268,6 @@ async function main(args) {
 
   const playlist = getStuff.activePlaylist
 
-  console.log(playlist)
-
   for (const line of makePlaylistGraph(playlist, {
     graphWidth, onlyFirst, metric
   })) {
diff --git a/src/smart-playlist.js b/src/smart-playlist.js
index 395c590..7c09919 100644
--- a/src/smart-playlist.js
+++ b/src/smart-playlist.js
@@ -7,11 +7,13 @@ const { isGroup, filterTracks, sourceSymbol, updatePlaylistFormat } = require('.
 const { promisify } = require('util')
 const readFile = promisify(fs.readFile)
 
-async function processSmartPlaylist(item) {
+async function processSmartPlaylist(item, topItem = true) {
   // Object.assign is used so that we keep original properties, e.g. "name"
   // or "apply". (It's also used so we return copies of original objects.)
 
-  item = await updatePlaylistFormat(item)
+  if (topItem) {
+    item = await updatePlaylistFormat(item)
+  }
 
   const newItem = Object.assign({}, item)
 
@@ -30,7 +32,9 @@ async function processSmartPlaylist(item) {
 
     delete newItem.source
   } else if ('items' in newItem) {
-    newItem.items = await Promise.all(item.items.map(processSmartPlaylist))
+    // Pass topItem = false, since we don't want to use updatePlaylistFormat
+    // on these items.
+    newItem.items = await Promise.all(item.items.map(x => processSmartPlaylist(x, false)))
   }
 
   if ('filters' in newItem) filters: {
@@ -122,9 +126,13 @@ async function processSmartPlaylist(item) {
     delete newItem.filters
   }
 
-  // We pass true so that the playlist-format-updater knows that this
-  // is going to be the source playlist, probably.
-  return updatePlaylistFormat(newItem, true)
+  if (topItem) {
+    // We pass true so that the playlist-format-updater knows that this
+    // is going to be the source playlist, probably.
+    return updatePlaylistFormat(newItem, true)
+  } else {
+    return newItem
+  }
 }
 
 async function main(opts) {