Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions syncplay/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2074,6 +2074,14 @@ def changePlaylist(self, files, username=None, resetIndex=False):
def addToPlaylist(self, file):
self.changePlaylist([*self._playlist, file])

def addToPlaylistNext(self, file):
if self._playlistIndex is not None:
insert_pos = self._playlistIndex + 1
new_playlist = self._playlist[:insert_pos] + [file] + self._playlist[insert_pos:]
else:
new_playlist = [file] + self._playlist
self.changePlaylist(new_playlist)

def deleteAtIndex(self, index):
new_playlist = self._playlist.copy()
if index >= 0 and index < len(new_playlist):
Expand Down
2 changes: 2 additions & 0 deletions syncplay/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ def getValueForOS(constantDict):
COMMANDS_TOGGLE = ['t', 'toggle']
COMMANDS_QUEUE = ['queue', 'qa', 'add']
COMMANDS_QUEUEANDSELECT = ['queueandselect','qas']
COMMANDS_QUEUENEXT = ['queuenext', 'qan']
COMMANDS_QUEUENEXTANDSELECT = ['queuenextandselect', 'qans']
COMMANDS_PLAYLIST = ['playlist', 'ql', 'pl']
COMMANDS_SELECT = ['select', 'qs']
COMMANDS_DELETE = ['delete', 'd', 'qd']
Expand Down
3 changes: 3 additions & 0 deletions syncplay/messages_en.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@
"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/queuenext": "\tqan [file/url] - add file or url after the currently playing item",
"commandList-notification/queuenextandselect": "\tqans [file/url] - add file or url after the currently playing item and select it",
"commandList-notification/playlist": "\tql - show the current playlist",
"commandList-notification/select": "\tqs [index] - select given entry in the playlist",
"commandList-notification/next": "\tqn - select next entry in the playlist",
Expand Down Expand Up @@ -175,6 +177,7 @@

"invalid-seek-value": "Invalid seek value",
"invalid-offset-value": "Invalid offset value",
"no-file-or-url-given-error": "No file/url given",

"switch-file-not-found-error": "Could not switch to file '{0}'. Syncplay looks in specified media directories.", # File not found
"folder-search-timeout-error": "The search for media in media directories was aborted as it took too long to search through '{}' after having processed the first {:,} files. This will occur if you select a folder with too many sub-folders in your list of media folders to search through or if there are too many files to process. For automatic file switching to work again please select File->Set Media Directories in the menu bar and remove this directory or replace it with an appropriate sub-folder. If the folder is actually fine then you can re-enable it by selecting File->Set Media Directories and pressing 'OK'.", # Folder, Files processed. Note: {:,} is {} but with added commas seprators.
Expand Down
13 changes: 12 additions & 1 deletion syncplay/ui/consoleUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,21 @@ def executeCommand(self, data):
elif command.group('command') in constants.COMMANDS_QUEUE:
filename = command.group('parameter')
if filename is None:
self.showErrorMessage("No file/url given")
self.showErrorMessage(getMessage("no-file-or-url-given-error"))
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_QUEUENEXT:
filename = command.group('parameter')
if filename is None:
self.showErrorMessage(getMessage("no-file-or-url-given-error"))
return
self._syncplayClient.playlist.addToPlaylistNext(filename)
elif command.group('command') in constants.COMMANDS_QUEUENEXTANDSELECT:
self._syncplayClient.playlist.switchToNewPlaylistItem = True
self.executeCommand("{} {}".format(constants.COMMANDS_QUEUENEXT[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)]
Expand Down Expand Up @@ -264,6 +273,8 @@ def executeCommand(self, data):
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/queuenext"), True)
self.showMessage(getMessage("commandList-notification/queuenextandselect"), True)
self.showMessage(getMessage("commandList-notification/playlist"), True)
self.showMessage(getMessage("commandList-notification/select"), True)
self.showMessage(getMessage("commandList-notification/next"), True)
Expand Down