From 9a10730e5451ebf6306790e4c2f704a3613157e4 Mon Sep 17 00:00:00 2001 From: et0h Date: Sat, 19 Sep 2020 14:50:10 +0100 Subject: [PATCH 1/4] Add warning about erroneous VLC seeks (#354) --- syncplay/messages_de.py | 3 +- syncplay/messages_en.py | 1 + syncplay/messages_es.py | 1 + syncplay/messages_it.py | 1 + syncplay/messages_pt_BR.py | 1 + syncplay/messages_pt_PT.py | 1 + syncplay/messages_ru.py | 1 + syncplay/players/vlc.py | 219 +++++++++++++++++++------------------ syncplay/ui/gui.py | 1 + 9 files changed, 123 insertions(+), 106 deletions(-) diff --git a/syncplay/messages_de.py b/syncplay/messages_de.py index 802e379..57b50c2 100755 --- a/syncplay/messages_de.py +++ b/syncplay/messages_de.py @@ -135,8 +135,9 @@ de = { "version-mismatch-error": "Verschiedene Versionen auf Client und Server\n", "vlc-failed-connection": "Kann nicht zu VLC verbinden. Wenn du syncplay.lua nicht installiert hast, findest du auf https://syncplay.pl/LUA/ [Englisch] eine Anleitung.", "vlc-failed-noscript": "Laut VLC ist das syncplay.lua Interface-Skript nicht installiert. Auf https://syncplay.pl/LUA/ [Englisch] findest du eine Anleitung.", - "vlc-failed-versioncheck": "Diese VLC-Version wird von Syncplay nicht unterstützt. Bitte nutze VLC 2.0", + "vlc-initial-warning": 'VLC does not always provide accurate position information to Syncplay, especially for .mp4 and .avi files. If you experience problems with erroneous seeking then please try an alternative media player such as mpv.', # TODO: Translate + "feature-sharedPlaylists": "Geteilte Playlists", # used for not-supported-by-server-error "feature-chat": "Chat", # used for not-supported-by-server-error "feature-readiness": "Bereitschaftsstatus", # used for not-supported-by-server-error diff --git a/syncplay/messages_en.py b/syncplay/messages_en.py index 243c1ad..9db8c9c 100755 --- a/syncplay/messages_en.py +++ b/syncplay/messages_en.py @@ -136,6 +136,7 @@ en = { "vlc-failed-connection": "Failed to connect to VLC. If you have not installed syncplay.lua and are using the latest verion of VLC then please refer to https://syncplay.pl/LUA/ for instructions.", "vlc-failed-noscript": "VLC has reported that the syncplay.lua interface script has not been installed. Please refer to https://syncplay.pl/LUA/ for instructions.", "vlc-failed-versioncheck": "This version of VLC is not supported by Syncplay.", + "vlc-initial-warning": 'VLC does not always provide accurate position information to Syncplay, especially for .mp4 and .avi files. If you experience problems with erroneous seeking then please try an alternative media player such as mpv.', "feature-sharedPlaylists": "shared playlists", # used for not-supported-by-server-error "feature-chat": "chat", # used for not-supported-by-server-error diff --git a/syncplay/messages_es.py b/syncplay/messages_es.py index b705f98..9c4e63c 100644 --- a/syncplay/messages_es.py +++ b/syncplay/messages_es.py @@ -136,6 +136,7 @@ es = { "vlc-failed-connection": "Falló la conexión con VLC. Si no has instalado syncplay.lua y estás usando la última versión de VLC, por favor revisa https://syncplay.pl/LUA/ para obtener instrucciones.", "vlc-failed-noscript": "VLC ha reportado que la interfaz syncplay.lua no se ha instalado. Por favor revisa https://syncplay.pl/LUA/ para obtener instrucciones.", "vlc-failed-versioncheck": "Esta versión de VLC no está soportada por Syncplay.", + "vlc-initial-warning": 'VLC does not always provide accurate position information to Syncplay, especially for .mp4 and .avi files. If you experience problems with erroneous seeking then please try an alternative media player such as mpv.', # TODO: Translatef "feature-sharedPlaylists": "listas de reproducción compartidas", # used for not-supported-by-server-error "feature-chat": "chat", # used for not-supported-by-server-error diff --git a/syncplay/messages_it.py b/syncplay/messages_it.py index 028bb11..b6fafc7 100755 --- a/syncplay/messages_it.py +++ b/syncplay/messages_it.py @@ -136,6 +136,7 @@ it = { "vlc-failed-connection": "Impossibile collegarsi a VLC. Se non hai installato syncplay.lua e stai usando l'ultima versione di VLC, fai riferimento a https://syncplay.pl/LUA/ per istruzioni.", "vlc-failed-noscript": "VLC ha segnalato che lo script di interfaccia syncplay.lua non è stato installato. Per favore, fai riferimento a https://syncplay.pl/LUA/ per istruzioni.", "vlc-failed-versioncheck": "Questa versione di VLC non è supportata da Syncplay.", + "vlc-initial-warning": 'VLC does not always provide accurate position information to Syncplay, especially for .mp4 and .avi files. If you experience problems with erroneous seeking then please try an alternative media player such as mpv.', # TODO: Translate "feature-sharedPlaylists": "playlist condivise", # used for not-supported-by-server-error "feature-chat": "chat", # used for not-supported-by-server-error diff --git a/syncplay/messages_pt_BR.py b/syncplay/messages_pt_BR.py index 7f85976..2f140f8 100644 --- a/syncplay/messages_pt_BR.py +++ b/syncplay/messages_pt_BR.py @@ -136,6 +136,7 @@ pt_BR = { "vlc-failed-connection": "Falha ao conectar ao VLC. Se você não instalou o syncplay.lua e está usando a versão mais recente do VLC, por favor veja https://syncplay.pl/LUA/ para mais instruções.", "vlc-failed-noscript": "O VLC reportou que a interface de script do syncplay.lua não foi instalada. Por favor, veja https://syncplay.pl/LUA/ para mais instruções.", "vlc-failed-versioncheck": "Esta versão do VLC não é suportada pelo Syncplay.", + "vlc-initial-warning": 'VLC does not always provide accurate position information to Syncplay, especially for .mp4 and .avi files. If you experience problems with erroneous seeking then please try an alternative media player such as mpv.', # TODO: Translate "feature-sharedPlaylists": "playlists compartilhadas", # used for not-supported-by-server-error "feature-chat": "chat", # used for not-supported-by-server-error diff --git a/syncplay/messages_pt_PT.py b/syncplay/messages_pt_PT.py index f0fb92b..9e1cc52 100644 --- a/syncplay/messages_pt_PT.py +++ b/syncplay/messages_pt_PT.py @@ -136,6 +136,7 @@ pt_PT = { "vlc-failed-connection": "Falha ao conectar ao VLC. Se você não instalou o syncplay.lua e está usando a versão mais recente do VLC, por favor veja https://syncplay.pl/LUA/ para mais instruções.", "vlc-failed-noscript": "O VLC reportou que a interface de script do syncplay.lua não foi instalada. Por favor, veja https://syncplay.pl/LUA/ para mais instruções.", "vlc-failed-versioncheck": "Esta versão do VLC não é suportada pelo Syncplay.", + "vlc-initial-warning": 'VLC does not always provide accurate position information to Syncplay, especially for .mp4 and .avi files. If you experience problems with erroneous seeking then please try an alternative media player such as mpv.', # TODO: Translate "feature-sharedPlaylists": "playlists compartilhadas", # used for not-supported-by-server-error "feature-chat": "chat", # used for not-supported-by-server-error diff --git a/syncplay/messages_ru.py b/syncplay/messages_ru.py index 242abcc..18529f9 100755 --- a/syncplay/messages_ru.py +++ b/syncplay/messages_ru.py @@ -136,6 +136,7 @@ ru = { "vlc-failed-connection": "Ошибка подключения к VLC. Если у Вас не установлен syncplay.lua, то обратитесь к https://syncplay.pl/LUA/ за инструкциями.", "vlc-failed-noscript": "VLC сообщает, что скрипт интерфейса syncplay.lua не установлен. Пожалуйста, обратитесь к https://syncplay.pl/LUA/ за инструкциями.", "vlc-failed-versioncheck": "Данная версия VLC не поддерживается Syncplay. Пожалуйста, используйте VLC версии 2 или выше.", + "vlc-initial-warning": 'VLC does not always provide accurate position information to Syncplay, especially for .mp4 and .avi files. If you experience problems with erroneous seeking then please try an alternative media player such as mpv.', # TODO: Translate "feature-sharedPlaylists": "shared playlists", # used for not-supported-by-server-error # TODO: Translate "feature-chat": "chat", # used for not-supported-by-server-error # TODO: Translate diff --git a/syncplay/players/vlc.py b/syncplay/players/vlc.py index 926c237..e5c0a76 100755 --- a/syncplay/players/vlc.py +++ b/syncplay/players/vlc.py @@ -1,6 +1,4 @@ -import asynchat -import asyncore import os import random import re @@ -13,11 +11,82 @@ import urllib.error import urllib.parse import urllib.request +from twisted.internet.protocol import ClientFactory +from twisted.protocols.basic import LineReceiver + from syncplay import constants, utils from syncplay.messages import getMessage from syncplay.players.basePlayer import BasePlayer from syncplay.utils import isBSD, isLinux, isWindows, isMacOS +class VLCProtocol(LineReceiver): + def __init__(self): + self.delimiter = b'\n' + + def lineReceived(self, data): + self.factory.vlcHasResponded = True + self.factory._playerController.lineReceived(data) + + def sendLine(self, line): + if self.factory.connected: + if not self.factory.requestedVLCVersion: + self.factory.requestedVLCVersion = True + self.sendLine("get-vlc-version") + # try: + lineToSend = line.encode('utf-8') + self.delimiter + self.transport.write(lineToSend) + if self.factory._playerController._client and self.factory._playerController._client.ui: + self.factory._playerController._client.ui.showDebugMessage("player >> {}".format(line)) + # except: + # pass + + def connectionMade(self): + self.factory.connected = True + self.factory._playerController._vlcready.set() + self.factory.timeVLCLaunched = None + self.factory._playerController.initWhenConnected() + + def connectionLost(self, reason): + self.factory.connected = False + + +class VLCClientFactory(ClientFactory): + def __init__(self, playerController, vlcHasResponded, vlcLaunchedTime, vlcProcess): + self._playerController = playerController + self._process = vlcProcess + self.requestedVLCVersion = False + self.vlcHasResponded = vlcHasResponded + self.timeVLCLaunched = vlcLaunchedTime + self.connected = False + + def buildProtocol(self, addr): + self.protocol = VLCProtocol() + self.protocol.factory = self + return self.protocol + + def clientConnectionLost(self, connector, reason): + if self.timeVLCLaunched and time.time() - self.timeVLCLaunched < constants.VLC_OPEN_MAX_WAIT_TIME: + try: + self._playerController._client.ui.showDebugMessage("Failed to connect to VLC, but reconnecting as within max wait time") + except: + pass + self._playerController._vlcready.clear() + connector.connect() + elif self.vlcHasResponded: + self._playerController.drop() + else: + self.vlcHasResponded = True + self._playerController.drop(getMessage("vlc-failed-connection").format(constants.VLC_MIN_VERSION)) + + def closeVLC(self): + self._playerController._vlcclosed.set() + if not self.connected and not self.timeVLCLaunched: + # For circumstances where Syncplay is not connected to VLC and is not reconnecting + #try: + self._process.terminate() + #except: # When VLC is already closed + # pass + class VlcPlayer(BasePlayer): speedSupported = True @@ -63,21 +132,19 @@ class VlcPlayer(BasePlayer): self._vlcclosed = threading.Event() self._listener = None try: - self._listener = self.__Listener(self, playerPath, filePath, args, self._vlcready, self._vlcclosed) + self._listener = self.__Listener(self, playerPath, filePath, args, self.reactor) except ValueError: self._client.ui.showErrorMessage(getMessage("vlc-failed-connection"), True) self.reactor.callFromThread(self._client.stop, True,) return - try: - self._listener.setDaemon(True) - self._listener.start() - if not self._vlcready.wait(constants.VLC_OPEN_MAX_WAIT_TIME): - self._vlcready.set() - self._client.ui.showErrorMessage(getMessage("vlc-failed-connection"), True) - self.reactor.callFromThread(self._client.stop, True,) - self.reactor.callFromThread(self._client.initPlayer, self,) - except: - pass + + def initWhenConnected(self): + self._client.ui.showErrorMessage(getMessage("vlc-initial-warning")) + if not self._vlcready.wait(constants.VLC_OPEN_MAX_WAIT_TIME): + self._vlcready.set() + self._client.ui.showErrorMessage(getMessage("vlc-failed-connection"), True) + self.reactor.callFromThread(self._client.stop, True,) + self.reactor.callFromThread(self._client.initPlayer, self,) def _fileUpdateClearEvents(self): self._durationAsk.clear() @@ -314,7 +381,7 @@ class VlcPlayer(BasePlayer): def drop(self, dropErrorMessage=None): if self._listener: self._vlcclosed.clear() - self._listener.sendLine('close-vlc') + self._listener._factory.closeVLC() self._vlcclosed.wait() self._durationAsk.set() self._filenameAsk.set() @@ -326,13 +393,15 @@ class VlcPlayer(BasePlayer): self.reactor.callFromThread(self._client.ui.showErrorMessage, dropErrorMessage, True) self.reactor.callFromThread(self._client.stop, False,) - class __Listener(threading.Thread, asynchat.async_chat): - def __init__(self, playerController, playerPath, filePath, args, vlcReady, vlcClosed): + + class __Listener(): + def __init__(self, playerController, playerPath, filePath, args, reactor): self.__playerController = playerController - self.requestedVLCVersion = False + self.reactor = reactor self.vlcHasResponded = False self.oldIntfVersion = None self.timeVLCLaunched = None + call = [playerPath] if filePath: if utils.isASCII(filePath): @@ -341,27 +410,27 @@ class VlcPlayer(BasePlayer): call.append(self.__playerController.getMRL(filePath)) if isLinux(): if 'snap' in playerPath: - playerController.vlcIntfPath = '/snap/vlc/current/usr/lib/vlc/lua/intf/' - playerController.vlcIntfUserPath = os.path.join(os.getenv('HOME', '.'), "snap/vlc/current/.local/share/vlc/lua/intf/") + self.__playerController.vlcIntfPath = '/snap/vlc/current/usr/lib/vlc/lua/intf/' + self.__playerController.vlcIntfUserPath = os.path.join(os.getenv('HOME', '.'), "snap/vlc/current/.local/share/vlc/lua/intf/") else: - playerController.vlcIntfPath = "/usr/lib/vlc/lua/intf/" - playerController.vlcIntfUserPath = os.path.join(os.getenv('HOME', '.'), ".local/share/vlc/lua/intf/") + self.__playerController.vlcIntfPath = "/usr/lib/vlc/lua/intf/" + self.__playerController.vlcIntfUserPath = os.path.join(os.getenv('HOME', '.'), ".local/share/vlc/lua/intf/") elif isMacOS(): - playerController.vlcIntfPath = "/Applications/VLC.app/Contents/MacOS/share/lua/intf/" - playerController.vlcIntfUserPath = os.path.join( + self.__playerController.vlcIntfPath = "/Applications/VLC.app/Contents/MacOS/share/lua/intf/" + self.__playerController.vlcIntfUserPath = os.path.join( os.getenv('HOME', '.'), "Library/Application Support/org.videolan.vlc/lua/intf/") elif isBSD(): # *BSD ports/pkgs install to /usr/local by default. # This should also work for all the other BSDs, such as OpenBSD or DragonFly. - playerController.vlcIntfPath = "/usr/local/lib/vlc/lua/intf/" - playerController.vlcIntfUserPath = os.path.join(os.getenv('HOME', '.'), ".local/share/vlc/lua/intf/") + self.__playerController.vlcIntfPath = "/usr/local/lib/vlc/lua/intf/" + self.__playerController.vlcIntfUserPath = os.path.join(os.getenv('HOME', '.'), ".local/share/vlc/lua/intf/") elif "vlcportable.exe" in playerPath.lower(): - playerController.vlcIntfPath = os.path.dirname(playerPath).replace("\\", "/") + "/App/vlc/lua/intf/" - playerController.vlcIntfUserPath = playerController.vlcIntfPath + self.__playerController.vlcIntfPath = os.path.dirname(playerPath).replace("\\", "/") + "/App/vlc/lua/intf/" + self.__playerController.vlcIntfUserPath = playerController.vlcIntfPath else: - playerController.vlcIntfPath = os.path.dirname(playerPath).replace("\\", "/") + "/lua/intf/" - playerController.vlcIntfUserPath = os.path.join(os.getenv('APPDATA', '.'), "VLC\\lua\\intf\\") - playerController.vlcModulePath = playerController.vlcIntfPath + "modules/?.luac" + self.__playerController.vlcIntfPath = os.path.dirname(playerPath).replace("\\", "/") + "/lua/intf/" + self.__playerController.vlcIntfUserPath = os.path.join(os.getenv('APPDATA', '.'), "VLC\\lua\\intf\\") + self.__playerController.vlcModulePath = self.__playerController.vlcIntfPath + "modules/?.luac" def _createIntfFolder(vlcSyncplayInterfaceDir): self.__playerController._client.ui.showDebugMessage("Checking if syncplay.lua intf directory exists") from pathlib import Path @@ -389,11 +458,11 @@ class VlcPlayer(BasePlayer): return True self.__playerController._client.ui.showDebugMessage("Up-to-dateness checks failed, so copy the file.") return True - if _intfNeedsUpdating(os.path.join(playerController.vlcIntfUserPath, "syncplay.lua")): + if _intfNeedsUpdating(os.path.join(self.__playerController.vlcIntfUserPath, "syncplay.lua")): try: - _createIntfFolder(playerController.vlcIntfUserPath) + _createIntfFolder(self.__playerController.vlcIntfUserPath) copyForm = utils.findResourcePath("syncplay.lua") - copyTo = os.path.join(playerController.vlcIntfUserPath, "syncplay.lua") + copyTo = os.path.join(self.__playerController.vlcIntfUserPath, "syncplay.lua") self.__playerController._client.ui.showDebugMessage("Copying VLC Lua Interface from '{}' to '{}'".format(copyForm, copyTo)) import shutil if os.path.exists(copyTo): @@ -401,22 +470,20 @@ class VlcPlayer(BasePlayer): shutil.copyfile(copyForm, copyTo) os.chmod(copyTo, 0o755) except Exception as e: - playerController._client.ui.showErrorMessage(e) + self.__playerController._client.ui.showErrorMessage(e) return if isLinux(): - playerController.vlcDataPath = "/usr/lib/syncplay/resources" + self.__playerController.vlcDataPath = "/usr/lib/syncplay/resources" else: - playerController.vlcDataPath = utils.findWorkingDir() + "\\resources" - playerController.SLAVE_ARGS.append( + self.__playerController.vlcDataPath = utils.findWorkingDir() + "\\resources" + self.__playerController.SLAVE_ARGS.append( '--lua-config=syncplay={{modulepath=\"{}\",port=\"{}\"}}'.format( - playerController.vlcModulePath, str(playerController.vlcport))) + self.__playerController.vlcModulePath, str(self.__playerController.vlcport))) - call.extend(playerController.SLAVE_ARGS) + call.extend(self.__playerController.SLAVE_ARGS) if args: call.extend(args) - self._vlcready = vlcReady - self._vlcclosed = vlcClosed self._vlcVersion = None if isWindows() and getattr(sys, 'frozen', '') and getattr(sys, '_MEIPASS', '') is not None: # Needed for pyinstaller --onefile bundle @@ -437,11 +504,11 @@ class VlcPlayer(BasePlayer): if "Hosting Syncplay" in line: break elif "Couldn't find lua interface" in line: - playerController._client.ui.showErrorMessage( + self.__playerController._client.ui.showErrorMessage( getMessage("vlc-failed-noscript").format(line), True) break elif "lua interface error" in line: - playerController._client.ui.showErrorMessage( + self.__playerController._client.ui.showErrorMessage( getMessage("media-player-error").format(line), True) break if not isMacOS(): @@ -450,48 +517,13 @@ class VlcPlayer(BasePlayer): vlcoutputthread = threading.Thread(target=self.handle_vlcoutput, args=()) vlcoutputthread.setDaemon(True) vlcoutputthread.start() - threading.Thread.__init__(self, name="VLC Listener") - asynchat.async_chat.__init__(self) - self.set_terminator(b'\n') - self._ibuffer = [] - self.create_socket(socket.AF_INET, socket.SOCK_STREAM) - self._sendingData = threading.Lock() + self.__playerController._vlcready.clear() + self._factory = VLCClientFactory(self.__playerController, self.vlcHasResponded, self.timeVLCLaunched, self.__process) + self.reactor.connectTCP('localhost', self.__playerController.vlcport, self._factory) def _shouldListenForSTDOUT(self): return not isWindows() - def initiate_send(self): - with self._sendingData: - asynchat.async_chat.initiate_send(self) - - def run(self): - self._vlcready.clear() - self.connect(('localhost', self.__playerController.vlcport)) - asyncore.loop() - - def handle_connect(self): - asynchat.async_chat.handle_connect(self) - self._vlcready.set() - self.timeVLCLaunched = None - - def collect_incoming_data(self, data): - self._ibuffer.append(data) - - def handle_close(self): - if self.timeVLCLaunched and time.time() - self.timeVLCLaunched < constants.VLC_OPEN_MAX_WAIT_TIME: - try: - self.__playerController._client.ui.showDebugMessage("Failed to connect to VLC, but reconnecting as within max wait time") - except: - pass - self.run() - elif self.vlcHasResponded: - asynchat.async_chat.handle_close(self) - self.__playerController.drop() - else: - self.vlcHasResponded = True - asynchat.async_chat.handle_close(self) - self.__playerController.drop(getMessage("vlc-failed-connection").format(constants.VLC_MIN_VERSION)) - def handle_vlcoutput(self): out = self.__process.stderr for line in iter(out.readline, ''): @@ -501,28 +533,5 @@ class VlcPlayer(BasePlayer): break out.close() - def found_terminator(self): - self.vlcHasResponded = True - self.__playerController.lineReceived(b"".join(self._ibuffer)) - self._ibuffer = [] - def sendLine(self, line): - if self.connected: - if not self.requestedVLCVersion: - self.requestedVLCVersion = True - self.sendLine("get-vlc-version") - # try: - lineToSend = line + "\n" - self.push(lineToSend.encode('utf-8')) - if self.__playerController._client and self.__playerController._client.ui: - self.__playerController._client.ui.showDebugMessage("player >> {}".format(line)) - # except: - # pass - if line == "close-vlc": - self._vlcclosed.set() - if not self.connected and not self.timeVLCLaunched: - # For circumstances where Syncplay is not connected to VLC and is not reconnecting - try: - self.__process.terminate() - except: # When VLC is already closed - pass + self.reactor.callFromThread(self._factory.protocol.sendLine, line) \ No newline at end of file diff --git a/syncplay/ui/gui.py b/syncplay/ui/gui.py index a5c324a..99f0ccd 100755 --- a/syncplay/ui/gui.py +++ b/syncplay/ui/gui.py @@ -903,6 +903,7 @@ class MainWindow(QtWidgets.QMainWindow): QtWidgets.QMessageBox.critical(self, "Syncplay", message) message = message.replace("&", "&").replace('"', """).replace("<", "<").replace(">", ">") message = message.replace("<a href="https://syncplay.pl/trouble">", '').replace("</a>", "") + message = message.replace("<a href="https://mpv.io/">", '').replace("</a>", "") message = message.replace("\n", "
") if isDarkMode: message = "".format(constants.STYLE_DARK_ERRORNOTIFICATION) + message + "" From 09c8b596ee3a9fdc86f9c3f972dbddc62357e77a Mon Sep 17 00:00:00 2001 From: et0h Date: Sat, 19 Sep 2020 15:29:21 +0100 Subject: [PATCH 2/4] Add error that VLC 4 does not support Syncplay --- syncplay/constants.py | 2 +- syncplay/messages_de.py | 2 +- syncplay/messages_en.py | 2 +- syncplay/messages_es.py | 2 +- syncplay/messages_it.py | 2 +- syncplay/messages_pt_BR.py | 2 +- syncplay/messages_pt_PT.py | 2 +- syncplay/messages_ru.py | 2 +- syncplay/resources/lua/intf/syncplay.lua | 7 ++++++- 9 files changed, 14 insertions(+), 9 deletions(-) diff --git a/syncplay/constants.py b/syncplay/constants.py index f3b9a0d..5a7a888 100755 --- a/syncplay/constants.py +++ b/syncplay/constants.py @@ -131,7 +131,7 @@ 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" -VLC_INTERFACE_VERSION = "0.3.5" +VLC_INTERFACE_VERSION = "0.3.6" VLC_LATENCY_ERROR_THRESHOLD = 2.0 MPV_UNRESPONSIVE_THRESHOLD = 60.0 CONTROLLED_ROOMS_MIN_VERSION = "1.3.0" diff --git a/syncplay/messages_de.py b/syncplay/messages_de.py index 57b50c2..e07427f 100755 --- a/syncplay/messages_de.py +++ b/syncplay/messages_de.py @@ -133,7 +133,7 @@ de = { "not-json-error": "Kein JSON-String\n", "hello-arguments-error": "Zu wenige Hello-Argumente\n", "version-mismatch-error": "Verschiedene Versionen auf Client und Server\n", - "vlc-failed-connection": "Kann nicht zu VLC verbinden. Wenn du syncplay.lua nicht installiert hast, findest du auf https://syncplay.pl/LUA/ [Englisch] eine Anleitung.", + "vlc-failed-connection": "Kann nicht zu VLC verbinden. Wenn du syncplay.lua nicht installiert hast, findest du auf https://syncplay.pl/LUA/ [Englisch] eine Anleitung. VLC 4 does not support Syncplay.", # TO DO: TRANSLATE "vlc-failed-noscript": "Laut VLC ist das syncplay.lua Interface-Skript nicht installiert. Auf https://syncplay.pl/LUA/ [Englisch] findest du eine Anleitung.", "vlc-failed-versioncheck": "Diese VLC-Version wird von Syncplay nicht unterstützt. Bitte nutze VLC 2.0", "vlc-initial-warning": 'VLC does not always provide accurate position information to Syncplay, especially for .mp4 and .avi files. If you experience problems with erroneous seeking then please try an alternative media player such as mpv.', # TODO: Translate diff --git a/syncplay/messages_en.py b/syncplay/messages_en.py index 9db8c9c..824b23c 100755 --- a/syncplay/messages_en.py +++ b/syncplay/messages_en.py @@ -133,7 +133,7 @@ en = { "not-json-error": "Not a json encoded string\n", "hello-arguments-error": "Not enough Hello arguments\n", # DO NOT TRANSLATE "version-mismatch-error": "Mismatch between versions of client and server\n", - "vlc-failed-connection": "Failed to connect to VLC. If you have not installed syncplay.lua and are using the latest verion of VLC then please refer to https://syncplay.pl/LUA/ for instructions.", + "vlc-failed-connection": "Failed to connect to VLC. If you have not installed syncplay.lua and are using the latest verion of VLC then please refer to https://syncplay.pl/LUA/ for instructions. VLC 4 does not support Syncplay.", "vlc-failed-noscript": "VLC has reported that the syncplay.lua interface script has not been installed. Please refer to https://syncplay.pl/LUA/ for instructions.", "vlc-failed-versioncheck": "This version of VLC is not supported by Syncplay.", "vlc-initial-warning": 'VLC does not always provide accurate position information to Syncplay, especially for .mp4 and .avi files. If you experience problems with erroneous seeking then please try an alternative media player such as mpv.', diff --git a/syncplay/messages_es.py b/syncplay/messages_es.py index 9c4e63c..33f8405 100644 --- a/syncplay/messages_es.py +++ b/syncplay/messages_es.py @@ -133,7 +133,7 @@ es = { "not-json-error": "No es una cadena de caracteres JSON válida\n", "hello-arguments-error": "Not enough Hello arguments\n", # DO NOT TRANSLATE "version-mismatch-error": "No coinciden las versiones del cliente y servidor\n", - "vlc-failed-connection": "Falló la conexión con VLC. Si no has instalado syncplay.lua y estás usando la última versión de VLC, por favor revisa https://syncplay.pl/LUA/ para obtener instrucciones.", + "vlc-failed-connection": "Falló la conexión con VLC. Si no has instalado syncplay.lua y estás usando la última versión de VLC, por favor revisa https://syncplay.pl/LUA/ para obtener instrucciones. VLC 4 does not support Syncplay.", # TO DO: TRANSLATE "vlc-failed-noscript": "VLC ha reportado que la interfaz syncplay.lua no se ha instalado. Por favor revisa https://syncplay.pl/LUA/ para obtener instrucciones.", "vlc-failed-versioncheck": "Esta versión de VLC no está soportada por Syncplay.", "vlc-initial-warning": 'VLC does not always provide accurate position information to Syncplay, especially for .mp4 and .avi files. If you experience problems with erroneous seeking then please try an alternative media player such as mpv.', # TODO: Translatef diff --git a/syncplay/messages_it.py b/syncplay/messages_it.py index b6fafc7..97f8e1f 100755 --- a/syncplay/messages_it.py +++ b/syncplay/messages_it.py @@ -133,7 +133,7 @@ it = { "not-json-error": "Non è una stringa con codifica JSON\n", "hello-arguments-error": "Not enough Hello arguments\n", # DO NOT TRANSLATE "version-mismatch-error": "La versione del client è diversa da quella del server\n", - "vlc-failed-connection": "Impossibile collegarsi a VLC. Se non hai installato syncplay.lua e stai usando l'ultima versione di VLC, fai riferimento a https://syncplay.pl/LUA/ per istruzioni.", + "vlc-failed-connection": "Impossibile collegarsi a VLC. Se non hai installato syncplay.lua e stai usando l'ultima versione di VLC, fai riferimento a https://syncplay.pl/LUA/ per istruzioni. VLC 4 does not support Syncplay.", # TO DO: TRANSLATE "vlc-failed-noscript": "VLC ha segnalato che lo script di interfaccia syncplay.lua non è stato installato. Per favore, fai riferimento a https://syncplay.pl/LUA/ per istruzioni.", "vlc-failed-versioncheck": "Questa versione di VLC non è supportata da Syncplay.", "vlc-initial-warning": 'VLC does not always provide accurate position information to Syncplay, especially for .mp4 and .avi files. If you experience problems with erroneous seeking then please try an alternative media player such as mpv.', # TODO: Translate diff --git a/syncplay/messages_pt_BR.py b/syncplay/messages_pt_BR.py index 2f140f8..ab42e2e 100644 --- a/syncplay/messages_pt_BR.py +++ b/syncplay/messages_pt_BR.py @@ -133,7 +133,7 @@ pt_BR = { "not-json-error": "Não é uma string codificada como JSON\n", "hello-arguments-error": "Not enough Hello arguments\n", # DO NOT TRANSLATE "version-mismatch-error": "Discrepância entre versões do client e do servidor\n", - "vlc-failed-connection": "Falha ao conectar ao VLC. Se você não instalou o syncplay.lua e está usando a versão mais recente do VLC, por favor veja https://syncplay.pl/LUA/ para mais instruções.", + "vlc-failed-connection": "Falha ao conectar ao VLC. Se você não instalou o syncplay.lua e está usando a versão mais recente do VLC, por favor veja https://syncplay.pl/LUA/ para mais instruções. VLC 4 does not support Syncplay.", # TO DO: TRANSLATE "vlc-failed-noscript": "O VLC reportou que a interface de script do syncplay.lua não foi instalada. Por favor, veja https://syncplay.pl/LUA/ para mais instruções.", "vlc-failed-versioncheck": "Esta versão do VLC não é suportada pelo Syncplay.", "vlc-initial-warning": 'VLC does not always provide accurate position information to Syncplay, especially for .mp4 and .avi files. If you experience problems with erroneous seeking then please try an alternative media player such as mpv.', # TODO: Translate diff --git a/syncplay/messages_pt_PT.py b/syncplay/messages_pt_PT.py index 9e1cc52..6f63dc7 100644 --- a/syncplay/messages_pt_PT.py +++ b/syncplay/messages_pt_PT.py @@ -133,7 +133,7 @@ pt_PT = { "not-json-error": "Não é uma string codificada como JSON\n", "hello-arguments-error": "Falta de argumentos Hello\n", # DO NOT TRANSLATE "version-mismatch-error": "Discrepância entre versões do cliente e do servidor\n", - "vlc-failed-connection": "Falha ao conectar ao VLC. Se você não instalou o syncplay.lua e está usando a versão mais recente do VLC, por favor veja https://syncplay.pl/LUA/ para mais instruções.", + "vlc-failed-connection": "Falha ao conectar ao VLC. Se você não instalou o syncplay.lua e está usando a versão mais recente do VLC, por favor veja https://syncplay.pl/LUA/ para mais instruções. VLC 4 does not support Syncplay.", # TO DO: TRANSLATE "vlc-failed-noscript": "O VLC reportou que a interface de script do syncplay.lua não foi instalada. Por favor, veja https://syncplay.pl/LUA/ para mais instruções.", "vlc-failed-versioncheck": "Esta versão do VLC não é suportada pelo Syncplay.", "vlc-initial-warning": 'VLC does not always provide accurate position information to Syncplay, especially for .mp4 and .avi files. If you experience problems with erroneous seeking then please try an alternative media player such as mpv.', # TODO: Translate diff --git a/syncplay/messages_ru.py b/syncplay/messages_ru.py index 18529f9..7fb6b2c 100755 --- a/syncplay/messages_ru.py +++ b/syncplay/messages_ru.py @@ -133,7 +133,7 @@ ru = { "not-json-error": "Не является закодированной json-строкой\n", "hello-arguments-error": "Не хватает аргументов Hello\n", "version-mismatch-error": "Конфликт версий между клиентом и сервером\n", - "vlc-failed-connection": "Ошибка подключения к VLC. Если у Вас не установлен syncplay.lua, то обратитесь к https://syncplay.pl/LUA/ за инструкциями.", + "vlc-failed-connection": "Ошибка подключения к VLC. Если у Вас не установлен syncplay.lua, то обратитесь к https://syncplay.pl/LUA/ за инструкциями. VLC 4 does not support Syncplay.", # TO DO: TRANSLATE "vlc-failed-noscript": "VLC сообщает, что скрипт интерфейса syncplay.lua не установлен. Пожалуйста, обратитесь к https://syncplay.pl/LUA/ за инструкциями.", "vlc-failed-versioncheck": "Данная версия VLC не поддерживается Syncplay. Пожалуйста, используйте VLC версии 2 или выше.", "vlc-initial-warning": 'VLC does not always provide accurate position information to Syncplay, especially for .mp4 and .avi files. If you experience problems with erroneous seeking then please try an alternative media player such as mpv.', # TODO: Translate diff --git a/syncplay/resources/lua/intf/syncplay.lua b/syncplay/resources/lua/intf/syncplay.lua index 54ce65f..c50c562 100644 --- a/syncplay/resources/lua/intf/syncplay.lua +++ b/syncplay/resources/lua/intf/syncplay.lua @@ -78,9 +78,14 @@ Syncplay should install this automatically to your user folder. --]==========================================================================] -local connectorversion = "0.3.5" +local connectorversion = "0.3.6" local vlcversion = vlc.misc.version() local vlcmajorversion = tonumber(vlcversion:sub(1,1)) -- get the major version of VLC + +if vlcmajorversion > 3 then + vlc.misc.quit() +end + local durationdelay = 500000 -- Pause for get_duration command etc for increased reliability (uses microseconds) local loopsleepduration = 2500 -- Pause for every event loop (uses microseconds) local quitcheckfrequency = 20 -- Check whether VLC has closed every X loops From 8a1810fd2b01dbd06676d86c4b856b96fbe8ed6c Mon Sep 17 00:00:00 2001 From: et0h Date: Sat, 19 Sep 2020 15:29:53 +0100 Subject: [PATCH 3/4] Update syncplay.lua to 0.3.6 --- syncplay/resources/lua/intf/syncplay.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syncplay/resources/lua/intf/syncplay.lua b/syncplay/resources/lua/intf/syncplay.lua index c50c562..0f0a7ac 100644 --- a/syncplay/resources/lua/intf/syncplay.lua +++ b/syncplay/resources/lua/intf/syncplay.lua @@ -5,7 +5,7 @@ Principal author: Etoh Other contributors: DerGenaue, jb, Pilotat Project: https://syncplay.pl/ - Version: 0.3.5 + Version: 0.3.6 Note: * This interface module is intended to be used in conjunction with Syncplay. From a02ddccf6b0db2810aa1678a95ae46b7dc48347f Mon Sep 17 00:00:00 2001 From: et0h Date: Sat, 19 Sep 2020 15:46:40 +0100 Subject: [PATCH 4/4] Always update VLC intf --- syncplay/players/vlc.py | 44 +++++++++++------------------------------ 1 file changed, 12 insertions(+), 32 deletions(-) diff --git a/syncplay/players/vlc.py b/syncplay/players/vlc.py index e5c0a76..097f54b 100755 --- a/syncplay/players/vlc.py +++ b/syncplay/players/vlc.py @@ -439,39 +439,19 @@ class VlcPlayer(BasePlayer): else: self.__playerController._client.ui.showDebugMessage("syncplay.lua intf directory not found, so creating directory '{}'".format(vlcSyncplayInterfaceDir)) Path(vlcSyncplayInterfaceDir).mkdir(mode=0o755, parents=True, exist_ok=True) - def _intfNeedsUpdating(vlcSyncplayInterfacePath): - self.__playerController._client.ui.showDebugMessage("Checking if '{}' exists and if it is the expected version".format(vlcSyncplayInterfacePath)) - if not os.path.isfile(vlcSyncplayInterfacePath): - self.__playerController._client.ui.showDebugMessage("syncplay.lua not found, so file needs copying") - return True - if os.path.isfile(vlcSyncplayInterfacePath): - with open(vlcSyncplayInterfacePath, 'rU') as interfacefile: - for line in interfacefile: - if "local connectorversion" in line: - interface_version = line[26:31] - if interface_version == constants.VLC_INTERFACE_VERSION: - self.__playerController._client.ui.showDebugMessage("syncplay.lua exists and is expected version, so no file needs copying") - return False - else: - self.oldIntfVersion = line[26:31] - self.__playerController._client.ui.showDebugMessage("syncplay.lua is {} but expected version is {} so file needs to be copied".format(interface_version, constants.VLC_INTERFACE_VERSION)) - return True - self.__playerController._client.ui.showDebugMessage("Up-to-dateness checks failed, so copy the file.") - return True - if _intfNeedsUpdating(os.path.join(self.__playerController.vlcIntfUserPath, "syncplay.lua")): - try: - _createIntfFolder(self.__playerController.vlcIntfUserPath) - copyForm = utils.findResourcePath("syncplay.lua") - copyTo = os.path.join(self.__playerController.vlcIntfUserPath, "syncplay.lua") - self.__playerController._client.ui.showDebugMessage("Copying VLC Lua Interface from '{}' to '{}'".format(copyForm, copyTo)) - import shutil - if os.path.exists(copyTo): - os.chmod(copyTo, 0o755) - shutil.copyfile(copyForm, copyTo) + try: + _createIntfFolder(self.__playerController.vlcIntfUserPath) + copyForm = utils.findResourcePath("syncplay.lua") + copyTo = os.path.join(self.__playerController.vlcIntfUserPath, "syncplay.lua") + self.__playerController._client.ui.showDebugMessage("Copying VLC Lua Interface from '{}' to '{}'".format(copyForm, copyTo)) + import shutil + if os.path.exists(copyTo): os.chmod(copyTo, 0o755) - except Exception as e: - self.__playerController._client.ui.showErrorMessage(e) - return + shutil.copyfile(copyForm, copyTo) + os.chmod(copyTo, 0o755) + except Exception as e: + self.__playerController._client.ui.showErrorMessage(e) + return if isLinux(): self.__playerController.vlcDataPath = "/usr/lib/syncplay/resources" else: