« get me outta code hell

Add new "apply" feature to playlists - 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:
authorLiam <towerofnix@gmail.com>2017-07-27 00:05:21 -0300
committerLiam <towerofnix@gmail.com>2017-07-27 00:05:21 -0300
commite02f90272a805f85f94adec8d790eaf45dcf9c3f (patch)
treef5d09b7e39123e24e55111693caaf201b19bc88f /src
parent07c9f7622567d822670c1021280c4dba4d161794 (diff)
Add new "apply" feature to playlists
See https://gist.github.com/liam4/cd7465a82c8b367eef221e61c3b6186e.
Though not tested, this should work even on old/mixed playlists,
e.g.: https://gist.github.com/liam4/2cad8630d5df4cf0014cb9acd0d76115
Diffstat (limited to 'src')
-rw-r--r--src/playlist-utils.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/playlist-utils.js b/src/playlist-utils.js
index 55638ed..5efd478 100644
--- a/src/playlist-utils.js
+++ b/src/playlist-utils.js
@@ -56,6 +56,16 @@ function updateGroupFormat(group) {
     // isn't a string..
     if (typeof item[1] === 'string' || item.downloaderArg) {
       item = updateTrackFormat(item)
+
+      // TODO: Should this also apply to groups? Is recursion good? Probably
+      // not!
+      //
+      // TODO: How should saving/serializing handle this? For now it just saves
+      // the result, after applying. (I.e., "apply": {"foo": "baz"} will save
+      // child tracks with {"foo": "baz"}.)
+      if (groupObj.apply) {
+        Object.assign(item, groupObj.apply)
+      }
     } else {
       item = updateGroupFormat(item)
     }