Added untagging ability to CLI.
This commit is contained in:
parent
adbd3620fb
commit
4905e32e6f
@ -291,6 +291,7 @@ Configuration:
|
||||
try { processInput(line) }
|
||||
catch (CliErr cliErr) {
|
||||
String errMsg = cliErr.message
|
||||
logger.error(errMsg)
|
||||
if (ANSI.strip(errMsg).length() > 80) {
|
||||
printLongMessage(errorStyle + errMsg + normalStyle) }
|
||||
else {
|
||||
@ -322,6 +323,7 @@ Configuration:
|
||||
case 'add': return processAdd(rest, currentSelection)
|
||||
case 'remove': return processRemove(rest, currentSelection)
|
||||
case 'tag': return processTag(rest, currentSelection)
|
||||
case 'untag': return processUntag(rest, currentSelection)
|
||||
case 'clear': return processClear(rest)
|
||||
case 'pause': return processPause()
|
||||
case 'stop': return processStop()
|
||||
@ -389,7 +391,7 @@ Configuration:
|
||||
Class modelClass
|
||||
|
||||
switch (options) {
|
||||
case ~/playing ($selectableModels|tag)s?/:
|
||||
case ~/playing ($selectableModels)s?/:
|
||||
if (!curMediaFile) err "No media is currently playing."
|
||||
|
||||
modelClass = modelClasses[Matcher.lastMatcher[0][1]]
|
||||
@ -415,10 +417,10 @@ Configuration:
|
||||
return selection.collectMany { library.getWhere(modelClass,
|
||||
[(idKeyFor(selectionClass)): it.id]) }.findAll()
|
||||
|
||||
case ~/files tagged( as)?((\s\w+)+?)/:
|
||||
case ~/files tagged( as){0,1}((\s\w+)+)/:
|
||||
selectedTags = Matcher.lastMatcher[0][2].split(/\s/)
|
||||
.collect { it?.trim() }.findAll()
|
||||
.collect { logger.debug("tag name: {}", it); library.getTagByName(it) }.findAll()
|
||||
.collect { library.getTagByName(it) }.findAll()
|
||||
if (!selectedTags) err 'Nothing is selected.'
|
||||
return library.getMediaFilesWhere(tags: selectedTags)
|
||||
|
||||
@ -473,6 +475,9 @@ Configuration:
|
||||
if (b.playTimeMs > 0)
|
||||
vlcj.mediaListPlayer.mediaPlayer.time = b.playTimeMs
|
||||
|
||||
b.lastUsed = new Timestamp(new Date().time);
|
||||
library.update(b)
|
||||
|
||||
return p;
|
||||
|
||||
default: selection = select(options, selection) }
|
||||
@ -560,7 +565,8 @@ Configuration:
|
||||
msg "Removed ${toRemove.size()} files."
|
||||
return toRemove }
|
||||
|
||||
private def processTag(String options, List<Model> selection) {
|
||||
private def processTag(String options, List<Model> selection,
|
||||
boolean addTags = true) {
|
||||
|
||||
String[] parts = options.split(' as ', 2)
|
||||
|
||||
@ -570,16 +576,18 @@ Configuration:
|
||||
if (parts.size() == 1) {
|
||||
if (!curMediaFile) err 'Nothing currently playing to tag.'
|
||||
selection = [curMediaFile]
|
||||
tags = parts[0].split(/\s/) }
|
||||
tags = parts[0].split(/\s/).collect { it?.trim() }.findAll() }
|
||||
|
||||
else {
|
||||
if (parts[0] != 'selection') selection = select(parts[0], selection)
|
||||
tags = parts[1].split(/\s/) }
|
||||
tags = parts[1].split(/\s/).collect { it?.trim() }.findAll() }
|
||||
|
||||
List<MediaFile> mediaFiles = library.collectMediaFiles(selection)
|
||||
library.tagMediaFiles(mediaFiles.collect { it.id }, tags)
|
||||
|
||||
msg "Tagged ${mediaFiles.size()} files as $tags."
|
||||
if (addTags) library.tagMediaFiles(mediaFiles.collect { it.id }, tags)
|
||||
else library.untagMediaFiles(mediaFiles.collect {it.id}, tags)
|
||||
|
||||
msg "${addTags ? 'Tagged' : 'Untagged'} ${mediaFiles.size()} files as $tags."
|
||||
return mediaFiles }
|
||||
|
||||
private def processClear(String options) {
|
||||
@ -1032,7 +1040,7 @@ help <commmand> Display detailed information about the given command."""
|
||||
return matches[0] }
|
||||
|
||||
public def getExactlyOne(Class modelClass, String nameOrId) {
|
||||
return ensureExactlyOne(library.getByIdOrName(modelClass, criteria)) }
|
||||
return ensureExactlyOne(library.getByIdOrName(modelClass, nameOrId)) }
|
||||
|
||||
private void drawLeader(afterOutput = false) {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user