Example #1
0
 def getFeatures(self):
     if not self._features:
         self._features = {}
         self._features["sharedPlaylists"] = meetsMinVersion(self._version, SHARED_PLAYLIST_MIN_VERSION)
         self._features["chat"] = meetsMinVersion(self._version, CHAT_MIN_VERSION)
         self._features["featureList"] = False
         self._features["readiness"] = meetsMinVersion(self._version, USER_READY_MIN_VERSION)
         self._features["managedRooms"] = meetsMinVersion(self._version, CONTROLLED_ROOMS_MIN_VERSION)
     return self._features
Example #2
0
 def getFeatures(self):
     if not self._features:
         self._features = {}
         self._features["sharedPlaylists"] = meetsMinVersion(self._version, SHARED_PLAYLIST_MIN_VERSION)
         self._features["chat"] = meetsMinVersion(self._version, CHAT_MIN_VERSION)
         self._features["featureList"] = False
         self._features["readiness"] = meetsMinVersion(self._version, USER_READY_MIN_VERSION)
         self._features["managedRooms"] = meetsMinVersion(self._version, CONTROLLED_ROOMS_MIN_VERSION)
     return self._features
Example #3
0
 def getMotd(self, userIp, username, room, clientVersion):
     oldClient = False
     if constants.WARN_OLD_CLIENTS:
         if not meetsMinVersion(clientVersion,
                                constants.RECENT_CLIENT_THRESHOLD):
             oldClient = True
     if self._motdFilePath and os.path.isfile(self._motdFilePath):
         tmpl = codecs.open(self._motdFilePath, "r", "utf-8-sig").read()
         args = dict(version=syncplay.version,
                     userIp=userIp,
                     username=username,
                     room=room)
         try:
             motd = Template(tmpl).substitute(args)
             if oldClient:
                 motdwarning = getMessage(
                     "new-syncplay-available-motd-message").format(
                         clientVersion)
                 motd = "{}\n{}".format(motdwarning, motd)
             return motd if len(
                 motd
             ) < constants.SERVER_MAX_TEMPLATE_LENGTH else getMessage(
                 "server-messed-up-motd-too-long").format(
                     constants.SERVER_MAX_TEMPLATE_LENGTH, len(motd))
         except ValueError:
             return getMessage(
                 "server-messed-up-motd-unescaped-placeholders")
     elif oldClient:
         return getMessage("new-syncplay-available-motd-message").format(
             clientVersion)
     else:
         return ""
Example #4
0
    def lineReceived(self, line):
        try:
            self._client.ui.showDebugMessage("player << {}".format(line))
        except:
            pass
        match, name, value = self.RE_ANSWER.match(line), "", ""
        if match:
            name, value = match.group('command'), match.group('argument')

        if line == "filepath-change-notification":
            self._filechanged = True
            t = threading.Thread(target=self._onFileUpdate)
            t.setDaemon(True)
            t.start()
        elif name == "filepath":
            self._filechanged = True
            if value == "no-input":
                self._filepath = None
            else:
                if "file://" in value:
                    value = value.replace("file://", "")
                    if not os.path.isfile(value):
                        value = value.lstrip("/")
                self._filepath = value
            self._pathAsk.set()
        elif name == "duration":
            if value == "no-input":
                self._duration = 0
            else:
                self._duration = float(value.replace(",", "."))
            self._durationAsk.set()
        elif name == "playstate":
            self._paused = bool(value != 'playing') if (
                value != "no-input" and self._filechanged
                == False) else self._client.getGlobalPaused()
            self._pausedAsk.set()
        elif name == "position":
            self._position = float(value.replace(
                ",", ".")) if (value != "no-input" and self._filechanged
                               == False) else self._client.getGlobalPosition()
            self._lastVLCPositionUpdate = time.time()
            self._positionAsk.set()
        elif name == "filename":
            self._filechanged = True
            self._filename = value.decode('utf-8')
            self._filenameAsk.set()
        elif line.startswith("vlc-version: "):
            vlc_version = line.split(': ')[1].replace(' ', '-').split('-')[0]
            if not utils.meetsMinVersion(vlc_version,
                                         constants.VLC_MIN_VERSION):
                self._client.ui.showErrorMessage(
                    getMessage("vlc-version-mismatch").format(
                        str(vlc_version), str(constants.VLC_MIN_VERSION)))
            self._vlcready.set()
Example #5
0
 def _usevlcintf(vlcIntfPath, vlcIntfUserPath):
     vlcSyncplayInterfacePath = vlcIntfPath + "syncplay.lua"
     if not os.path.isfile(vlcSyncplayInterfacePath):
         vlcSyncplayInterfacePath = vlcIntfUserPath + "syncplay.lua"
     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 utils.meetsMinVersion(interface_version, constants.VLC_INTERFACE_MIN_VERSION):
                         return True
                     else:
                         playerController._client.ui.showErrorMessage(getMessage("vlc-interface-oldversion-warning"))
                         return False
     playerController._client.ui.showErrorMessage(getMessage("vlc-interface-not-installed"))
     return False
Example #6
0
 def _usevlcintf(vlcIntfPath, vlcIntfUserPath):
     vlcSyncplayInterfacePath = vlcIntfPath + "syncplay.lua"
     if not os.path.isfile(vlcSyncplayInterfacePath):
         vlcSyncplayInterfacePath = vlcIntfUserPath + "syncplay.lua"
     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 utils.meetsMinVersion(interface_version, constants.VLC_INTERFACE_MIN_VERSION):
                         return True
                     else:
                         self.oldIntfVersion = line[26:31]
                         return False
     playerController._client.ui.showErrorMessage(getMessage("vlc-interface-not-installed"))
     return False
Example #7
0
    def lineReceived(self, line):
        try:
            self._client.ui.showDebugMessage("player << {}".format(line))
        except:
            pass
        match, name, value = self.RE_ANSWER.match(line), "", ""
        if match:
            name, value = match.group('command'), match.group('argument')

        if line == "filepath-change-notification":
            self._filechanged = True
            t = threading.Thread(target=self._onFileUpdate)
            t.setDaemon(True)
            t.start()
        elif name == "filepath":
            self._filechanged = True
            if value == "no-input":
                self._filepath = None
            else:
                if "file://" in value:
                    value = value.replace("file://", "")
                    if not os.path.isfile(value):
                        value = value.lstrip("/")
                self._filepath = value
            self._pathAsk.set()
        elif name == "duration":
            if value == "no-input":
                self._duration = 0
            else:
                self._duration = float(value.replace(",", "."))
            self._durationAsk.set()
        elif name == "playstate":
            self._paused = bool(value != 'playing') if(value != "no-input" and self._filechanged == False) else self._client.getGlobalPaused()
            self._pausedAsk.set()
        elif name == "position":
            self._position = float(value.replace(",", ".")) if (value != "no-input" and self._filechanged == False) else self._client.getGlobalPosition()
            self._lastVLCPositionUpdate = time.time()
            self._positionAsk.set()
        elif name == "filename":
            self._filechanged = True
            self._filename = value.decode('utf-8')
            self._filenameAsk.set()
        elif line.startswith("vlc-version: "):
            vlc_version = line.split(': ')[1].replace(' ','-').split('-')[0]
            if not utils.meetsMinVersion(vlc_version, constants.VLC_MIN_VERSION):
                self._client.ui.showErrorMessage(getMessage("vlc-version-mismatch").format(str(vlc_version), str(constants.VLC_MIN_VERSION)))
            self._vlcready.set()
Example #8
0
 def getMotd(self, userIp, username, room, clientVersion):
     oldClient = False
     if constants.WARN_OLD_CLIENTS:
         if not meetsMinVersion(clientVersion, constants.RECENT_CLIENT_THRESHOLD):
             oldClient = True
     if self._motdFilePath and os.path.isfile(self._motdFilePath):
         tmpl = codecs.open(self._motdFilePath, "r", "utf-8-sig").read()
         args = dict(version=syncplay.version, userIp=userIp, username=username, room=room)
         try:
             motd = Template(tmpl).substitute(args)
             if oldClient:
                 motdwarning = getMessage("new-syncplay-available-motd-message").format(clientVersion)
                 motd = "{}\n{}".format(motdwarning, motd)
             return motd if len(motd) < constants.SERVER_MAX_TEMPLATE_LENGTH else getMessage("server-messed-up-motd-too-long").format(constants.SERVER_MAX_TEMPLATE_LENGTH, len(motd))
         except ValueError:
             return getMessage("server-messed-up-motd-unescaped-placeholders")
     elif oldClient:
         return getMessage("new-syncplay-available-motd-message").format(clientVersion)
     else:
         return ""
Example #9
0
    def lineReceived(self, line):
        try:
            self._client.ui.showDebugMessage("player << {}".format(line))
        except:
            pass
        match, name, value = self.RE_ANSWER.match(line), "", ""
        if match:
            name, value = match.group('command'), match.group('argument')

        if line == "filepath-change-notification":
            self._filechanged = True
            t = threading.Thread(target=self._onFileUpdate)
            t.setDaemon(True)
            t.start()
        elif name == "filepath":
            self._filechanged = True
            if value == "no-input":
                self._filepath = None
            else:
                if "file://" in value:
                    value = value.replace("file://", "")
                    if not os.path.isfile(value):
                        value = value.lstrip("/")
                elif utils.isURL(value):
                    value = urllib.unquote(value)
                    value = value.decode('utf-8')
                self._filepath = value
            self._pathAsk.set()
        elif name == "duration":
            if value == "no-input":
                self._duration = 0
            elif value == "invalid-32-bit-value":
                self._duration = 0
                self.drop(getMessage("vlc-failed-versioncheck"))
            else:
                self._duration = float(value.replace(",", "."))
            self._durationAsk.set()
        elif name == "playstate":
            self._paused = bool(value != 'playing') if (
                value != "no-input" and self._filechanged
                == False) else self._client.getGlobalPaused()
            if self._paused == False \
            and self._position == self._previousPreviousPosition \
            and self._previousPosition == self._position \
            and self._duration > constants.PLAYLIST_LOAD_NEXT_FILE_MINIMUM_LENGTH \
            and self._position == self._duration:
                self._paused = True
                self._client.ui.showDebugMessage(
                    "Treating 'playing' response as 'paused' due to VLC EOF bug"
                )
            self._pausedAsk.set()
        elif name == "position":
            newPosition = float(value.replace(
                ",", ".")) if (value != "no-input" and self._filechanged
                               == False) else self._client.getGlobalPosition()
            if newPosition == self._previousPosition and newPosition <> self._duration and not self._paused:
                self._client.ui.showDebugMessage(
                    "Not considering position {} duplicate as new time because of VLC time precision bug"
                    .format(newPosition))
                self._positionAsk.set()
                return
            self._previousPreviousPosition = self._previousPosition
            self._previousPosition = self._position
            self._position = newPosition
            if self._position < 0 and self._duration > 2147 and self._vlcVersion == "3.0.0":
                self.drop(getMessage("vlc-failed-versioncheck"))
            self._lastVLCPositionUpdate = time.time()
            self._positionAsk.set()
        elif name == "filename":
            self._filechanged = True
            self._filename = value.decode('utf-8')
            self._filenameAsk.set()
        elif line.startswith("vlc-version: "):
            self._vlcVersion = line.split(': ')[1].replace(' ',
                                                           '-').split('-')[0]
            if not utils.meetsMinVersion(self._vlcVersion,
                                         constants.VLC_MIN_VERSION):
                self._client.ui.showErrorMessage(
                    getMessage("vlc-version-mismatch").format(
                        constants.VLC_MIN_VERSION))
            self._vlcready.set()
Example #10
0
    def lineReceived(self, line):
        try:
            self._client.ui.showDebugMessage("player << {}".format(line))
        except:
            pass
        match, name, value = self.RE_ANSWER.match(line), "", ""
        if match:
            name, value = match.group('command'), match.group('argument')

        if line == "filepath-change-notification":
            self._filechanged = True
            t = threading.Thread(target=self._onFileUpdate)
            t.setDaemon(True)
            t.start()
        elif name == "filepath":
            self._filechanged = True
            if value == "no-input":
                self._filepath = None
            else:
                if "file://" in value:
                    value = value.replace("file://", "")
                    if not os.path.isfile(value):
                        value = value.lstrip("/")
                elif utils.isURL(value):
                    value = urllib.unquote(value)
                    value = value.decode('utf-8')
                self._filepath = value
            self._pathAsk.set()
        elif name == "duration":
            if value == "no-input":
                self._duration = 0
            elif value == "invalid-32-bit-value":
                self._duration = 0
                self.drop(getMessage("vlc-failed-versioncheck"))
            else:
                self._duration = float(value.replace(",", "."))
            self._durationAsk.set()
        elif name == "playstate":
            self._paused = bool(value != 'playing') if(value != "no-input" and self._filechanged == False) else self._client.getGlobalPaused()
            if self._paused == False \
            and self._position == self._previousPreviousPosition \
            and self._previousPosition == self._position \
            and self._duration > constants.PLAYLIST_LOAD_NEXT_FILE_MINIMUM_LENGTH \
            and self._position == self._duration:
                self._paused = True
                self._client.ui.showDebugMessage("Treating 'playing' response as 'paused' due to VLC EOF bug")
            self._pausedAsk.set()
        elif name == "position":
            newPosition = float(value.replace(",", ".")) if (value != "no-input" and self._filechanged == False) else self._client.getGlobalPosition()
            if newPosition == self._previousPosition and newPosition <> self._duration and not self._paused:
                self._client.ui.showDebugMessage("Not considering position {} duplicate as new time because of VLC time precision bug".format(newPosition))
                self._positionAsk.set()
                return
            self._previousPreviousPosition = self._previousPosition
            self._previousPosition = self._position
            self._position = newPosition
            if self._position < 0 and self._duration > 2147 and self._vlcVersion == "3.0.0":
                self.drop(getMessage("vlc-failed-versioncheck"))
            self._lastVLCPositionUpdate = time.time()
            self._positionAsk.set()
        elif name == "filename":
            self._filechanged = True
            self._filename = value.decode('utf-8')
            self._filenameAsk.set()
        elif line.startswith("vlc-version: "):
            self._vlcVersion = line.split(': ')[1].replace(' ','-').split('-')[0]
            if not utils.meetsMinVersion(self._vlcVersion, constants.VLC_MIN_VERSION):
                self._client.ui.showErrorMessage(getMessage("vlc-version-mismatch").format(constants.VLC_MIN_VERSION))
            self._vlcready.set()