Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow player arguments with spaces/quotes (#665) #668

Merged
merged 1 commit into from
Jan 28, 2024
Merged
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
1 change: 1 addition & 0 deletions syncplay/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def getValueForOS(constantDict):
FILENAME_STRIP_REGEX = "[-~_\.\[\](): ]"
CONTROL_PASSWORD_STRIP_REGEX = "[^a-zA-Z0-9\-]"
ROOM_NAME_STRIP_REGEX = "^(\+)(?P<roomnamebase>.*)(:)(\w{12})$"
ARGUMENT_SPLIT_REGEX = r'(?:[^\s"]+|"[^"]*")+'
COMMANDS_UNDO = ["u", "undo", "revert"]
COMMANDS_CHAT = ["ch", "chat"]
COMMANDS_LIST = ["l", "list", "users"]
Expand Down
8 changes: 6 additions & 2 deletions syncplay/players/vlc.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,14 @@ def _createIntfFolder(vlcSyncplayInterfaceDir):

call.extend(self.__playerController.SLAVE_ARGS)
if args:
call.extend(args)
for arg in args:
if "=" in arg and "\"" in arg:
(argName, argValue) = arg.split("=", 1)
if argValue.startswith("\"") and argValue.endswith("\""):
arg = argName + "=" + argValue[1:-1]
call.extend([arg])

self._vlcVersion = None

if isWindows() and getattr(sys, 'frozen', '') and getattr(sys, '_MEIPASS', '') is not None: # Needed for pyinstaller --onefile bundle
self.__process = subprocess.Popen(
call, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE,
Expand Down
2 changes: 1 addition & 1 deletion syncplay/ui/GuiConfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def changedPlayerArgs(self):
currentplayerpath = self.executablepathCombobox.currentText()

if currentplayerpath:
NewPlayerArgs = self.playerargsTextbox.text().split(" ") if self.playerargsTextbox.text() else ""
NewPlayerArgs = utils.parseCommandLineString(self.playerargsTextbox.text()) if self.playerargsTextbox.text() else ""
self.perPlayerArgs[self.executablepathCombobox.currentText()] = NewPlayerArgs

def languageChanged(self):
Expand Down
4 changes: 4 additions & 0 deletions syncplay/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ def limitedPowerset(s, minLength):
return itertools.chain.from_iterable(itertools.combinations(s, r) for r in range(len(s), minLength, -1))


def parseCommandLineString(s):
arsToReturn = re.findall(constants.ARGUMENT_SPLIT_REGEX, s)
return arsToReturn

def blackholeStdoutForFrozenWindow():
if getattr(sys, 'frozen', '') == "windows_exe":
class Stderr(object):
Expand Down
Loading