« get me outta code hell

Change around some things in download-playlist - http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
path: root/src/playlist-utils.js
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2017-08-04 18:12:57 -0300
committerFlorrie <towerofnix@gmail.com>2017-08-04 18:13:13 -0300
commit3dd9d4c40e3b81beebbe7c0a66df93e226ac0bd1 (patch)
tree7e3778d2877f872b4d8ae36924bbf6e8b5723aaf /src/playlist-utils.js
parent9dce2bac1a4d6e8e5f1a37edfa92e2d9c1b7d0e7 (diff)
Change around some things in download-playlist
Diffstat (limited to 'src/playlist-utils.js')
-rw-r--r--src/playlist-utils.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/playlist-utils.js b/src/playlist-utils.js
index 5efd478..aed4964 100644
--- a/src/playlist-utils.js
+++ b/src/playlist-utils.js
@@ -245,6 +245,14 @@ function getPlaylistTreeString(playlist, showTracks = false) {
   return recursive(playlist)
 }
 
+function getItemPath(item) {
+  if (item[parentSymbol]) {
+    return [...getItemPath(item[parentSymbol]), item]
+  } else {
+    return [item]
+  }
+}
+
 function getItemPathString(item) {
   // Gets the playlist path of an item by following its parent chain.
   // Returns a string in format Foo/Bar/Baz, where Foo and Bar are group
@@ -286,7 +294,7 @@ module.exports = {
   filterPlaylistByPathString, filterGrouplikeByPath,
   removeGroupByPathString, removeGroupByPath,
   getPlaylistTreeString,
-  getItemPathString,
+  getItemPath, getItemPathString,
   parsePathString,
   isGroup, isTrack
 }