diff --git a/syncplay/constants.py b/syncplay/constants.py index a3e6c7a..b2bf82f 100755 --- a/syncplay/constants.py +++ b/syncplay/constants.py @@ -124,6 +124,7 @@ COMMANDS_HELP = ['help', 'h', '?', '/?', r'\?'] COMMANDS_CREATE = ['c', 'create'] COMMANDS_AUTH = ['a', 'auth'] COMMANDS_TOGGLE = ['t', 'toggle'] +COMMANDS_QUEUE = ['queue', 'q', 'add'] 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 548f42a..d16e96d 100755 --- a/syncplay/messages_en.py +++ b/syncplay/messages_en.py @@ -87,6 +87,7 @@ en = { "commandlist-notification/create": "\tc [name] - create managed room using name of current room", "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": "\tq [file/url] - add file or url to bottom of 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 a7d2a4c..1fdeb17 100755 --- a/syncplay/ui/consoleUI.py +++ b/syncplay/ui/consoleUI.py @@ -3,12 +3,13 @@ import re import sys import threading import time +import os import syncplay from syncplay import constants from syncplay import utils from syncplay.messages import getMessage -from syncplay.utils import formatTime +from syncplay.utils import formatTime, isURL class ConsoleUI(threading.Thread): @@ -184,6 +185,21 @@ class ConsoleUI(threading.Thread): self._syncplayClient.identifyAsController(controlpassword) elif command.group('command') in constants.COMMANDS_TOGGLE: self._syncplayClient.toggleReady() + elif command.group('command') in constants.COMMANDS_QUEUE: + filename = command.group('parameter') + if filename is None: + self.showErrorMessage("No file/url given") + return + elif os.path.isfile(filename) or isURL(filename): + filePath = filename + else: + filePath = self._syncplayClient.fileSwitch.findFilepath(filename) + if filePath is None: + self.showErrorMessage(getMessage("cannot-find-file-for-playlist-switch-error").format(filename)) + else: + self._syncplayClient.ui.addFileToPlaylist(filePath) + + else: if self._tryAdvancedCommands(data): return @@ -200,6 +216,7 @@ class ConsoleUI(threading.Thread): self.showMessage(getMessage("commandlist-notification/create"), True) self.showMessage(getMessage("commandlist-notification/auth"), True) self.showMessage(getMessage("commandlist-notification/chat"), True) + self.showMessage(getMessage("commandList-notification/queue"), True) self.showMessage(getMessage("syncplay-version-notification").format(syncplay.version), True) self.showMessage(getMessage("more-info-notification").format(syncplay.projectURL), True)