diff options
author | Florrie <towerofnix@gmail.com> | 2017-09-28 22:00:45 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2017-09-28 22:00:45 -0300 |
commit | 94c68dbdca1bb57086cd5921f87f47b8a30e21fa (patch) | |
tree | d3deb7b744e648639fdbf0e76aca326e8235a51a /src/play.js | |
parent | eadd4ad2e26f47c529ffcbc3c96685947ee8b81c (diff) |
Add --filter
Diffstat (limited to 'src/play.js')
-rwxr-xr-x | src/play.js | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/play.js b/src/play.js index 6061d09..6adbb9c 100755 --- a/src/play.js +++ b/src/play.js @@ -14,7 +14,7 @@ const processSmartPlaylist = require('./smart-playlist') const { filterPlaylistByPathString, removeGroupByPathString, getPlaylistTreeString, - updatePlaylistFormat, collapseGrouplike + updatePlaylistFormat, collapseGrouplike, filterGrouplikeByProperty } = require('./playlist-utils') const readFile = promisify(fs.readFile) @@ -300,6 +300,20 @@ async function main(args) { 'r': util => util.alias('-remove'), 'x': util => util.alias('-remove'), + '-filter': function(util) { + // --filter <property> <value> (alias: -f) + // Filters the playlist so that only tracks with the given property- + // value pair are kept. + + const property = util.nextArg() + const value = util.nextArg() + + const p = filterGrouplikeByProperty(activePlaylist, property, value) + activePlaylist = updatePlaylistFormat(p) + }, + + 'f': util => util.alias('-filter'), + '-collapse-groups': function() { // --collapse-groups (alias: --collapse) // Collapses groups in the active playlist so that there is only one |