add commands to show the playlist and select an index

This commit is contained in:
odrling 2020-06-04 05:54:57 +02:00
parent 2814fe00ca
commit 11eb629b1a
3 changed files with 18 additions and 0 deletions

View File

@ -125,6 +125,8 @@ COMMANDS_CREATE = ['c', 'create']
COMMANDS_AUTH = ['a', 'auth']
COMMANDS_TOGGLE = ['t', 'toggle']
COMMANDS_QUEUE = ['queue', 'q', 'add']
COMMANDS_PLAYLIST = ['playlist', 'ql', 'pl']
COMMANDS_SELECT = ['select', 'qs']
MPC_MIN_VER = "1.6.4"
MPC_BE_MIN_VER = "1.5.2.3123"
VLC_MIN_VERSION = "2.2.1"

View File

@ -88,6 +88,8 @@ en = {
"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",
"commandList-notification/playlist": "\tql - show the current playlist",
"commandList-notification/select": "\tqs [index] - select given entry in the playlist",
"syncplay-version-notification": "Syncplay version: {}", # syncplay.version
"more-info-notification": "More info available at: {}", # projectURL

View File

@ -197,6 +197,20 @@ class ConsoleUI(threading.Thread):
return
self._syncplayClient.ui.addFileToPlaylist(filename)
elif command.group('command') in constants.COMMANDS_PLAYLIST:
playlist_elements = [f"\t{i}: {el}" for i, el in enumerate(self._syncplayClient.playlist._playlist)]
if playlist_elements:
print(*playlist_elements, sep='\n')
else:
print("playlist is currently empty.")
elif command.group('command') in constants.COMMANDS_SELECT:
try:
index = int(command.group('parameter').strip())
self._syncplayClient.playlist.changeToPlaylistIndex(index, resetPosition=True)
self._syncplayClient.rewindFile()
except TypeError:
print("invalid index")
else:
if self._tryAdvancedCommands(data):