diff --git a/syncplay/client.py b/syncplay/client.py index 5eb91ae..90f3200 100755 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -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): diff --git a/syncplay/constants.py b/syncplay/constants.py index a9b6985..1451abe 100755 --- a/syncplay/constants.py +++ b/syncplay/constants.py @@ -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" diff --git a/syncplay/messages_en.py b/syncplay/messages_en.py index f2d1309..fd0f8ea 100755 --- a/syncplay/messages_en.py +++ b/syncplay/messages_en.py @@ -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 diff --git a/syncplay/ui/consoleUI.py b/syncplay/ui/consoleUI.py index 2d1f9fb..6b2b166 100755 --- a/syncplay/ui/consoleUI.py +++ b/syncplay/ui/consoleUI.py @@ -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)