Allow per-player arguments (#59)

This commit is contained in:
Et0h 2015-06-24 00:01:55 +01:00
parent 763829a00e
commit 6c56432fbd
7 changed files with 62 additions and 5 deletions

View File

@ -676,7 +676,7 @@ info = dict(
options={'py2exe': { options={'py2exe': {
'dist_dir': OUT_DIR, 'dist_dir': OUT_DIR,
'packages': 'PySide.QtUiTools', 'packages': 'PySide.QtUiTools',
'includes': 'twisted, sys, encodings, datetime, os, time, math, PySide, liburl', 'includes': 'twisted, sys, encodings, datetime, os, time, math, PySide, liburl, ast',
'excludes': 'venv, _ssl, doctest, pdb, unittest, win32clipboard, win32file, win32pdh, win32security, win32trace, win32ui, winxpgui, win32pipe, win32process, Tkinter', 'excludes': 'venv, _ssl, doctest, pdb, unittest, win32clipboard, win32file, win32pdh, win32security, win32trace, win32ui, winxpgui, win32pipe, win32process, Tkinter',
'dll_excludes': 'msvcr71.dll, MSVCP90.dll, POWRPROF.dll', 'dll_excludes': 'msvcr71.dll, MSVCP90.dll, POWRPROF.dll',
'optimize': 2, 'optimize': 2,

View File

@ -1,4 +1,4 @@
version = '1.3.1' version = '1.3.1'
milestone = 'Chami' milestone = 'Chami'
release_number = '12' release_number = '13'
projectURL = 'http://syncplay.pl/' projectURL = 'http://syncplay.pl/'

View File

@ -497,7 +497,10 @@ class SyncplayClient(object):
return return
self._running = True self._running = True
if self._playerClass: if self._playerClass:
reactor.callLater(0.1, self._playerClass.run, self, self._config['playerPath'], self._config['file'], self._config['playerArgs']) perPlayerArguments = utils.getPlayerArgumentsByPathAsArray(self._config['perPlayerArguments'],self._config['playerPath'])
if perPlayerArguments:
self._config['playerArgs'].extend(perPlayerArguments)
reactor.callLater(0.1, self._playerClass.run, self, self._config['playerPath'], self._config['file'], self._config['playerArgs'], )
self._playerClass = None self._playerClass = None
self.protocolFactory = SyncClientFactory(self) self.protocolFactory = SyncClientFactory(self)
port = int(port) port = int(port)

View File

@ -169,6 +169,7 @@ en = {
"media-setting-title" : "Media player settings", "media-setting-title" : "Media player settings",
"executable-path-label" : "Path to media player:", "executable-path-label" : "Path to media player:",
"media-path-label" : "Path to media file:", "media-path-label" : "Path to media file:",
"player-arguments-label" : "Player arguments (if any):",
"browse-label" : "Browse", "browse-label" : "Browse",
"more-title" : "Show more settings", "more-title" : "Show more settings",
@ -284,6 +285,7 @@ en = {
"executable-path-tooltip" : "Location of your chosen supported media player (MPC-HC, VLC, mplayer2 or mpv).", "executable-path-tooltip" : "Location of your chosen supported media player (MPC-HC, VLC, mplayer2 or mpv).",
"media-path-tooltip" : "Location of video or stream to be opened. Necessary for mpv and mplayer2.", "media-path-tooltip" : "Location of video or stream to be opened. Necessary for mpv and mplayer2.",
"player-arguments-tooltip" : "Additional command line arguments / switches to pass on to this media player.",
"more-tooltip" : "Display less frequently used settings.", "more-tooltip" : "Display less frequently used settings.",
"filename-privacy-tooltip" : "Privacy mode for sending currently playing filename to server.", "filename-privacy-tooltip" : "Privacy mode for sending currently playing filename to server.",
@ -527,6 +529,7 @@ ru = {
"media-setting-title" : u"Параметры проигрывателя", "media-setting-title" : u"Параметры проигрывателя",
"executable-path-label" : u"Путь к проигрывателю:", "executable-path-label" : u"Путь к проигрывателю:",
"media-path-label" : u"Путь к видеофайлу:", "media-path-label" : u"Путь к видеофайлу:",
"player-arguments-label" : "Player arguments:", # TODO: Translate into Russian
"browse-label" : u"Выбрать", "browse-label" : u"Выбрать",
"more-title" : u"Больше настроек", "more-title" : u"Больше настроек",
@ -642,6 +645,7 @@ ru = {
"executable-path-tooltip" : u"Расположение Вашего видеопроигрывателя (MPC-HC, VLC, mplayer2 или mpv).", "executable-path-tooltip" : u"Расположение Вашего видеопроигрывателя (MPC-HC, VLC, mplayer2 или mpv).",
"media-path-tooltip" : u"Расположение видеофайла или потока для просмотра. Обязательно для mpv и mplayer2.", "media-path-tooltip" : u"Расположение видеофайла или потока для просмотра. Обязательно для mpv и mplayer2.",
"player-arguments-tooltip" : "Additional command line arguments / switches to pass on to this media player.", # TODO: Translate into Russian
"more-tooltip" : u"Показать дополнительные настройки.", "more-tooltip" : u"Показать дополнительные настройки.",
"filename-privacy-tooltip" : u"Режим приватности для передачи имени воспроизводимого файла на сервер.", "filename-privacy-tooltip" : u"Режим приватности для передачи имени воспроизводимого файла на сервер.",
@ -885,6 +889,7 @@ de = {
"media-setting-title" : u"Media-Player Einstellungen", "media-setting-title" : u"Media-Player Einstellungen",
"executable-path-label" : u"Pfad zum Media-Player:", "executable-path-label" : u"Pfad zum Media-Player:",
"media-path-label" : u"Pfad zur Datei:", "media-path-label" : u"Pfad zur Datei:",
"player-arguments-label" : "Player arguments:", # TODO: Translate into German
"browse-label" : u"Durchsuchen", "browse-label" : u"Durchsuchen",
"more-title" : u"Mehr Einstellungen zeigen", "more-title" : u"Mehr Einstellungen zeigen",
@ -998,6 +1003,7 @@ de = {
"executable-path-tooltip" : u"Pfad zum ausgewählten, unterstützten Mediaplayer (MPC-HC, VLC, mplayer2 or mpv).", "executable-path-tooltip" : u"Pfad zum ausgewählten, unterstützten Mediaplayer (MPC-HC, VLC, mplayer2 or mpv).",
"media-path-tooltip" : u"Pfad zum wiederzugebenden Video oder Stream. Notwendig für mpv und mplayer2.", "media-path-tooltip" : u"Pfad zum wiederzugebenden Video oder Stream. Notwendig für mpv und mplayer2.",
"player-arguments-tooltip" : "Additional command line arguments / switches to pass on to this media player.", # TODO: Translate into German
"more-tooltip" : u"Weitere Einstellungen anzeigen.", "more-tooltip" : u"Weitere Einstellungen anzeigen.",
"filename-privacy-tooltip" : u"Privatheitsmodus beim Senden des Namens der aktuellen Datei zum Server.", "filename-privacy-tooltip" : u"Privatheitsmodus beim Senden des Namens der aktuellen Datei zum Server.",

View File

@ -2,6 +2,7 @@ from ConfigParser import SafeConfigParser, DEFAULTSECT
import argparse import argparse
import os import os
import sys import sys
import ast
from syncplay import constants, utils, version, milestone from syncplay import constants, utils, version, milestone
from syncplay.messages import getMessage, setLanguage, isValidLanguage from syncplay.messages import getMessage, setLanguage, isValidLanguage
from syncplay.players.playerFactory import PlayerFactory from syncplay.players.playerFactory import PlayerFactory
@ -31,6 +32,7 @@ class ConfigurationGetter(object):
"room": "", "room": "",
"password": None, "password": None,
"playerPath": None, "playerPath": None,
"perPlayerArguments": None,
"file": None, "file": None,
"playerArgs": [], "playerArgs": [],
"playerClass": None, "playerClass": None,
@ -104,6 +106,10 @@ class ConfigurationGetter(object):
"autoplayInitialState", "autoplayInitialState",
] ]
self._serialised = [
"perPlayerArguments",
]
self._numeric = [ self._numeric = [
"slowdownThreshold", "slowdownThreshold",
"rewindThreshold", "rewindThreshold",
@ -113,7 +119,7 @@ class ConfigurationGetter(object):
self._iniStructure = { self._iniStructure = {
"server_data": ["host", "port", "password"], "server_data": ["host", "port", "password"],
"client_settings": ["name", "room", "playerPath", "slowdownThreshold", "rewindThreshold", "fastforwardThreshold", "slowOnDesync", "rewindOnDesync", "fastforwardOnDesync", "dontSlowDownWithMe", "forceGuiPrompt", "filenamePrivacyMode", "filesizePrivacyMode", "unpauseAction", "pauseOnLeave", "readyAtStart", "autoplayMinUsers", "autoplayInitialState"], "client_settings": ["name", "room", "playerPath", "perPlayerArguments", "slowdownThreshold", "rewindThreshold", "fastforwardThreshold", "slowOnDesync", "rewindOnDesync", "fastforwardOnDesync", "dontSlowDownWithMe", "forceGuiPrompt", "filenamePrivacyMode", "filesizePrivacyMode", "unpauseAction", "pauseOnLeave", "readyAtStart", "autoplayMinUsers", "autoplayInitialState"],
"gui": ["showOSD", "showOSDWarnings", "showSlowdownOSD", "showDifferentRoomOSD", "showSameRoomOSD", "showNonControllerOSD", "showDurationNotification"], "gui": ["showOSD", "showOSDWarnings", "showSlowdownOSD", "showDifferentRoomOSD", "showSameRoomOSD", "showNonControllerOSD", "showDurationNotification"],
"general": ["language", "checkForUpdatesAutomatically", "lastCheckedForUpdates"] "general": ["language", "checkForUpdatesAutomatically", "lastCheckedForUpdates"]
} }
@ -150,6 +156,12 @@ class ConfigurationGetter(object):
elif self._config[key] == "False": elif self._config[key] == "False":
self._config[key] = False self._config[key] = False
for key in self._serialised:
if self._config[key] is None or self._config[key] == "":
self._config[key] = {}
elif isinstance(self._config[key], (str, unicode)):
self._config[key] = ast.literal_eval(self._config[key])
for key in self._tristate: for key in self._tristate:
if self._config[key] == "True": if self._config[key] == "True":
self._config[key] = True self._config[key] = True

View File

@ -134,13 +134,27 @@ class ConfigDialog(QtGui.QDialog):
return foundpath return foundpath
def updateExecutableIcon(self): def updateExecutableIcon(self):
currentplayerpath = unicode(self.executablepathCombobox.currentText()) currentplayerpath = self.executablepathCombobox.currentText()
iconpath = PlayerFactory().getPlayerIconByPath(currentplayerpath) iconpath = PlayerFactory().getPlayerIconByPath(currentplayerpath)
if iconpath != None and iconpath != "": if iconpath != None and iconpath != "":
self.executableiconImage.load(self.resourcespath + iconpath) self.executableiconImage.load(self.resourcespath + iconpath)
self.executableiconLabel.setPixmap(QtGui.QPixmap.fromImage(self.executableiconImage)) self.executableiconLabel.setPixmap(QtGui.QPixmap.fromImage(self.executableiconImage))
else: else:
self.executableiconLabel.setPixmap(QtGui.QPixmap.fromImage(QtGui.QImage())) self.executableiconLabel.setPixmap(QtGui.QPixmap.fromImage(QtGui.QImage()))
self.updatePlayerArguments(currentplayerpath)
def updatePlayerArguments(self, currentplayerpath):
argumentsForPath = utils.getPlayerArgumentsByPathAsText(self.perPlayerArgs, currentplayerpath)
self.playerargsTextbox.blockSignals(True)
self.playerargsTextbox.setText(argumentsForPath)
self.playerargsTextbox.blockSignals(False)
def changedPlayerArgs(self):
currentplayerpath = self.executablepathCombobox.currentText()
if currentplayerpath:
NewPlayerArgs = self.playerargsTextbox.text().split(u" ") if self.playerargsTextbox.text() else ""
self.perPlayerArgs[self.executablepathCombobox.currentText()]=NewPlayerArgs
def languageChanged(self): def languageChanged(self):
setLanguage(unicode(self.languageCombobox.itemData(self.languageCombobox.currentIndex()))) setLanguage(unicode(self.languageCombobox.itemData(self.languageCombobox.currentIndex())))
@ -235,6 +249,8 @@ class ConfigDialog(QtGui.QDialog):
self.automaticUpdatePromptCheck() self.automaticUpdatePromptCheck()
self.loadLastUpdateCheckDate() self.loadLastUpdateCheckDate()
self.config["perPlayerArguments"] = self.perPlayerArgs
self.processWidget(self, lambda w: self.saveValues(w)) self.processWidget(self, lambda w: self.saveValues(w))
if self.hostTextbox.text(): if self.hostTextbox.text():
self.config['host'] = self.hostTextbox.text() if ":" in self.hostTextbox.text() else self.hostTextbox.text() + ":" + unicode(constants.DEFAULT_PORT) self.config['host'] = self.hostTextbox.text() if ":" in self.hostTextbox.text() else self.hostTextbox.text() + ":" + unicode(constants.DEFAULT_PORT)
@ -364,6 +380,8 @@ class ConfigDialog(QtGui.QDialog):
else: else:
host = config['host'] + ":" + str(config['port']) host = config['host'] + ":" + str(config['port'])
self.perPlayerArgs = self.config["perPlayerArguments"]
self.connectionSettingsGroup = QtGui.QGroupBox(getMessage("connection-group-title")) self.connectionSettingsGroup = QtGui.QGroupBox(getMessage("connection-group-title"))
self.hostTextbox = QLineEdit(host, self) self.hostTextbox = QLineEdit(host, self)
self.hostLabel = QLabel(getMessage("host-label"), self) self.hostLabel = QLabel(getMessage("host-label"), self)
@ -396,6 +414,10 @@ class ConfigDialog(QtGui.QDialog):
self.connectionSettingsGroup.setLayout(self.connectionSettingsLayout) self.connectionSettingsGroup.setLayout(self.connectionSettingsLayout)
self.connectionSettingsGroup.setMaximumHeight(self.connectionSettingsGroup.minimumSizeHint().height()) self.connectionSettingsGroup.setMaximumHeight(self.connectionSettingsGroup.minimumSizeHint().height())
self.playerargsTextbox = QLineEdit("", self)
self.playerargsTextbox.textEdited.connect(self.changedPlayerArgs)
self.playerargsLabel = QLabel(getMessage("player-arguments-label"), self)
self.mediaplayerSettingsGroup = QtGui.QGroupBox(getMessage("media-setting-title")) self.mediaplayerSettingsGroup = QtGui.QGroupBox(getMessage("media-setting-title"))
self.executableiconImage = QtGui.QImage() self.executableiconImage = QtGui.QImage()
self.executableiconLabel = QLabel(self) self.executableiconLabel = QLabel(self)
@ -419,6 +441,8 @@ class ConfigDialog(QtGui.QDialog):
self.executablepathCombobox.setObjectName("executable-path") self.executablepathCombobox.setObjectName("executable-path")
self.mediapathLabel.setObjectName("media-path") self.mediapathLabel.setObjectName("media-path")
self.mediapathTextbox.setObjectName(constants.LOAD_SAVE_MANUALLY_MARKER + "media-path") self.mediapathTextbox.setObjectName(constants.LOAD_SAVE_MANUALLY_MARKER + "media-path")
self.playerargsLabel.setObjectName("player-arguments")
self.playerargsTextbox.setObjectName(constants.LOAD_SAVE_MANUALLY_MARKER + "player-arguments")
self.mediaplayerSettingsLayout = QtGui.QGridLayout() self.mediaplayerSettingsLayout = QtGui.QGridLayout()
self.mediaplayerSettingsLayout.addWidget(self.executablepathLabel, 0, 0) self.mediaplayerSettingsLayout.addWidget(self.executablepathLabel, 0, 0)
@ -428,6 +452,8 @@ class ConfigDialog(QtGui.QDialog):
self.mediaplayerSettingsLayout.addWidget(self.mediapathLabel, 1, 0) self.mediaplayerSettingsLayout.addWidget(self.mediapathLabel, 1, 0)
self.mediaplayerSettingsLayout.addWidget(self.mediapathTextbox , 1, 2) self.mediaplayerSettingsLayout.addWidget(self.mediapathTextbox , 1, 2)
self.mediaplayerSettingsLayout.addWidget(self.mediabrowseButton , 1, 3) self.mediaplayerSettingsLayout.addWidget(self.mediabrowseButton , 1, 3)
self.mediaplayerSettingsLayout.addWidget(self.playerargsLabel, 2, 0, 1, 2)
self.mediaplayerSettingsLayout.addWidget(self.playerargsTextbox, 2, 2, 1, 2)
self.mediaplayerSettingsGroup.setLayout(self.mediaplayerSettingsLayout) self.mediaplayerSettingsGroup.setLayout(self.mediaplayerSettingsLayout)
self.showmoreCheckbox = QCheckBox(getMessage("more-title")) self.showmoreCheckbox = QCheckBox(getMessage("more-title"))

View File

@ -225,6 +225,16 @@ def isURL(path):
if "://" in path: if "://" in path:
return True return True
def getPlayerArgumentsByPathAsArray(arguments, path):
if arguments and not isinstance(arguments, (str, unicode)) and arguments.has_key(path):
return arguments[path]
else:
return None
def getPlayerArgumentsByPathAsText(arguments, path):
argsToReturn = getPlayerArgumentsByPathAsArray(arguments, path)
return " ".join(argsToReturn) if argsToReturn else ""
class RoomPasswordProvider(object): class RoomPasswordProvider(object):
CONTROLLED_ROOM_REGEX = re.compile("^\+(.*):(\w{12})$") CONTROLLED_ROOM_REGEX = re.compile("^\+(.*):(\w{12})$")
PASSWORD_REGEX = re.compile("[A-Z]{2}-\d{3}-\d{3}") PASSWORD_REGEX = re.compile("[A-Z]{2}-\d{3}-\d{3}")