From 459c9e91985796210fbc36968f8a6e572141f24f Mon Sep 17 00:00:00 2001 From: Etoh Date: Sat, 3 Feb 2024 12:02:22 +0000 Subject: [PATCH 01/20] Pass input-ipc-server player argument to mpv (#529) (#669) * Pass input-ipc-server player argument to mpv (#529) * Create secondary mpv IPC Socket "mpvSyncplaySocket" by default --- syncplay/players/mpv.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/syncplay/players/mpv.py b/syncplay/players/mpv.py index 641a1c0..10c0aca 100755 --- a/syncplay/players/mpv.py +++ b/syncplay/players/mpv.py @@ -420,6 +420,8 @@ class MpvPlayer(BasePlayer): options_string = ", ".join(options) self._listener.sendLine(["script-message-to", "syncplayintf", "set_syncplayintf_options", options_string]) self._setOSDPosition() + publicIPCSocket = self._listener.mpv_arguments.get("input-ipc-server") if self._listener.mpv_arguments.get("input-ipc-server") else "mpvSyncplaySocket" + self._setProperty("input-ipc-server", publicIPCSocket) def _handleUnknownLine(self, line): self.mpvErrorCheck(line) From 7c9682a6f6e5fda078011043e066332c2bf690cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Wr=C3=B3bel?= <1662391+daniel-123@users.noreply.github.com> Date: Tue, 6 Feb 2024 22:43:04 +0100 Subject: [PATCH 02/20] Add missing depency to deb package python3-pem missing was causing the client to not support TLS. --- ci/deb-script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/deb-script.sh b/ci/deb-script.sh index 6b40afa..4a3eb32 100755 --- a/ci/deb-script.sh +++ b/ci/deb-script.sh @@ -16,7 +16,7 @@ Version: "$( )" Architecture: all Maintainer: -Depends: python3 (>= 3.6), python3-pyside2.qtwidgets, python3-pyside2.qtcore, python3-twisted (>= 16.4.0), python3-certifi, mpv (>= 0.23) | vlc (>= 2.2.1) +Depends: python3 (>= 3.6), python3-pyside2.qtwidgets, python3-pyside2.qtcore, python3-twisted (>= 16.4.0), python3-certifi, python3-pem, mpv (>= 0.23) | vlc (>= 2.2.1) Homepage: https://syncplay.pl Section: web Priority: optional From c670acba1fc2f6d4ebbcb085574bd36265f1db8a Mon Sep 17 00:00:00 2001 From: Etoh Date: Wed, 7 Feb 2024 19:11:46 +0000 Subject: [PATCH 03/20] Don't log 32/64-bit cryptography 'frozen zipimport' errors No need to log ":259: UserWarning: You are using cryptography on a 32-bit Python on a 64-bit Windows Operating System. Cryptography will be significantly faster if you switch to using a 64-bit Python." all the time. --- syncplay/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/syncplay/utils.py b/syncplay/utils.py index 076c509..2c0e7d5 100755 --- a/syncplay/utils.py +++ b/syncplay/utils.py @@ -211,7 +211,8 @@ def blackholeStdoutForFrozenWindow(): self._file = open(path, 'a', encoding='utf-8') # TODO: Handle errors. if self._file is not None: - self._file.write(text) + if not text.startswith(""): + self._file.write(text) self._file.flush() def flush(self): From 888bb537f78d26a6e8e52669f347fab5ea635e9b Mon Sep 17 00:00:00 2001 From: Etoh Date: Wed, 7 Feb 2024 19:22:02 +0000 Subject: [PATCH 04/20] MPC: Only reset position if file is playing (#663) Avoids MpcHcApi.PlayerNotReadyException if you add media to empty playlist. --- syncplay/players/mpc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syncplay/players/mpc.py b/syncplay/players/mpc.py index 05150dd..51329bd 100755 --- a/syncplay/players/mpc.py +++ b/syncplay/players/mpc.py @@ -407,7 +407,7 @@ class MPCHCAPIPlayer(BasePlayer): def openFile(self, filePath, resetPosition=False): self._mpcApi.openFile(filePath) - if resetPosition: + if resetPosition and self._mpcApi.filePlaying: self.setPosition(0, resetPosition=True) def displayMessage( From d5eb213a5962185c2dda47c818a4e0bde2a9392c Mon Sep 17 00:00:00 2001 From: Etoh Date: Fri, 16 Feb 2024 13:36:19 +0000 Subject: [PATCH 05/20] Reduce suppression of .exe error logging Increases verbosity to reduce aggressiveness of c670acba1fc2f6d4ebbcb085574bd36265f1db8a --- syncplay/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syncplay/utils.py b/syncplay/utils.py index 2c0e7d5..6adf663 100755 --- a/syncplay/utils.py +++ b/syncplay/utils.py @@ -211,7 +211,7 @@ def blackholeStdoutForFrozenWindow(): self._file = open(path, 'a', encoding='utf-8') # TODO: Handle errors. if self._file is not None: - if not text.startswith(""): + if not (text.startswith("") and "UserWarning:" in text): self._file.write(text) self._file.flush() From 899081ca6ee6ee5ce34b34d0fcb9aaa5504d4ea3 Mon Sep 17 00:00:00 2001 From: Et0h Date: Tue, 20 Feb 2024 18:40:36 +0000 Subject: [PATCH 06/20] Provide more information on PySide load failure --- syncplay/messages_de.py | 2 +- syncplay/messages_en.py | 2 +- syncplay/messages_eo.py | 2 +- syncplay/messages_es.py | 2 +- syncplay/messages_fi.py | 2 +- syncplay/messages_fr.py | 2 +- syncplay/messages_it.py | 2 +- syncplay/messages_ko.py | 2 +- syncplay/messages_pt_BR.py | 2 +- syncplay/messages_pt_PT.py | 2 +- syncplay/messages_ru.py | 2 +- syncplay/messages_tr.py | 2 +- syncplay/messages_zh_CN.py | 2 +- syncplay/ui/ConfigurationGetter.py | 9 +++++---- 14 files changed, 18 insertions(+), 17 deletions(-) diff --git a/syncplay/messages_de.py b/syncplay/messages_de.py index 19355c7..677fbf4 100755 --- a/syncplay/messages_de.py +++ b/syncplay/messages_de.py @@ -133,7 +133,7 @@ de = { "hostname-empty-error": "Hostname darf nicht leer sein", "empty-error": "{} darf nicht leer sein", # Configuration "media-player-error": "Player-Fehler: \"{}\"", # Error line - "unable-import-gui-error": "Konnte die GUI-Bibliotheken nicht importieren. PySide muss installiert sein, damit die grafische Oberfläche funktioniert.", + "unable-import-gui-error": "Konnte die GUI-Bibliotheken nicht importieren. PySide muss installiert sein, damit die grafische Oberfläche funktioniert. If you want to run Syncplay in console mode then run it with the --no-gui command line switch. See https://syncplay.pl/guide/ for more details.", # TODO: Translate end of message and update second sentence to be a translation of "You need to have the correct version of PySide installed for the GUI to work." "unable-import-twisted-error": "Twisted konnte nicht importiert werden. Bitte installiere Twisted v16.4.0 oder höher", "arguments-missing-error": "Notwendige Argumente fehlen, siehe --help", diff --git a/syncplay/messages_en.py b/syncplay/messages_en.py index 97a759d..ab3e302 100644 --- a/syncplay/messages_en.py +++ b/syncplay/messages_en.py @@ -133,7 +133,7 @@ en = { "hostname-empty-error": "Hostname can't be empty", "empty-error": "{} can't be empty", # Configuration "media-player-error": "Media player error: \"{}\"", # Error line - "unable-import-gui-error": "Could not import GUI libraries. If you do not have PySide installed then you will need to install it for the GUI to work.", + "unable-import-gui-error": "Could not import GUI libraries. You need to have the correct version of PySide installed for the GUI to work. If you want to run Syncplay in console mode then run it with the --no-gui command line switch. See https://syncplay.pl/guide/ for more details.", "unable-import-twisted-error": "Could not import Twisted. Please install Twisted v16.4.0 or later.", "arguments-missing-error": "Some necessary arguments are missing, refer to --help", diff --git a/syncplay/messages_eo.py b/syncplay/messages_eo.py index 4225f7c..31c2c08 100644 --- a/syncplay/messages_eo.py +++ b/syncplay/messages_eo.py @@ -136,7 +136,7 @@ eo = { "hostname-empty-error": "Nomo de gastiga komputilo ne povas esti malplena", "empty-error": "{} ne povas esti malplena", # Configuration "media-player-error": "Eraro de vidaŭdaĵa ludilo: \"{}\"", # Error line - "unable-import-gui-error": "Ne povis enporti fasadajn bibliotekojn. Se PySide ne estas instalita, vi devos instali ĝin, por ke la fasado funkciu.", + "unable-import-gui-error": "Ne povis enporti fasadajn bibliotekojn. Se PySide ne estas instalita, vi devos instali ĝin, por ke la fasado funkciu. If you want to run Syncplay in console mode then run it with the --no-gui command line switch. See https://syncplay.pl/guide/ for more details.", # TODO: Translate end of message and update second sentence to be a translation of "You need to have the correct version of PySide installed for the GUI to work." "unable-import-twisted-error": "Ne povis enporti la bibliotekon Twisted. Bonvolu instali version 16.4.0 de Twisted, aŭ pli altan.", "arguments-missing-error": "Iuj bezonataj parametroj mankas; vidu al --help", diff --git a/syncplay/messages_es.py b/syncplay/messages_es.py index 890b249..d6adeb0 100644 --- a/syncplay/messages_es.py +++ b/syncplay/messages_es.py @@ -133,7 +133,7 @@ es = { "hostname-empty-error": "El nombre del host no puede ser vacío", "empty-error": "{} no puede ser vacío", # Configuration "media-player-error": "Error del reproductor multimedia: \"{}\"", # Error line - "unable-import-gui-error": "No se lograron importar las librerías GUI. Si no tienes instalado PySide, entonces tendrás que instalarlo para que funcione el GUI.", + "unable-import-gui-error": "No se lograron importar las librerías GUI. Si no tienes instalado PySide, entonces tendrás que instalarlo para que funcione el GUI. If you want to run Syncplay in console mode then run it with the --no-gui command line switch. See https://syncplay.pl/guide/ for more details.", # TODO: Translate end of message and update second sentence to be a translation of "You need to have the correct version of PySide installed for the GUI to work." "unable-import-twisted-error": "No se logró importar Twisted. Por favor instala Twisted v16.4.0 o posterior.", "arguments-missing-error": "Están faltando algunos argumentos necesarios. Por favor revisa --help", diff --git a/syncplay/messages_fi.py b/syncplay/messages_fi.py index ec1d5b0..3590587 100644 --- a/syncplay/messages_fi.py +++ b/syncplay/messages_fi.py @@ -133,7 +133,7 @@ fi = { "hostname-empty-error": "Palvelinnimi ei voi olla tyhjä", "empty-error": "{} ei voi jättää tyhjäksi", # Configuration "media-player-error": "Mediasoitin kohtasi virheen: \"{}\"", # Error line - "unable-import-gui-error": "Käyttöliittymäkirjastoja ei saatu tuotua. Mikäli sinulla ei ole PySide asennettuna, tulee sinun asentaa se jotta käyttöliittymä toimisi.", + "unable-import-gui-error": "Käyttöliittymäkirjastoja ei saatu tuotua. Mikäli sinulla ei ole PySide asennettuna, tulee sinun asentaa se jotta käyttöliittymä toimisi. If you want to run Syncplay in console mode then run it with the --no-gui command line switch. See https://syncplay.pl/guide/ for more details.", # TODO: Translate end of message and update second sentence to be a translation of "You need to have the correct version of PySide installed for the GUI to work." "unable-import-twisted-error": "Twisted:iä ei onnistuttu tuomaan. Asenna Twisted v16.4.0 tai myöhäisempi.", "arguments-missing-error": "Joitakin vipuja uupuu, katso apua --help", diff --git a/syncplay/messages_fr.py b/syncplay/messages_fr.py index 6d95add..d39340c 100644 --- a/syncplay/messages_fr.py +++ b/syncplay/messages_fr.py @@ -133,7 +133,7 @@ fr = { "hostname-empty-error": "Le nom d'hôte ne peut pas être vide", "empty-error": "{} ne peut pas être vide", # Configuration "media-player-error": "Media player error: \"{}\"", # Error line - "unable-import-gui-error": "Impossible d'importer les bibliothèques GUI. Si vous n'avez pas installé PySide, vous devrez l'installer pour que l'interface graphique fonctionne.", + "unable-import-gui-error": "Impossible d'importer les bibliothèques GUI. Si vous n'avez pas installé PySide, vous devrez l'installer pour que l'interface graphique fonctionne. If you want to run Syncplay in console mode then run it with the --no-gui command line switch. See https://syncplay.pl/guide/ for more details.", # TODO: Translate end of message and update second sentence to be a translation of "You need to have the correct version of PySide installed for the GUI to work." "unable-import-twisted-error": "Impossible d'importer Twisted. Veuillez installer Twisted v16.4.0 ou une version ultérieure.", "arguments-missing-error": "Certains arguments nécessaires sont manquants, reportez-vous à --help", diff --git a/syncplay/messages_it.py b/syncplay/messages_it.py index cdf2b76..77fdd80 100755 --- a/syncplay/messages_it.py +++ b/syncplay/messages_it.py @@ -133,7 +133,7 @@ it = { "hostname-empty-error": "Il campo hostname non può essere vuoto", "empty-error": "Il campo {} non può esssere vuoto", # Configuration "media-player-error": "Errore media player: \"{}\"", # Error line - "unable-import-gui-error": "Non è possibile importare le librerie di interfaccia grafica. Hai bisogno di PySide per poter utilizzare l'interfaccia grafica.", + "unable-import-gui-error": "Non è possibile importare le librerie di interfaccia grafica. Hai bisogno di PySide per poter utilizzare l'interfaccia grafica. If you want to run Syncplay in console mode then run it with the --no-gui command line switch. See https://syncplay.pl/guide/ for more details.", # TODO: Translate end of message and update second sentence to be a translation of "You need to have the correct version of PySide installed for the GUI to work." "unable-import-twisted-error": "Non è possibile importare Twisted. Si prega di installare Twisted v16.4.0 o superiore.", "arguments-missing-error": "Alcuni argomenti obbligatori non sono stati trovati. Fai riferimento a --help", diff --git a/syncplay/messages_ko.py b/syncplay/messages_ko.py index d460ec4..b23c64e 100644 --- a/syncplay/messages_ko.py +++ b/syncplay/messages_ko.py @@ -133,7 +133,7 @@ ko = { "hostname-empty-error": "호스트이름은 비워둘 수 없습니다", "empty-error": "{}은(는) 비워 둘 수 없습니다", # Configuration "media-player-error": "미디어 플레이어 오류: \"{}\"", # Error line - "unable-import-gui-error": "GUI 라이브러리를 가져올 수 없습니다. PySide가 설치되어 있지 않은 경우 GUI가 작동하려면 설치해야 합니다.", + "unable-import-gui-error": "GUI 라이브러리를 가져올 수 없습니다. PySide가 설치되어 있지 않은 경우 GUI가 작동하려면 설치해야 합니다. If you want to run Syncplay in console mode then run it with the --no-gui command line switch. See https://syncplay.pl/guide/ for more details.", # TODO: Translate end of message and update second sentence to be a translation of "You need to have the correct version of PySide installed for the GUI to work." "unable-import-twisted-error": "Twisted를 가져올 수 없습니다. Twisted v16.4.0 이상을 설치하세요.", "arguments-missing-error": "일부 필요한 인수가 누락되었습니다. --help를 참조하세요.", diff --git a/syncplay/messages_pt_BR.py b/syncplay/messages_pt_BR.py index c7a2535..6ffd894 100644 --- a/syncplay/messages_pt_BR.py +++ b/syncplay/messages_pt_BR.py @@ -134,7 +134,7 @@ pt_BR = { "hostname-empty-error": "O endereço do servidor não pode estar vazio", "empty-error": "{} não pode estar vazio", # Configuration "media-player-error": "Erro do reprodutor de mídia: \"{}\"", # Error line - "unable-import-gui-error": "Não foi possível importar bibliotecas da GUI. Se você não possuir o PySide instalado, instale-o para que a GUI funcione.", + "unable-import-gui-error": "Não foi possível importar bibliotecas da GUI. Se você não possuir o PySide instalado, instale-o para que a GUI funcione. If you want to run Syncplay in console mode then run it with the --no-gui command line switch. See https://syncplay.pl/guide/ for more details.", # TODO: Translate end of message and update second sentence to be a translation of "You need to have the correct version of PySide installed for the GUI to work." "unable-import-twisted-error": "Não foi possível importar o Twisted. Por favor, instale o Twisted v16.4.0 ou superior.", "arguments-missing-error": "Alguns argumentos necessários estão faltando, por favor reveja --help", diff --git a/syncplay/messages_pt_PT.py b/syncplay/messages_pt_PT.py index a32d24c..51cb5d6 100644 --- a/syncplay/messages_pt_PT.py +++ b/syncplay/messages_pt_PT.py @@ -133,7 +133,7 @@ pt_PT = { "hostname-empty-error": "O endereço do servidor não pode ser vazio", "empty-error": "{} não pode ser vazio", # Configuration "media-player-error": "Erro do reprodutor de mídia: \"{}\"", # Error line - "unable-import-gui-error": "Não foi possível importar bibliotecas da GUI. Se você não possuir o PySide instalado, instale-o para que a GUI funcione.", + "unable-import-gui-error": "Não foi possível importar bibliotecas da GUI. Se você não possuir o PySide instalado, instale-o para que a GUI funcione. If you want to run Syncplay in console mode then run it with the --no-gui command line switch. See https://syncplay.pl/guide/ for more details.", # TODO: Translate end of message and update second sentence to be a translation of "You need to have the correct version of PySide installed for the GUI to work." "unable-import-twisted-error": "Não foi possível importar o Twisted. Por favor, instale o Twisted v16.4.0 ou superior.", "arguments-missing-error": "Alguns argumentos necessários estão faltando, por favor reveja --help", diff --git a/syncplay/messages_ru.py b/syncplay/messages_ru.py index ce30c21..4547c23 100755 --- a/syncplay/messages_ru.py +++ b/syncplay/messages_ru.py @@ -132,7 +132,7 @@ ru = { "hostname-empty-error": "Имя пользователя не может быть пустым.", "empty-error": "{} не может быть пустым.", # Configuration "media-player-error": "Ошибка проигрывателя: \"{}\"", # Error line - "unable-import-gui-error": "Невозможно импортировать библиотеки графического интерфейса. Необходимо установить PySide, иначе графический интерфейс не будет работать.", + "unable-import-gui-error": "Невозможно импортировать библиотеки графического интерфейса. Необходимо установить PySide, иначе графический интерфейс не будет работать. If you want to run Syncplay in console mode then run it with the --no-gui command line switch. See https://syncplay.pl/guide/ for more details.", # TODO: Translate end of message and update second sentence to be a translation of "You need to have the correct version of PySide installed for the GUI to work." "unable-import-twisted-error": "Невозможно импортировать Twisted. Установите Twisted 16.4.0 или более позднюю версию.", "arguments-missing-error": "Некоторые необходимые аргументы отсутствуют, обратитесь к --help", diff --git a/syncplay/messages_tr.py b/syncplay/messages_tr.py index cb4e759..709bcf5 100644 --- a/syncplay/messages_tr.py +++ b/syncplay/messages_tr.py @@ -133,7 +133,7 @@ tr = { "hostname-empty-error": "Ana bilgisayar adı boş olamaz", "empty-error": "{} boş olamaz", # Configuration "media-player-error": "Medaya oynatıcısı hatası: \"{}\"", # Error line - "unable-import-gui-error": "GUI kitaplıkları içe aktarılamadı. PySide kurulu değilse, GUI'nin çalışması için kurmanız gerekecektir.", + "unable-import-gui-error": "GUI kitaplıkları içe aktarılamadı. PySide kurulu değilse, GUI'nin çalışması için kurmanız gerekecektir. If you want to run Syncplay in console mode then run it with the --no-gui command line switch. See https://syncplay.pl/guide/ for more details.", # TODO: Translate end of message and update second sentence to be a translation of "You need to have the correct version of PySide installed for the GUI to work." "unable-import-twisted-error": "Twisted içe aktarılamadı. Lütfen Twisted v16.4.0 veya sonraki sürümünü yükleyin.", "arguments-missing-error": "Bazı gerekli argümanlar eksik, bakınız --help", diff --git a/syncplay/messages_zh_CN.py b/syncplay/messages_zh_CN.py index 9fbdff7..d9a5032 100644 --- a/syncplay/messages_zh_CN.py +++ b/syncplay/messages_zh_CN.py @@ -133,7 +133,7 @@ zh_CN = { "hostname-empty-error": "主机名不能是空的", "empty-error": "{}不能是空的", # Configuration "media-player-error": "媒体播放器错误:\"{}\"", # Error line - "unable-import-gui-error": "无法导入GUI库。如果你没有安装PySide,GUI则无法工作,请安装PySide。", + "unable-import-gui-error": "无法导入GUI库。如果你没有安装PySide,GUI则无法工作,请安装PySide。 If you want to run Syncplay in console mode then run it with the --no-gui command line switch. See https://syncplay.pl/guide/ for more details.", # TODO: Translate end of message and update second sentence to be a translation of "You need to have the correct version of PySide installed for the GUI to work." "unable-import-twisted-error": "无法导入Twisted。请安装Twisted v16.4.0或更高版本。", "arguments-missing-error": "缺少一些必要的参数,使用--help命令查看详细信息", diff --git a/syncplay/ui/ConfigurationGetter.py b/syncplay/ui/ConfigurationGetter.py index 496c682..214afde 100755 --- a/syncplay/ui/ConfigurationGetter.py +++ b/syncplay/ui/ConfigurationGetter.py @@ -520,7 +520,7 @@ class ConfigurationGetter(object): from syncplay.vendor.Qt.QtCore import QCoreApplication from syncplay.vendor import qt5reactor if not (IsPySide6 or IsPySide2 or IsPySide): - raise ImportError + raise ImportError("Failed to identify compatible version of PySide.") if QCoreApplication.instance() is None: self.app = QtWidgets.QApplication(sys.argv) self.app.setDesktopFileName("syncplay") @@ -537,13 +537,14 @@ class ConfigurationGetter(object): if isMacOS(): import appnope appnope.nope() - except ImportError: + except ImportError as e: try: from twisted.trial import unittest - except Exception as e: - print(e) + except Exception as ee: + print(ee) print(getMessage("unable-import-twisted-error")) sys.exit() + print(e) print(getMessage("unable-import-gui-error")) self._config['noGui'] = True if self._config['file'] and self._config['file'][:2] == "--": From af08ff9f807c0211f014c6c66d84106223bbcdee Mon Sep 17 00:00:00 2001 From: Et0h Date: Fri, 1 Mar 2024 15:23:41 +0000 Subject: [PATCH 07/20] Avoid error when closing Syncplay before loadDelayedPath is complete --- syncplay/client.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/syncplay/client.py b/syncplay/client.py index b7cb245..3dfcb35 100755 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -1785,6 +1785,9 @@ class SyncplayPlaylist(): def loadDelayedPath(self, changeToIndex): # Implementing the behaviour set out at https://github.com/Syncplay/syncplay/issues/315 + if not self._client: + return + if self._client.playerIsNotReady(): self._client.addPlayerReadyCallback(lambda x: self.loadDelayedPath(changeToIndex)) return From 9b53026db7061aa1a1022d60d067d424522e3da1 Mon Sep 17 00:00:00 2001 From: Et0h Date: Fri, 1 Mar 2024 15:30:33 +0000 Subject: [PATCH 08/20] Remove mpv.net v7 workaround due to upstream fix (see #529) - reverts 793804e --- syncplay/players/mpvnet.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/syncplay/players/mpvnet.py b/syncplay/players/mpvnet.py index 42d5f11..1ee7796 100644 --- a/syncplay/players/mpvnet.py +++ b/syncplay/players/mpvnet.py @@ -50,9 +50,4 @@ class MpvnetPlayer(MpvPlayer): def getIconPath(path): return constants.MPVNET_ICONPATH - def sendMpvOptions(self): - for key in self._listener.mpv_arguments: - if key != "script" and key != "input-ipc-server": - self._setProperty(key, self._listener.mpv_arguments[key]) - super().sendMpvOptions() From bc683a59f5be10e6ce534208dec091566ecfd2d9 Mon Sep 17 00:00:00 2001 From: Etoh Date: Fri, 5 Apr 2024 20:13:16 +0100 Subject: [PATCH 09/20] Set recent threshold to 1.7.2 --- syncplay/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syncplay/constants.py b/syncplay/constants.py index d13986c..6cd8a14 100755 --- a/syncplay/constants.py +++ b/syncplay/constants.py @@ -29,7 +29,7 @@ MPLAYER_OSD_LEVEL = 1 UI_TIME_FORMAT = "[%X] " CONFIG_NAMES = [".syncplay", "syncplay.ini"] # Syncplay searches first to last DEFAULT_CONFIG_NAME = "syncplay.ini" -RECENT_CLIENT_THRESHOLD = "1.7.1" # This and higher considered 'recent' clients (no warnings) +RECENT_CLIENT_THRESHOLD = "1.7.2" # This and higher considered 'recent' clients (no warnings) MUSIC_FORMATS = [".mp3", ".m4a", ".m4p", ".wav", ".aiff", ".r", ".ogg", ".flac"] # ALL LOWER CASE! WARN_OLD_CLIENTS = True # Use MOTD to inform old clients to upgrade LIST_RELATIVE_CONFIGS = True # Print list of relative configs loaded From 0a9700058e4b65676fb53567dee4ff781eddf955 Mon Sep 17 00:00:00 2001 From: Etoh Date: Fri, 5 Apr 2024 20:14:48 +0100 Subject: [PATCH 10/20] Mark as 1.7.2 release (build 111) --- syncplay/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syncplay/__init__.py b/syncplay/__init__.py index 34b434e..9b29024 100755 --- a/syncplay/__init__.py +++ b/syncplay/__init__.py @@ -1,5 +1,5 @@ version = '1.7.2' -revision = ' development' +revision = '' milestone = 'Yoitsu' -release_number = '110' +release_number = '111' projectURL = 'https://syncplay.pl/' From 887131ef9fe82072869148e2ac855e8e64925e34 Mon Sep 17 00:00:00 2001 From: peelz Date: Mon, 29 Apr 2024 13:55:10 -0400 Subject: [PATCH 11/20] Fix MPV socket getting created in CWD (#675) (fixes #674) * Disable creation of secondary MPV socket by default * Fix secondary and primary MPV sockets getting conflated * Store MPV socket in $XDG_RUNTIME_DIR --- syncplay/players/mpv.py | 31 +++++++++++++++++++++++-------- syncplay/utils.py | 23 ++++++++++++++++++++++- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/syncplay/players/mpv.py b/syncplay/players/mpv.py index 10c0aca..cf9e745 100755 --- a/syncplay/players/mpv.py +++ b/syncplay/players/mpv.py @@ -1,5 +1,6 @@ # coding:utf8 import os +import random import re import sys import time @@ -10,7 +11,7 @@ import ast from syncplay import constants from syncplay.messages import getMessage from syncplay.players.basePlayer import BasePlayer -from syncplay.utils import isURL, findResourcePath +from syncplay.utils import getRuntimeDir, isURL, findResourcePath from syncplay.utils import isMacOS, isWindows, isASCII from syncplay.vendor.python_mpv_jsonipc.python_mpv_jsonipc import MPV @@ -375,7 +376,7 @@ class MpvPlayer(BasePlayer): self._listener.sendLine(['loadfile', filePath], notReadyAfterThis=True) def setFeatures(self, featureList): - self.sendMpvOptions() + self._sendMpvOptions() def setPosition(self, value): if value < constants.DO_NOT_RESET_POSITION_THRESHOLD and self._recentlyReset(): @@ -408,7 +409,7 @@ class MpvPlayer(BasePlayer): self._storePosition(0) # TO TRY: self._listener.setReadyToSend(False) - def sendMpvOptions(self): + def _sendMpvOptions(self): options = [] for option in constants.MPV_SYNCPLAYINTF_OPTIONS_TO_SEND: options.append("{}={}".format(option, self._client._config[option])) @@ -420,8 +421,9 @@ class MpvPlayer(BasePlayer): options_string = ", ".join(options) self._listener.sendLine(["script-message-to", "syncplayintf", "set_syncplayintf_options", options_string]) self._setOSDPosition() - publicIPCSocket = self._listener.mpv_arguments.get("input-ipc-server") if self._listener.mpv_arguments.get("input-ipc-server") else "mpvSyncplaySocket" - self._setProperty("input-ipc-server", publicIPCSocket) + socketPath = self._listener.mpv_arguments.get("input-ipc-server") + if socketPath is not None: + self._setProperty("input-ipc-server", socketPath) def _handleUnknownLine(self, line): self.mpvErrorCheck(line) @@ -449,7 +451,7 @@ class MpvPlayer(BasePlayer): #self._client.ui.showDebugMessage("{} = {} / {}".format(update_string, paused_update, position_update)) if "" in line: - self.sendMpvOptions() + self._sendMpvOptions() if line == "" or "Playing:" in line: self._client.ui.showDebugMessage("Not ready to send due to ") @@ -620,8 +622,15 @@ class MpvPlayer(BasePlayer): env['PATH'] = python_executable + ':' + env['PATH'] env['PYTHONPATH'] = pythonPath try: - socket = self.mpv_arguments.get('input-ipc-server') - self.mpvpipe = self.playerIPCHandler(mpv_location=self.playerPath, ipc_socket=socket, loglevel="info", log_handler=self.__playerController.mpv_log_handler, quit_callback=self.stop_client, env=env, **self.mpv_arguments) + self.mpvpipe = self.playerIPCHandler( + loglevel="info", + ipc_socket=self._get_ipc_socket(), + mpv_location=self.playerPath, + log_handler=self.__playerController.mpv_log_handler, + quit_callback=self.stop_client, + env=env, + **self.mpv_arguments + ) except Exception as e: self.quitReason = getMessage("media-player-error").format(str(e)) + " " + getMessage("mpv-failed-advice") self.__playerController.reactor.callFromThread(self.__playerController._client.ui.showErrorMessage, self.quitReason, True) @@ -630,6 +639,12 @@ class MpvPlayer(BasePlayer): #self.mpvpipe.show_text("HELLO WORLD!", 1000) threading.Thread.__init__(self, name="MPV Listener") + def _get_ipc_socket(self): + if isWindows(): + # On Windows, mpv expects a named pipe identifier (not a path) + return "syncplay-mpv-{0}".format(random.randint(0, 2**48)) + return getRuntimeDir().joinpath("mpv-socket").as_posix() + def __getCwd(self, filePath, env): if not filePath: return None diff --git a/syncplay/utils.py b/syncplay/utils.py index 6adf663..556d461 100755 --- a/syncplay/utils.py +++ b/syncplay/utils.py @@ -1,5 +1,5 @@ - import ast +import atexit import datetime import hashlib import itertools @@ -10,11 +10,13 @@ import re import string import subprocess import sys +import tempfile import time import traceback import urllib.error import urllib.parse import urllib.request +from pathlib import Path from syncplay import constants from syncplay.messages import getMessage @@ -37,9 +39,28 @@ def isMacOS(): def isBSD(): return constants.OS_BSD in sys.platform or sys.platform.startswith(constants.OS_DRAGONFLY) + def isWindowsConsole(): return os.path.basename(sys.executable) == "SyncplayConsole.exe" + +def getRuntimeDir(): + cachedPath = getattr(getRuntimeDir, "cachedPath", None) + if cachedPath is not None: + return cachedPath + + baseDir = None + if not isWindows() and not isMacOS(): + baseDir = os.getenv("XDG_RUNTIME_DIR", None) + + tmp = tempfile.TemporaryDirectory(prefix="syncplay-", dir=baseDir) + atexit.register(tmp.cleanup) + + o = Path(tmp.name) + setattr(getRuntimeDir, "cachedPath", o) + return o + + def retry(ExceptionToCheck, tries=4, delay=3, backoff=2, logger=None): """Retry calling the decorated function using an exponential backoff. From 64ea98ac1c8c694d1cb6d3dd58c047116f183116 Mon Sep 17 00:00:00 2001 From: peelz Date: Mon, 29 Apr 2024 14:04:10 -0400 Subject: [PATCH 12/20] Fix invalid string escapes (#677) --- syncplay/constants.py | 10 +++++----- syncplay/utils.py | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/syncplay/constants.py b/syncplay/constants.py index 6cd8a14..a6f198f 100755 --- a/syncplay/constants.py +++ b/syncplay/constants.py @@ -112,9 +112,9 @@ FOLDER_SEARCH_DOUBLE_CHECK_INTERVAL = 30.0 # Secs - Frequency of updating cache # Usually there's no need to adjust these DOUBLE_CHECK_REWIND = False LAST_PAUSED_DIFF_THRESHOLD = 2 -FILENAME_STRIP_REGEX = "[-~_\.\[\](): ]" -CONTROL_PASSWORD_STRIP_REGEX = "[^a-zA-Z0-9\-]" -ROOM_NAME_STRIP_REGEX = "^(\+)(?P.*)(:)(\w{12})$" +FILENAME_STRIP_REGEX = r"[-~_\.\[\](): ]" +CONTROL_PASSWORD_STRIP_REGEX = r"[^a-zA-Z0-9\-]" +ROOM_NAME_STRIP_REGEX = r"^(\+)(?P.*)(:)(\w{12})$" ARGUMENT_SPLIT_REGEX = r'(?:[^\s"]+|"[^"]*")+' COMMANDS_UNDO = ["u", "undo", "revert"] COMMANDS_CHAT = ["ch", "chat"] @@ -163,7 +163,7 @@ MPC_PATHS = [ ] MPC_EXECUTABLES = ["mpc-hc.exe", "mpc-hc64.exe", "mpc-hcportable.exe", "mpc-hc_nvo.exe", "mpc-hc64_nvo.exe", "shoukaku.exe"] -MPC64_EXECUTABLES = ["mpc-hc64.exe", "mpc-hc64_nvo.exe", "x64\mpc-hc\shoukaku.exe"] +MPC64_EXECUTABLES = ["mpc-hc64.exe", "mpc-hc64_nvo.exe", r"x64\mpc-hc\shoukaku.exe"] MPC_BE_PATHS = [ r"c:\program files\mpc-be x64\mpc-be64.exe", @@ -302,7 +302,7 @@ VLC_SLAVE_EXTRA_ARGS = getValueForOS({ OS_MACOS: ['--verbose=2', '--no-file-logging']}) MPV_SUPERSEDE_IF_DUPLICATE_COMMANDS = ["set_property time-pos ", "loadfile "] MPV_REMOVE_BOTH_IF_DUPLICATE_COMMANDS = ["cycle pause"] -MPLAYER_ANSWER_REGEX = "^ANS_([a-zA-Z_-]+)=(.+)$|^(Exiting)\.\.\. \((.+)\)$" +MPLAYER_ANSWER_REGEX = r"^ANS_([a-zA-Z_-]+)=(.+)$|^(Exiting)\.\.\. \((.+)\)$" VLC_ANSWER_REGEX = r"(?:^(?P[a-zA-Z_-]+)(?:\: )?(?P.*))" UI_COMMAND_REGEX = r"^(?P[^\ ]+)(?:\ (?P.+))?" UI_OFFSET_REGEX = r"^(?:o|offset)\ ?(?P[/+-])?(?P