mirror of
https://github.com/Syncplay/syncplay
synced 2025-03-11 06:07:53 +00:00
* add videos to playlist from chat * add urls to playlist * add files in media directory to playlist * add commands to show the playlist and select an index * add command to delete files from the playlist * show selected index in playlist * fix adding files with queue command in GUI mode * start indexing the playlist at 1 or at least that's what it would look like to the user * start all commands related to playlist with `q` Co-authored-by: kiscs <csandras05@gmail.com>
This commit is contained in:
parent
bf4bea65c3
commit
b09fb90b34
@ -1887,6 +1887,15 @@ class SyncplayPlaylist():
|
||||
self._ui.setPlaylist(self._playlist)
|
||||
self._ui.showMessage(getMessage("playlist-contents-changed-notification").format(username))
|
||||
|
||||
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):
|
||||
@ -2005,7 +2014,7 @@ class FileSwitchManager(object):
|
||||
self.mediaFilesCache = {}
|
||||
self.filenameWatchlist = []
|
||||
self.currentDirectory = None
|
||||
self.mediaDirectories = None
|
||||
self.mediaDirectories = client.getConfig().get('mediaSearchDirectories')
|
||||
self.lock = threading.Lock()
|
||||
self.folderSearchEnabled = True
|
||||
self.directorySearchError = None
|
||||
|
@ -124,6 +124,10 @@ COMMANDS_HELP = ['help', 'h', '?', '/?', r'\?']
|
||||
COMMANDS_CREATE = ['c', 'create']
|
||||
COMMANDS_AUTH = ['a', 'auth']
|
||||
COMMANDS_TOGGLE = ['t', 'toggle']
|
||||
COMMANDS_QUEUE = ['queue', 'qa', '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"
|
||||
|
@ -87,6 +87,10 @@ 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": "\tqa [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": "\tqd [index] - delete the given entry from the playlist",
|
||||
"syncplay-version-notification": "Syncplay version: {}", # syncplay.version
|
||||
"more-info-notification": "More info available at: {}", # projectURL
|
||||
|
||||
|
@ -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):
|
||||
@ -22,8 +23,13 @@ class ConsoleUI(threading.Thread):
|
||||
def addClient(self, client):
|
||||
self._syncplayClient = client
|
||||
|
||||
def addFileToPlaylist(self):
|
||||
pass
|
||||
def addFileToPlaylist(self, file):
|
||||
if not isURL(file):
|
||||
if not self._syncplayClient.fileSwitch.findFilepath(file):
|
||||
print(f"{file} is not in any media directory")
|
||||
return
|
||||
|
||||
self._syncplayClient.playlist.addToPlaylist(file)
|
||||
|
||||
def drop(self):
|
||||
pass
|
||||
@ -184,6 +190,41 @@ 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
|
||||
|
||||
self._syncplayClient.ui.addFileToPlaylist(filename)
|
||||
elif command.group('command') in constants.COMMANDS_PLAYLIST:
|
||||
playlist = self._syncplayClient.playlist
|
||||
playlist_elements = [f"\t{i+1}: {el}" for i, el in enumerate(playlist._playlist)]
|
||||
|
||||
if playlist_elements:
|
||||
i = playlist._playlistIndex
|
||||
if i is not None and i in range(len(playlist_elements)):
|
||||
playlist_elements[i] = " *" + playlist_elements[i]
|
||||
|
||||
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()) - 1
|
||||
self._syncplayClient.playlist.changeToPlaylistIndex(index, resetPosition=True)
|
||||
self._syncplayClient.rewindFile()
|
||||
|
||||
except TypeError:
|
||||
print("invalid index")
|
||||
elif command.group('command') in constants.COMMANDS_DELETE:
|
||||
try:
|
||||
index = int(command.group('parameter').strip()) - 1
|
||||
self._syncplayClient.playlist.deleteAtIndex(index)
|
||||
|
||||
except TypeError:
|
||||
print("invalid index")
|
||||
|
||||
else:
|
||||
if self._tryAdvancedCommands(data):
|
||||
return
|
||||
@ -200,6 +241,10 @@ 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("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)
|
||||
|
||||
|
@ -1924,7 +1924,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
self.playlist.setPlaylistIndexFilename(filename)
|
||||
|
||||
def addFileToPlaylist(self, filePath, index=-1):
|
||||
if os.path.isfile(filePath):
|
||||
if not isURL:
|
||||
self.removePlaylistNote()
|
||||
filename = os.path.basename(filePath)
|
||||
if self.noPlaylistDuplicates(filename):
|
||||
@ -1933,7 +1933,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
else:
|
||||
self.playlist.insertItem(index, filename)
|
||||
self._syncplayClient.fileSwitch.notifyUserIfFileNotInMediaDirectory(filename, filePath)
|
||||
elif isURL(filePath):
|
||||
else:
|
||||
self.removePlaylistNote()
|
||||
if self.noPlaylistDuplicates(filePath):
|
||||
if self.playlist == -1 or index == -1:
|
||||
|
Loading…
Reference in New Issue
Block a user