CLI add selection removal.
This commit is contained in:
parent
fe8729265e
commit
09875d28d9
@ -77,7 +77,7 @@ Options:
|
||||
Configuration:
|
||||
"""
|
||||
|
||||
p2rivate static Logger logger =
|
||||
private static Logger logger =
|
||||
LoggerFactory.getLogger(CommandLineInterface)
|
||||
|
||||
private Properties cliConfig
|
||||
@ -695,44 +695,67 @@ Configuration:
|
||||
msg "${mediaFiles.size()} media files added to '${p.name}'."
|
||||
return added }
|
||||
|
||||
private def removeFromSelection(List<Model> toRemoveSel,
|
||||
List<Model> selection) {
|
||||
if (!toRemoveSel) err 'Nothing was selected to be removed.'
|
||||
if (!selection) err 'Selection is already empty.'
|
||||
|
||||
if (selection[0].class == toRemoveSel[0].class) {
|
||||
return selection - toRemoveSel }
|
||||
|
||||
List<MediaFile> selectionFiles = library.collectMediaFiles(selection)
|
||||
List<MediaFile> toRemoveFiles = library.collectMediaFiles(toRemoveSel)
|
||||
return selectionFiles - toRemoveFiles }
|
||||
|
||||
private def processRemove(String options, List<Model> selection = null) {
|
||||
|
||||
def m = (options =~ /(.+) from (.+)/)
|
||||
String removeFrom = m[0][2]
|
||||
List<Model> toRemoveSel
|
||||
|
||||
if (m[0][1] != 'selection') selection = select(m[0][1], selection)
|
||||
if (!selection) err 'Nothing was selected to be removed.'
|
||||
if (m[0][1] == 'selection') toRemoveSel = selection
|
||||
else toRemoveSel = select(m[0][1], selection)
|
||||
|
||||
Playlist p
|
||||
if (removeFrom == 'queue') p = playQueue
|
||||
else if (removeFrom.startsWith('playlist')) {
|
||||
String[] parts = removeFrom.split(/\s/, 2)
|
||||
if (parts.size() < 2) err 'No playlist id or name given.'
|
||||
p = getExactlyOne(Playlist, parts[1]) }
|
||||
if (!toRemoveSel) err 'Nothing was selected to be removed.'
|
||||
|
||||
List<MediaFile> toRemove = library.collectMediaFiles(selection)
|
||||
toRemove.each { library.removeFromPlaylist(p.id, it.id) }
|
||||
if (removeFrom == 'selection') {
|
||||
currentSelecton = removeFromSelection(toRemoveSel, selection)
|
||||
msg "Removed from selection."
|
||||
return }
|
||||
|
||||
// Reset our queue if we removed from the queue
|
||||
if (removeFrom == 'queue') {
|
||||
vlcj.mediaListPlayer.stop()
|
||||
setPlayQueue(playQueue)
|
||||
else {
|
||||
Playlist p
|
||||
if (removeFrom == 'queue') p = playQueue
|
||||
else if (removeFrom.startsWith('playlist')) {
|
||||
String[] parts = removeFrom.split(/\s/, 2)
|
||||
if (parts.size() < 2) err 'No playlist id or name given.'
|
||||
p = getExactlyOne(Playlist, parts[1]) }
|
||||
|
||||
// Restart playback with the file that was playing before we
|
||||
// removed stuff (may not be there anymore)
|
||||
if (playBookmark) {
|
||||
MediaFile mf = library.getMediaFileById(playBookmark.mediaFileId)
|
||||
List<MediaFile> playlistMFs = library.getMediaFilesWhere(
|
||||
playlistId: playQueue.id)
|
||||
int index = playlistMFs.indexOf(mf)
|
||||
if (index > 0) {
|
||||
vlcj.mediaListPlayer.playItem(index)
|
||||
if (playBookmark.playTimeMs > 0) {
|
||||
vlcj.mediaListPlayer.mediaPlayer.time =
|
||||
playBookmark.playTimeMs } } } }
|
||||
List<MediaFile> toRemoveFiles = library.collectMediaFiles(toRemoveSel)
|
||||
toRemoveFiles.each { library.removeFromPlaylist(p.id, it.id) }
|
||||
|
||||
msg "Removed ${toRemove.size()} files."
|
||||
return toRemove }
|
||||
// Reset our queue if we removed from the queue
|
||||
if (removeFrom == 'queue') {
|
||||
vlcj.mediaListPlayer.stop()
|
||||
setPlayQueue(playQueue)
|
||||
|
||||
// Restart playback with the file that was playing before we
|
||||
// removed stuff (may not be there anymore)
|
||||
if (playBookmark) {
|
||||
MediaFile mf = library.getMediaFileById(playBookmark.mediaFileId)
|
||||
List<MediaFile> playlistMFs = library.getMediaFilesWhere(
|
||||
playlistId: playQueue.id)
|
||||
int index = playlistMFs.indexOf(mf)
|
||||
|
||||
if (index > 0) {
|
||||
vlcj.mediaListPlayer.playItem(index)
|
||||
|
||||
if (playBookmark.playTimeMs > 0) {
|
||||
vlcj.mediaListPlayer.mediaPlayer.time =
|
||||
playBookmark.playTimeMs } } } }
|
||||
|
||||
msg "Removed ${toRemoveFiles.size()} files."
|
||||
return toRemoveFiles } }
|
||||
|
||||
private def processRandomize(String options) {
|
||||
Playlist p
|
||||
@ -1153,18 +1176,19 @@ add <select-criteria> to playlist <id | name>
|
||||
// REMOVE
|
||||
// --------------
|
||||
case 'remove': return """\
|
||||
remove selection from queue
|
||||
remove selection from { queue | selection }
|
||||
remove selection from playlist <id | name>
|
||||
|
||||
Remove the media files for the current selection from the current play
|
||||
queue or from a playlist looked up by ID or name (including partial match).
|
||||
Remove the media files for the current selection from the current
|
||||
selection, the current play queue, or from a playlist looked up by ID or
|
||||
name (including partial match).
|
||||
|
||||
remove <select-criteria> from queue
|
||||
remove <select-criteria> from { queue | selection }
|
||||
remove <select-criteria> from playlist <id | name>
|
||||
|
||||
Make a selection using the ${cmdStyle}select${normalStyle} syntax then remove those media
|
||||
files from either the play queue or from a playlist looked up by ID or name
|
||||
(including partial match).
|
||||
files from either the current selection, the play queue, or from a
|
||||
playlist looked up by ID or name (including partial match).
|
||||
|
||||
"""
|
||||
|
||||
@ -1352,8 +1376,8 @@ Playlist and Queue Management:
|
||||
|
||||
remove selection from playlist <id | name>
|
||||
remove <selection-criteria> from playlist <id | name>
|
||||
remove selection from queue
|
||||
remove <selection-criteria> from queue
|
||||
remove selection from { queue | selection }
|
||||
remove <selection-criteria> from { queue | selection }
|
||||
|
||||
create bookmark named <name>
|
||||
create bookmark named <name> on playlist <playlist name | id> at <file name | id>
|
||||
@ -1367,8 +1391,7 @@ Playlist and Queue Management:
|
||||
delete playlist <id | name>
|
||||
delete bookmark <id | name>
|
||||
|
||||
randomize queue
|
||||
randomize playlist
|
||||
randomize { queue | playlist | selection }
|
||||
|
||||
reorder queue move <file id | name> to <position>
|
||||
reorder playlist <id | name> move <file id | name> to <position>
|
||||
|
Loading…
Reference in New Issue
Block a user