diff options
author | Florrie <towerofnix@gmail.com> | 2019-10-28 18:56:48 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2019-10-28 18:56:48 -0300 |
commit | 780b44ba6629005d8a9f976bf7117163a65cf717 (patch) | |
tree | 795601619da62a2686eae05c2d249aa53bd4b37d /playlist-utils.js | |
parent | cbc5d345786293acf14f317aab555498030061c2 (diff) |
Don't show text files adjacent to playables
Diffstat (limited to 'playlist-utils.js')
-rw-r--r-- | playlist-utils.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/playlist-utils.js b/playlist-utils.js index 082a734..452b705 100644 --- a/playlist-utils.js +++ b/playlist-utils.js @@ -634,6 +634,25 @@ function getCorrespondingFileForItem(item, extension) { return null } +function getCorrespondingPlayableForFile(item) { + if (!(item && item.url)) { + return null + } + + if (isPlayable(item)) { + return item + } + + const parent = item[parentSymbol] + + if (!parent) { + return null + } + + const basename = path.basename(item.url, path.extname(item.url)) + return parent.items.find(item => isPlayable(item) && path.basename(item.url, path.extname(item.url)) === basename) +} + module.exports = { parentSymbol, updatePlaylistFormat, updateGroupFormat, updateTrackFormat, @@ -653,6 +672,7 @@ module.exports = { getNameWithoutTrackNumber, searchForItem, getCorrespondingFileForItem, + getCorrespondingPlayableForFile, isGroup, isTrack, isOpenable, isPlayable } |