Untested implementation of reorder and randomize in CLI.
This commit is contained in:
parent
72b4b0c9ff
commit
902e97c309
@ -327,6 +327,7 @@ Configuration:
|
||||
case 'remove': return processRemove(rest, currentSelection)
|
||||
case 'tag': return processTag(rest, currentSelection)
|
||||
case 'untag': return processTag(rest, currentSelection, false)
|
||||
case 'randomize': return processRandomize(rest)
|
||||
case 'clear': return processClear(rest)
|
||||
case 'pause': return processPause()
|
||||
case 'stop': return processStop()
|
||||
@ -566,6 +567,44 @@ Configuration:
|
||||
msg "Removed ${toRemove.size()} files."
|
||||
return toRemove }
|
||||
|
||||
private def processRandomize(String options) {
|
||||
Playlist p
|
||||
switch (options) {
|
||||
case 'queue': p = playQueue; break
|
||||
case ~/playlist (.+)/:
|
||||
String idOrName = Matcher.lastMatcher[0][1]
|
||||
p = getExactlyOne(Playlist, idOrName)
|
||||
break
|
||||
default: invalidOptionsErr('randomize') }
|
||||
|
||||
library.randomizePlaylist(p) }
|
||||
|
||||
private def processReorder(String options) {
|
||||
Playlist p
|
||||
int startingIdx = -1
|
||||
|
||||
String[] parts = options.split(/ as | starting at /)
|
||||
|
||||
if (parts.size() < 2) invalidOptionsErr('reorder');
|
||||
|
||||
// Playlist or queue?
|
||||
switch (parts[0].trim()) {
|
||||
case 'queue': p = playQueue; break
|
||||
case ~/playlist (.+)/:
|
||||
String idOrName = Matcher.lastMatcher[0][1]
|
||||
p = getExactlyOne(Playlist, idOrName)
|
||||
break
|
||||
default: invalidOptionsErr('reorder') }
|
||||
|
||||
// What files in order?
|
||||
List<MediaFile> playlistFiles = library.getMediaFilesWhere(playlistId: p.id)
|
||||
String[] fileIds = parts[1].split(/[,;\s]/)
|
||||
List<MediaFile> files = fileIds.collect { library.getMediaFileById(it) }
|
||||
.findAll()
|
||||
|
||||
if (parts.size() == 3) startingIdx = safeToInteger(parts[2])
|
||||
}
|
||||
|
||||
private def processTag(String options, List<Model> selection,
|
||||
boolean addTags = true) {
|
||||
|
||||
@ -722,6 +761,8 @@ Available commands:
|
||||
enqueue Enqueue requested media to the end of the play queue.
|
||||
add Append requested media to the end of a playlist.
|
||||
remove Remove requested from the play queue or playlist.
|
||||
randomize Re-order the files in a play queue or a playlist randomly.
|
||||
reorder Re-order the files in a play queue or a playlist.
|
||||
tag Associate tags with requested media.
|
||||
untag Remove the association between the given tags and media.
|
||||
clear Clear the selection, play queue, playlist, or screen.
|
||||
@ -900,7 +941,36 @@ remove <select-criteria> from playlist <id | name>
|
||||
|
||||
"""
|
||||
|
||||
// tag
|
||||
// RANDOMIZE
|
||||
// --------------
|
||||
case 'randomize': return """\
|
||||
randomize queue
|
||||
randomize playlist <id | name>
|
||||
|
||||
Randomize the order of all elements in either the current play queue or the
|
||||
named playlist.
|
||||
|
||||
"""
|
||||
|
||||
// REORDER
|
||||
// --------------
|
||||
case 'reorder': return """\
|
||||
reorder queue move <file id | name> to <position>
|
||||
reorder playlist <id | name> move <file id | name> to <position>
|
||||
|
||||
Move a single file from its current position to the named position in the
|
||||
play queue/playlist.
|
||||
|
||||
reorder queue as <file id>... starting at <position>
|
||||
reorder playlist <id | name> as <file id>... starting at <position>
|
||||
|
||||
Take a set of files in the playlist, reorder them into given order, and
|
||||
move them to the given starting position (defaults to the end of the
|
||||
playlist)
|
||||
|
||||
"""
|
||||
|
||||
// TAG
|
||||
// --------------
|
||||
case 'tag': return """\
|
||||
tag <tag>...
|
||||
@ -1053,6 +1123,14 @@ Playlist and Queue Management:
|
||||
create bookmark <id | name>
|
||||
update bookmark <id | name>
|
||||
|
||||
randomize queue
|
||||
randomize playlist
|
||||
|
||||
reorder queue move <file id | name> to <position>
|
||||
reorder playlist <id | name> move <file id | name> to <position>
|
||||
reorder queue as <file id>...
|
||||
reorder playlist <id | name> as <file id>...
|
||||
|
||||
clear
|
||||
clear queue
|
||||
clear selection
|
||||
|
Loading…
Reference in New Issue
Block a user