diff --git a/syncplay/client.py b/syncplay/client.py index cae8de1c..88df67fd 100755 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -101,6 +101,9 @@ def __init__(self, playerClass, ui, config): self.lastRewindTime = None self.lastUpdatedFileTime = None self.lastAdvanceTime = None + self.openedStrmSource = None + self.openedStrmResolvedPath = None + self.openedStrmSourceTime = None self.fileOpenBeforeChangingPlaylistIndex = None self.waitingToLoadNewfile = False self.waitingToLoadNewfileSince = None @@ -559,21 +562,53 @@ def eofReportedByPlayer(self): self.ui.showDebugMessage("Fixing file duration to allow for playlist advancement") self.userlist.currentUser.file["duration"] = self._playerPosition + def _isStrmPath(self, filePath): + if not filePath: + return False + return urlparse(filePath).path.lower().endswith(".strm") + def updateFile(self, filename, duration, path): self.lastUpdatedFileTime = time.time() newPath = "" - if utils.isURL(path): - filename = path if not path: return - try: - size = os.path.getsize(path) - except: + usingOpenedStrmSource = False + if self.openedStrmSource: + if self.openedStrmResolvedPath is None: + resolutionTimedOut = ( + self.openedStrmSourceTime is None or + time.time() - self.openedStrmSourceTime > constants.STREAM_ADDITIONAL_IGNORE_TIME + ) + if resolutionTimedOut: + self.openedStrmSource = None + self.openedStrmResolvedPath = None + self.openedStrmSourceTime = None + elif self._isStrmPath(path): + usingOpenedStrmSource = True + else: + self.openedStrmResolvedPath = path + usingOpenedStrmSource = True + elif path == self.openedStrmResolvedPath: + usingOpenedStrmSource = True + else: + self.openedStrmSource = None + self.openedStrmResolvedPath = None + self.openedStrmSourceTime = None + if usingOpenedStrmSource: + path = self.openedStrmSource + filename = path if utils.isURL(path) else os.path.basename(path) + size = 0 + else: + if utils.isURL(path): + filename = path try: - path = path.decode('utf-8') size = os.path.getsize(path) except: - size = 0 + try: + path = path.decode('utf-8') + size = os.path.getsize(path) + except: + size = 0 if not utils.isURL(path) and os.path.exists(path): self.fileSwitch.notifyUserIfFileNotInMediaDirectory(filename, path) filename, size = self.__executePrivacySettings(filename, size) @@ -656,6 +691,13 @@ def openFile(self, filePath, resetPosition=False, fromUser=False): self.playlist.loadPlaylistFromFile(filePath, resetPosition) return + self.openedStrmSource = None + self.openedStrmResolvedPath = None + self.openedStrmSourceTime = None + if self._isStrmPath(filePath): + self.openedStrmSource = filePath + self.openedStrmSourceTime = time.time() + self.playlist.openedFile() self._player.openFile(filePath, resetPosition) if resetPosition: diff --git a/syncplay/messages_en.py b/syncplay/messages_en.py index 347ddbae..fca44146 100644 --- a/syncplay/messages_en.py +++ b/syncplay/messages_en.py @@ -162,7 +162,7 @@ "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. Syncplay and VLC 4 are not currently compatible, so either use VLC 3 or an alternative such as mpv.", "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 (or mpv.net for Windows users).', + "vlc-initial-warning": 'VLC does not always provide accurate position information to Syncplay, especially for streams and .mp4 and .avi files. If you experience problems with erroneous seeking then please try an alternative media player such as mpv (or mpv.net for Windows users).', "feature-sharedPlaylists": "shared playlists", # used for not-supported-by-server-error "feature-chat": "chat", # used for not-supported-by-server-error