CLI add selection removal.
This commit is contained in:
parent
fe8729265e
commit
09875d28d9
@ -77,7 +77,7 @@ Options:
|
|||||||
Configuration:
|
Configuration:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
p2rivate static Logger logger =
|
private static Logger logger =
|
||||||
LoggerFactory.getLogger(CommandLineInterface)
|
LoggerFactory.getLogger(CommandLineInterface)
|
||||||
|
|
||||||
private Properties cliConfig
|
private Properties cliConfig
|
||||||
@ -695,44 +695,67 @@ Configuration:
|
|||||||
msg "${mediaFiles.size()} media files added to '${p.name}'."
|
msg "${mediaFiles.size()} media files added to '${p.name}'."
|
||||||
return added }
|
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) {
|
private def processRemove(String options, List<Model> selection = null) {
|
||||||
|
|
||||||
def m = (options =~ /(.+) from (.+)/)
|
def m = (options =~ /(.+) from (.+)/)
|
||||||
String removeFrom = m[0][2]
|
String removeFrom = m[0][2]
|
||||||
|
List<Model> toRemoveSel
|
||||||
|
|
||||||
if (m[0][1] != 'selection') selection = select(m[0][1], selection)
|
if (m[0][1] == 'selection') toRemoveSel = selection
|
||||||
if (!selection) err 'Nothing was selected to be removed.'
|
else toRemoveSel = select(m[0][1], selection)
|
||||||
|
|
||||||
Playlist p
|
if (!toRemoveSel) err 'Nothing was selected to be removed.'
|
||||||
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]) }
|
|
||||||
|
|
||||||
List<MediaFile> toRemove = library.collectMediaFiles(selection)
|
if (removeFrom == 'selection') {
|
||||||
toRemove.each { library.removeFromPlaylist(p.id, it.id) }
|
currentSelecton = removeFromSelection(toRemoveSel, selection)
|
||||||
|
msg "Removed from selection."
|
||||||
|
return }
|
||||||
|
|
||||||
// Reset our queue if we removed from the queue
|
else {
|
||||||
if (removeFrom == 'queue') {
|
Playlist p
|
||||||
vlcj.mediaListPlayer.stop()
|
if (removeFrom == 'queue') p = playQueue
|
||||||
setPlayQueue(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
|
List<MediaFile> toRemoveFiles = library.collectMediaFiles(toRemoveSel)
|
||||||
// removed stuff (may not be there anymore)
|
toRemoveFiles.each { library.removeFromPlaylist(p.id, it.id) }
|
||||||
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 ${toRemove.size()} files."
|
// Reset our queue if we removed from the queue
|
||||||
return toRemove }
|
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) {
|
private def processRandomize(String options) {
|
||||||
Playlist p
|
Playlist p
|
||||||
@ -1153,18 +1176,19 @@ add <select-criteria> to playlist <id | name>
|
|||||||
// REMOVE
|
// REMOVE
|
||||||
// --------------
|
// --------------
|
||||||
case 'remove': return """\
|
case 'remove': return """\
|
||||||
remove selection from queue
|
remove selection from { queue | selection }
|
||||||
remove selection from playlist <id | name>
|
remove selection from playlist <id | name>
|
||||||
|
|
||||||
Remove the media files for the current selection from the current play
|
Remove the media files for the current selection from the current
|
||||||
queue or from a playlist looked up by ID or name (including partial match).
|
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>
|
remove <select-criteria> from playlist <id | name>
|
||||||
|
|
||||||
Make a selection using the ${cmdStyle}select${normalStyle} syntax then remove those media
|
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
|
files from either the current selection, the play queue, or from a
|
||||||
(including partial match).
|
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 from playlist <id | name>
|
||||||
remove <selection-criteria> from playlist <id | name>
|
remove <selection-criteria> from playlist <id | name>
|
||||||
remove selection from queue
|
remove selection from { queue | selection }
|
||||||
remove <selection-criteria> from queue
|
remove <selection-criteria> from { queue | selection }
|
||||||
|
|
||||||
create bookmark named <name>
|
create bookmark named <name>
|
||||||
create bookmark named <name> on playlist <playlist name | id> at <file name | id>
|
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 playlist <id | name>
|
||||||
delete bookmark <id | name>
|
delete bookmark <id | name>
|
||||||
|
|
||||||
randomize queue
|
randomize { queue | playlist | selection }
|
||||||
randomize playlist
|
|
||||||
|
|
||||||
reorder queue move <file id | name> to <position>
|
reorder queue move <file id | name> to <position>
|
||||||
reorder playlist <id | name> move <file id | name> to <position>
|
reorder playlist <id | name> move <file id | name> to <position>
|
||||||
|
Loading…
Reference in New Issue
Block a user