add command to delete files from the playlist

This commit is contained in:
odrling 2020-06-04 06:07:57 +02:00
parent 11eb629b1a
commit bdf8cabc0a
4 changed files with 18 additions and 0 deletions

View File

@ -1883,6 +1883,12 @@ class SyncplayPlaylist():
def addToPlaylist(self, file):
self.changePlaylist([*self._playlist, file])
def deleteAtIndex(self, index):
new_playlist = self._playlist.copy()
if index < len(new_playlist):
del new_playlist[index]
self.changePlaylist(new_playlist)
@needsSharedPlaylistsEnabled
def undoPlaylistChange(self):
if self.canUndoPlaylist(self._playlist):

View File

@ -127,6 +127,7 @@ COMMANDS_TOGGLE = ['t', 'toggle']
COMMANDS_QUEUE = ['queue', 'q', 'add']
COMMANDS_PLAYLIST = ['playlist', 'ql', 'pl']
COMMANDS_SELECT = ['select', 'qs']
COMMANDS_DELETE = ['delete', 'd', 'qd']
MPC_MIN_VER = "1.6.4"
MPC_BE_MIN_VER = "1.5.2.3123"
VLC_MIN_VERSION = "2.2.1"

View File

@ -90,6 +90,7 @@ en = {
"commandList-notification/queue": "\tq [file/url] - add file or url to bottom of playlist",
"commandList-notification/playlist": "\tql - show the current playlist",
"commandList-notification/select": "\tqs [index] - select given entry in the playlist",
"commandList-notification/delete": "\td [index] - delete the given entry from the playlist",
"syncplay-version-notification": "Syncplay version: {}", # syncplay.version
"more-info-notification": "More info available at: {}", # projectURL

View File

@ -211,6 +211,13 @@ class ConsoleUI(threading.Thread):
except TypeError:
print("invalid index")
elif command.group('command') in constants.COMMANDS_DELETE:
try:
index = int(command.group('parameter').strip())
self._syncplayClient.playlist.deleteAtIndex(index)
except TypeError:
print("invalid index")
else:
if self._tryAdvancedCommands(data):
@ -229,6 +236,9 @@ class ConsoleUI(threading.Thread):
self.showMessage(getMessage("commandlist-notification/auth"), True)
self.showMessage(getMessage("commandlist-notification/chat"), True)
self.showMessage(getMessage("commandList-notification/queue"), True)
self.showMessage(getMessage("commandList-notification/playlist"), True)
self.showMessage(getMessage("commandList-notification/select"), True)
self.showMessage(getMessage("commandList-notification/delete"), True)
self.showMessage(getMessage("syncplay-version-notification").format(syncplay.version), True)
self.showMessage(getMessage("more-info-notification").format(syncplay.projectURL), True)