CLI: Implemented delete command for bookmarks and playlists.
This commit is contained in:
parent
652cb178f3
commit
fe8729265e
@ -50,11 +50,14 @@ remove <selection-criteria> from playlist <id | name>
|
||||
|
||||
clear playlist <id | name>
|
||||
|
||||
delete playlist <id | name>
|
||||
|
||||
# Bookmarking
|
||||
|
||||
create bookmark named <name>
|
||||
create bookmark named <name> on <playlist id | name> at <media file id | name>
|
||||
rename bookmark <old name> to <new name>
|
||||
delete bookmark <name | id>
|
||||
|
||||
# Transport Functions
|
||||
|
||||
|
@ -77,7 +77,7 @@ Options:
|
||||
Configuration:
|
||||
"""
|
||||
|
||||
private static Logger logger =
|
||||
p2rivate static Logger logger =
|
||||
LoggerFactory.getLogger(CommandLineInterface)
|
||||
|
||||
private Properties cliConfig
|
||||
@ -404,6 +404,7 @@ Configuration:
|
||||
case 'list': return processList(rest, currentSelection)
|
||||
case 'select': return processSelect(rest, currentSelection)
|
||||
case 'create': return processCreate(rest, currentSelection)
|
||||
case 'delete': return processDelete(rest)
|
||||
case 'play': return processPlay(rest, currentSelection)
|
||||
case 'enqueue': return processEnqueue(rest, currentSelection)
|
||||
case 'add': return processAdd(rest, currentSelection)
|
||||
@ -610,6 +611,18 @@ Configuration:
|
||||
|
||||
default: invalidOptionsErr('create') } }
|
||||
|
||||
private def processDelete(String options) {
|
||||
switch (options) {
|
||||
case ~/playlist (.+)/:
|
||||
Playlist p = getExactlyOne(
|
||||
Playlist, Matcher.lastMatcher[0][1].trim())
|
||||
return library.delete(p)
|
||||
case ~/bookmark (.+)/:
|
||||
Bookmark b = getExactlyOne(
|
||||
Bookmark, Matcher.latMatcher[0][1].trim())
|
||||
return library.delete(b)
|
||||
default: invalidOptionsErr('delete') } }
|
||||
|
||||
private Playlist processPlay(String options, List<Model> selection) {
|
||||
|
||||
switch (options) {
|
||||
@ -670,7 +683,7 @@ Configuration:
|
||||
|
||||
Playlist p
|
||||
def m = (options =~ /(.+) to playlist (.+)/)
|
||||
p = getExactlyOne(m[0][2])
|
||||
p = getExactlyOne(Playlist, m[0][2])
|
||||
if (!p) err "No playlist for '${Matcher.lastMatcher[0][1]}'."
|
||||
|
||||
if (m[0][1] != "selection") selection = select(options, selection)
|
||||
@ -936,6 +949,7 @@ Available commands:
|
||||
select Select things (into the select buffer, no the play queue).
|
||||
play Play requested media.
|
||||
enqueue Enqueue requested media to the end of the play queue.
|
||||
create Create a playlist or bookmark.
|
||||
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.
|
||||
@ -1074,6 +1088,15 @@ ${cmdStyle}create playlist named <name> from { queue | selection}${normalStyle}
|
||||
current play queue or the current selection.
|
||||
"""
|
||||
|
||||
// DELETE
|
||||
// --------------
|
||||
case 'delete': return """\
|
||||
${cmdStyle}delete playlist <name | id>
|
||||
delete bookmark <name | id>${normalStyle}
|
||||
|
||||
Delete a playlist or bookmark.
|
||||
"""
|
||||
|
||||
// PLAY
|
||||
// --------------
|
||||
case 'play': return """\
|
||||
@ -1336,10 +1359,14 @@ Playlist and Queue Management:
|
||||
create bookmark named <name> on playlist <playlist name | id> at <file name | id>
|
||||
create playlist named <name> from { selection | queue }
|
||||
create playlist named <name from <selection-criteria>
|
||||
|
||||
copy playlist <id | name> as <new name>
|
||||
create bookmark <id | name>
|
||||
update bookmark <id | name>
|
||||
|
||||
delete playlist <id | name>
|
||||
delete bookmark <id | name>
|
||||
|
||||
randomize queue
|
||||
randomize playlist
|
||||
|
||||
|
@ -637,6 +637,11 @@ public class DbApi {
|
||||
return sql.rows(query, sqlParams)
|
||||
.collect { recordToModel(Playlist, it) } }
|
||||
|
||||
public int delete(Playlist p) {
|
||||
return withTransaction {
|
||||
removeAllFromPlaylist(p.id)
|
||||
delete((Model) p) } }
|
||||
|
||||
public int getNextPlaylistPosition(UUID playlistId) {
|
||||
String query = """\
|
||||
SELECT COALESCE(MAX(position), 0) + 1
|
||||
@ -740,7 +745,8 @@ public class DbApi {
|
||||
logger.debug(
|
||||
'Finding media file playlist position.\n\tSQL: {}\n\tPARAMS: {}',
|
||||
getPositionQuery, params)
|
||||
int position = sql.firstRow(getPositionQuery, params)[0]
|
||||
def row = sql.firstRow(getPositionQuery, params)
|
||||
int position = row ? row[0] : 0
|
||||
|
||||
logger.debug(
|
||||
'Removing media file from playlist.\n\tSQL: {}\n\tPARAMS: {}',
|
||||
|
Loading…
Reference in New Issue
Block a user