From e2605577f5169dad14a238e6ab53b409af32f4d3 Mon Sep 17 00:00:00 2001 From: et0h Date: Thu, 28 Oct 2021 01:25:25 +0100 Subject: [PATCH] Add queue and select command (#472) --- syncplay/__init__.py | 2 +- syncplay/client.py | 5 +++++ syncplay/constants.py | 1 + syncplay/messages_de.py | 1 + syncplay/messages_en.py | 1 + syncplay/messages_es.py | 1 + syncplay/messages_it.py | 1 + syncplay/messages_pt_BR.py | 1 + syncplay/messages_pt_PT.py | 1 + syncplay/messages_ru.py | 1 + syncplay/messages_tr.py | 1 + syncplay/ui/consoleUI.py | 5 ++++- 12 files changed, 19 insertions(+), 2 deletions(-) diff --git a/syncplay/__init__.py b/syncplay/__init__.py index 88dea82d..f3c37c46 100755 --- a/syncplay/__init__.py +++ b/syncplay/__init__.py @@ -1,5 +1,5 @@ version = '1.7.0' revision = ' development' milestone = 'Yoitsu' -release_number = '100' +release_number = '101' projectURL = 'https://syncplay.pl/' diff --git a/syncplay/client.py b/syncplay/client.py index acc40271..d3c4c3f3 100755 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -1700,6 +1700,7 @@ def __init__(self, client): self._playlist = [] self._playlistIndex = None self.addedChangeListCallback = False + self.switchToNewPlaylistItem = False self._lastPlaylistIndexChange = time.time() def needsSharedPlaylistsEnabled(f): # @NoSelf @@ -1864,6 +1865,10 @@ def switchToNewPlaylistIndex(self, index, resetPosition = False): self._ui.showDebugMessage("Could not change playlist index due to IndexError") def _getValidIndexFromNewPlaylist(self, newPlaylist=None): + if self.switchToNewPlaylistItem: + self.switchToNewPlaylistItem = False + return len(self._playlist) + if self._playlistIndex is None or not newPlaylist or len(newPlaylist) <= 1: return 0 diff --git a/syncplay/constants.py b/syncplay/constants.py index b9c04120..ddb2f73e 100755 --- a/syncplay/constants.py +++ b/syncplay/constants.py @@ -125,6 +125,7 @@ def getValueForOS(constantDict): COMMANDS_AUTH = ['a', 'auth'] COMMANDS_TOGGLE = ['t', 'toggle'] COMMANDS_QUEUE = ['queue', 'qa', 'add'] +COMMANDS_QUEUEANDSELECT = ['queueandselect','qas'] COMMANDS_PLAYLIST = ['playlist', 'ql', 'pl'] COMMANDS_SELECT = ['select', 'qs'] COMMANDS_DELETE = ['delete', 'd', 'qd'] diff --git a/syncplay/messages_de.py b/syncplay/messages_de.py index b9060bb6..632293e7 100755 --- a/syncplay/messages_de.py +++ b/syncplay/messages_de.py @@ -89,6 +89,7 @@ "commandlist-notification/auth": "\ta [password] - authentifiziere als Raumleiter mit Passwort", "commandlist-notification/chat": "\tch [message] - Chatnachricht an einem Raum senden", "commandList-notification/queue": "\tqa [file/url] - add file or url to bottom of playlist", # TO DO: Translate + "commandList-notification/queueandselect": "\tqas [file/url] - add file or url to bottom of playlist and select it", # TO DO: Translate "commandList-notification/playlist": "\tql - show the current playlist", # TO DO: Translate "commandList-notification/select": "\tqs [index] - select given entry in the playlist", # TO DO: Translate "commandList-notification/delete": "\tqd [index] - delete the given entry from the playlist", # TO DO: Translate diff --git a/syncplay/messages_en.py b/syncplay/messages_en.py index 71302d4c..8ad9d054 100755 --- a/syncplay/messages_en.py +++ b/syncplay/messages_en.py @@ -89,6 +89,7 @@ "commandlist-notification/auth": "\ta [password] - authenticate as room operator with operator password", "commandlist-notification/chat": "\tch [message] - send a chat message in a room", "commandList-notification/queue": "\tqa [file/url] - add file or url to bottom of playlist", + "commandList-notification/queueandselect": "\tqas [file/url] - add file or url to bottom of playlist and select it", "commandList-notification/playlist": "\tql - show the current playlist", "commandList-notification/select": "\tqs [index] - select given entry in the playlist", "commandList-notification/delete": "\tqd [index] - delete the given entry from the playlist", diff --git a/syncplay/messages_es.py b/syncplay/messages_es.py index 7283b287..b45a7d1b 100644 --- a/syncplay/messages_es.py +++ b/syncplay/messages_es.py @@ -89,6 +89,7 @@ "commandlist-notification/auth": "\ta [contraseña] - autentificar como operador de la sala con la contraseña de operador", "commandlist-notification/chat": "\tch [mensaje] - enviar un mensaje en la sala", "commandList-notification/queue": "\tqa [file/url] - add file or url to bottom of playlist", # TO DO: Translate + "commandList-notification/queueandselect": "\tqas [file/url] - add file or url to bottom of playlist and select it", # TO DO: Translate "commandList-notification/playlist": "\tql - show the current playlist", # TO DO: Translate "commandList-notification/select": "\tqs [index] - select given entry in the playlist", # TO DO: Translate "commandList-notification/delete": "\tqd [index] - delete the given entry from the playlist", # TO DO: Translate diff --git a/syncplay/messages_it.py b/syncplay/messages_it.py index 42c62ea6..72429a24 100755 --- a/syncplay/messages_it.py +++ b/syncplay/messages_it.py @@ -89,6 +89,7 @@ "commandlist-notification/auth": "\ta [password] - autentica come gestore della stanza, utilizzando la password del gestore", "commandlist-notification/chat": "\tch [message] - invia un messaggio nella chat della stanza", "commandList-notification/queue": "\tqa [file/url] - add file or url to bottom of playlist", # TO DO: Translate + "commandList-notification/queueandselect": "\tqas [file/url] - add file or url to bottom of playlist and select it", # TO DO: Translate "commandList-notification/playlist": "\tql - show the current playlist", # TO DO: Translate "commandList-notification/select": "\tqs [index] - select given entry in the playlist", # TO DO: Translate "commandList-notification/delete": "\tqd [index] - delete the given entry from the playlist", # TO DO: Translate diff --git a/syncplay/messages_pt_BR.py b/syncplay/messages_pt_BR.py index c75fb7d5..05c4060d 100644 --- a/syncplay/messages_pt_BR.py +++ b/syncplay/messages_pt_BR.py @@ -90,6 +90,7 @@ "commandlist-notification/auth": "\ta [senha] - autentica-se como operador da sala com a senha", "commandlist-notification/chat": "\tch [mensagem] - envia uma mensagem no chat da sala", "commandList-notification/queue": "\tqa [file/url] - adiciona arquivo ou URL para o final da playlist", + "commandList-notification/queueandselect": "\tqas [file/url] - add file or url to bottom of playlist and select it", # TO DO: Translate "commandList-notification/playlist": "\tql - mostra a playlist atual", "commandList-notification/select": "\tqs [index] - seleciona uma dada entrada na playlist", "commandList-notification/delete": "\tqd [index] - deleta uma dada entrada na playlist", diff --git a/syncplay/messages_pt_PT.py b/syncplay/messages_pt_PT.py index 2ab1876c..a451390a 100644 --- a/syncplay/messages_pt_PT.py +++ b/syncplay/messages_pt_PT.py @@ -89,6 +89,7 @@ "commandlist-notification/auth": "\ta [senha] - autentica-se como administrador da sala com a senha", "commandlist-notification/chat": "\tch [mensagem] - envia uma mensagem no chat da sala", "commandList-notification/queue": "\tqa [file/url] - add file or url to bottom of playlist", # TO DO: Translate + "commandList-notification/queueandselect": "\tqas [file/url] - add file or url to bottom of playlist and select it", # TO DO: Translate "commandList-notification/playlist": "\tql - show the current playlist", # TO DO: Translate "commandList-notification/select": "\tqs [index] - select given entry in the playlist", # TO DO: Translate "commandList-notification/delete": "\tqd [index] - delete the given entry from the playlist", # TO DO: Translate diff --git a/syncplay/messages_ru.py b/syncplay/messages_ru.py index a0e6c0dd..c9cda466 100755 --- a/syncplay/messages_ru.py +++ b/syncplay/messages_ru.py @@ -88,6 +88,7 @@ "commandlist-notification/auth": "\ta [пароль] - авторизоваться как оператор комнаты с помощью пароля", "commandlist-notification/chat": "\tch [сообщение] - выслать сообщение в комнату", "commandList-notification/queue": "\tqa [файл/URL] - добавить файл или URL в конец списка воспроизведения", + "commandList-notification/queueandselect": "\tqas [file/url] - add file or url to bottom of playlist and select it", # TO DO: Translate "commandList-notification/playlist": "\tql - показать текущий список воспроизведения", "commandList-notification/select": "\tqs [индекс] - выделить указанный пункт в списке воспроизведения", "commandList-notification/delete": "\tqd [индекс] - удалить указанный пункт из списка воспроизведения", diff --git a/syncplay/messages_tr.py b/syncplay/messages_tr.py index 115f4326..efb045aa 100644 --- a/syncplay/messages_tr.py +++ b/syncplay/messages_tr.py @@ -89,6 +89,7 @@ "commandlist-notification/auth": "\ta [password] - operatör şifresi ile oda operatörü olarak kimlik doğrular", "commandlist-notification/chat": "\tch [message] - bir odaya sohbet mesajı gönderir", "commandList-notification/queue": "\tqa [file/url] - oynatma listesinin altına dosya veya bağlantı ekler", + "commandList-notification/queueandselect": "\tqas [file/url] - add file or url to bottom of playlist and select it", # TO DO: Translate "commandList-notification/playlist": "\tql - mevcut oynatma listesini gösterir", "commandList-notification/select": "\tqs [index] - oynatma listesinde verilen girişi seçer", "commandList-notification/delete": "\tqd [index] - verilen girişi oynatma listesinden siler", diff --git a/syncplay/ui/consoleUI.py b/syncplay/ui/consoleUI.py index 7363ae64..00a00035 100755 --- a/syncplay/ui/consoleUI.py +++ b/syncplay/ui/consoleUI.py @@ -193,8 +193,10 @@ def executeCommand(self, data): if filename is None: self.showErrorMessage("No file/url given") return - self._syncplayClient.ui.addFileToPlaylist(filename) + elif command.group('command') in constants.COMMANDS_QUEUEANDSELECT: + self._syncplayClient.playlist.switchToNewPlaylistItem = True + self.executeCommand("{} {}".format(constants.COMMANDS_QUEUE[0], command.group('parameter'))) elif command.group('command') in constants.COMMANDS_PLAYLIST: playlist = self._syncplayClient.playlist playlist_elements = ["\t{}: {}".format(i+1, el) for i, el in enumerate(playlist._playlist)] @@ -244,6 +246,7 @@ def executeCommand(self, data): 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/queueandselect"), True) self.showMessage(getMessage("commandList-notification/playlist"), True) self.showMessage(getMessage("commandList-notification/select"), True) self.showMessage(getMessage("commandList-notification/delete"), True)