« get me outta code hell

http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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) {