def handleProgress(self): printl("", self, "S") currentTime = self.getPlayPosition()[1] / 90000 totalTime = self.getPlayLength()[1] / 90000 progress = currentTime / (totalTime/100) printl( "played time is %s secs of %s @ %s%%" % ( currentTime, totalTime, progress),self, "I" ) instance = Singleton() plexInstance = instance.getPlexInstance() if self.multiUser: plexInstance.getTimelineURL(self.server, "/library/sections/onDeck", self.id, "stopped", str(currentTime*1000), str(totalTime*1000)) #Legacy PMS Server server support before MultiUser version v0.9.8.0 and if we are not connected via myPlex else: if currentTime < 30: printl("Less that 30 seconds, will not set resume", self, "I") #If we are less than 95% complete, store resume time elif progress < 95: printl("Less than 95% progress, will store resume time", self, "I" ) plexInstance.doRequest("http://"+self.server+"/:/progress?key="+self.id+"&identifier=com.plexapp.plugins.library&time="+str(currentTime*1000)) #Otherwise, mark as watched else: printl( "Movie marked as watched. Over 95% complete", self, "I") plexInstance.doRequest("http://"+self.server+"/:/scrobble?key="+self.id+"&identifier=com.plexapp.plugins.library") printl("", self, "C")
def updateTimeline(self): printl("" ,self,"S") try: currentTime = self.getPlayPosition()[1] / 90000 totalTime = self.getPlayLength()[1] / 90000 progress = int(( float(currentTime) / float(totalTime) ) * 100) if totalTime > 100000: return True printl("currentTime: " + str(currentTime), self, "C") printl("totalTime: " + str(totalTime), self, "C") instance = Singleton() plexInstance = instance.getPlexInstance() seekState = self.seekstate if seekState == self.SEEK_STATE_PAUSE: printl( "Movies PAUSED time: %s secs of %s @ %s%%" % ( currentTime, totalTime, progress), self,"D" ) plexInstance.getTimelineURL(self.server, "/library/sections/onDeck", self.id, "paused", str(currentTime*1000), str(totalTime*1000)) if seekState == self.SEEK_STATE_PLAY : printl( "Movies PLAYING time: %s secs of %s @ %s%%" % ( currentTime, totalTime, progress),self,"D" ) plexInstance.getTimelineURL(self.server, "/library/sections/onDeck", self.id, "playing", str(currentTime*1000), str(totalTime*1000)) except Exception, e: printl("exception: " + str(e), self, "E") return False
def handleProgress(self, EOF=False): printl("", self, "S") currentTime = self.getPlayPosition()[1] / 90000 totalTime = self.getPlayLength()[1] / 90000 if not EOF and currentTime is not None and currentTime > 0 and totalTime is not None and totalTime > 0: progress = currentTime / float(totalTime / 100.0) printl( "played time is %s secs of %s @ %s%%" % (currentTime, totalTime, progress), self, "I") else: progress = 100 printl("End of file reached", self, "I") instance = Singleton() plexInstance = instance.getPlexInstance() if self.multiUser: plexInstance.getTimelineURL(self.server, "/library/sections/onDeck", self.id, "stopped", str(currentTime * 1000), str(totalTime * 1000)) #Legacy PMS Server server support before MultiUser version v0.9.8.0 and if we are not connected via myPlex else: if currentTime < 30: printl("Less that 30 seconds, will not set resume", self, "I") #If we are less than 95% complete, store resume time elif progress < 95: printl("Less than 95% progress, will store resume time", self, "I") plexInstance.doRequest( "http://" + self.server + "/:/progress?key=" + self.id + "&identifier=com.plexapp.plugins.library&time=" + str(currentTime * 1000)) #Otherwise, mark as watched else: printl("Movie marked as watched. Over 95% complete", self, "I") plexInstance.doRequest( "http://" + self.server + "/:/scrobble?key=" + self.id + "&identifier=com.plexapp.plugins.library") if self.multiUser and self.timelinewatcherThread.isAlive(): self.timelinewatcherthread_wait.set() self.timelinewatcherthread_stop.set() printl("", self, "C")
def playEntry(self, selection): printl("-> in DP_ListMain", self, "S") media_id = selection[1]['Id'] server = selection[1]['ArtPoster'] instance = Singleton() plexInstance = instance.getPlexInstance() print "server =>" + server url = plexInstance.playStream(media_id, server, False) sref = eServiceReference(0x1001, 0, str(url)) sref.setName("DreamPlex") self.sref = sref self.session.open(DP_Player, sref, self)
def stopTranscoding(self): printl("", self, "S") if self.multiUser: self.timelinewatcherthread_wait.set() self.timelinewatcherthread_stop.set() instance = Singleton() plexInstance = instance.getPlexInstance() if self.universalTranscoder: plexInstance.doRequest("http://"+self.server+"/video/:/transcode/universal/stop?session=" + self.transcodingSession) else: plexInstance.doRequest("http://"+self.server+"/video/:/transcode/segmented/stop?session=" + self.transcodingSession) printl("", self, "C")
def updateTimeline(self): printl("", self, "S") try: currentTime = self.getPlayPosition()[1] / 90000 totalTime = self.getPlayLength()[1] / 90000 progress = int((float(currentTime) / float(totalTime)) * 100) if totalTime > 100000: return True printl("currentTime: " + str(currentTime), self, "C") printl("totalTime: " + str(totalTime), self, "C") instance = Singleton() plexInstance = instance.getPlexInstance() seekState = self.seekstate if seekState == self.SEEK_STATE_PAUSE: printl( "Movies PAUSED time: %s secs of %s @ %s%%" % (currentTime, totalTime, progress), self, "D") plexInstance.getTimelineURL(self.server, "/library/sections/onDeck", self.id, "paused", str(currentTime * 1000), str(totalTime * 1000)) if seekState == self.SEEK_STATE_PLAY: printl( "Movies PLAYING time: %s secs of %s @ %s%%" % (currentTime, totalTime, progress), self, "D") plexInstance.getTimelineURL(self.server, "/library/sections/onDeck", self.id, "playing", str(currentTime * 1000), str(totalTime * 1000)) except Exception, e: printl("exception: " + str(e), self, "E") return False
def stopTranscoding(self): printl("", self, "S") if self.multiUser: self.timelinewatcherthread_wait.set() self.timelinewatcherthread_stop.set() instance = Singleton() plexInstance = instance.getPlexInstance() if self.universalTranscoder: plexInstance.doRequest( "http://" + self.server + "/video/:/transcode/universal/stop?session=" + self.transcodingSession) else: plexInstance.doRequest( "http://" + self.server + "/video/:/transcode/segmented/stop?session=" + self.transcodingSession) printl("", self, "C")
def loadLibrary(self, params): printl("", self, "S") printl("params =" + str(params), self, "D") url = self.g_url instance = Singleton() plexInstance = instance.getPlexInstance() library = plexInstance.getMoviesFromSection(url) parsedLibrary = [] tmpAbc = [] tmpGenres = [] for movie in library: #=============================================================== # printl ("-> url = " + str(movie[0]), self, "D") # printl ("-> properties = " + str(movie[1]), self, "D") # printl ("-> arguments = " + str(movie[2]), self, "D") # printl ("-> context = " + str(movie[3]), self, "D") #=============================================================== url = movie[0] properties = movie[1] arguments = movie[2] context = movie[3] d = {} d["Title"] = properties.get('title', "") # d["Year"] = properties.get('year', "") # d["Plot"] = properties.get('plot', "") # d["Runtime"] = properties.get('duration', "") # d["Genres"] = properties.get('genre', "") d["Seen"] = properties.get('playcount', "") # d["Popularity"] = properties.get('rating', 0) # d["Studio"] = properties.get('studio', 0) # d["MPAA"] = properties.get('mpaa', 0) # d["Tag"] = properties.get('tagline', "") # d["server"] = properties.get('server', "") d["Id"] = arguments.get( 'ratingKey' ) #we use this because there is the id as value without any need of manipulating d["Path"] = arguments.get('key', "") d["Resolution"] = arguments.get('VideoResolution', "") d["Video"] = arguments.get('VideoCodec', "") d["Sound"] = arguments.get('AudioCodec', "") d["ArtBackdrop"] = arguments.get('fanart_image', "") d["ArtPoster"] = arguments.get('thumb', "") d["Creation"] = arguments.get('addedAt', 0) d["Key"] = arguments.get('key', "") d["ViewMode"] = "play" d["ScreenTitle"] = d["Title"] if d["Title"].upper() not in tmpAbc: tmpAbc.append(d["Title"].upper()) for genre in d["Genres"]: if genre not in tmpGenres: tmpGenres.append(genre) if (d["Seen"] == 0): image = None else: image = None parsedLibrary.append( (d["Title"], d, d["Title"].lower(), "50", image)) sort = [ ("Title", None, False), ("Popularity", "Popularity", True), ] if self.checkFileCreationDate: sort.append(("File Creation", "Creation", True)) sort.append(("Filename", "Filename", False)) filter = [ ("All", (None, False), ("", )), ] filter.append(("Seen", ("Seen", False, 1), ( "Seen", "Unseen", ))) if len(tmpGenres) > 0: tmpGenres.sort() filter.append(("Genre", ("Genres", True), tmpGenres)) if len(tmpAbc) > 0: tmpAbc.sort() filter.append(("Abc", ("Title", False, 1), tmpAbc)) printl("", self, "C") return (parsedLibrary, ( "ViewMode", "Id", ), None, None, sort, filter)
def loadLibrary(self, params): printl ("", self, "S") printl("params =" + str(params), self, "D") url = self.g_url instance = Singleton() plexInstance = instance.getPlexInstance() library = plexInstance.getMoviesFromSection(url) parsedLibrary = [] tmpAbc = [] tmpGenres = [] for movie in library: #=============================================================== # printl ("-> url = " + str(movie[0]), self, "D") # printl ("-> properties = " + str(movie[1]), self, "D") # printl ("-> arguments = " + str(movie[2]), self, "D") # printl ("-> context = " + str(movie[3]), self, "D") #=============================================================== url = movie[0] properties = movie[1] arguments = movie[2] context = movie[3] d = {} d["Title"] = properties.get('title', "")# d["Year"] = properties.get('year', "")# d["Plot"] = properties.get('plot', "") # d["Runtime"] = properties.get('duration', "")# d["Genres"] = properties.get('genre', "") d["Seen"] = properties.get('playcount', "")# d["Popularity"] = properties.get('rating', 0)# d["Studio"] = properties.get('studio', 0)# d["MPAA"] = properties.get('mpaa', 0)# d["Tag"] = properties.get('tagline', "")# d["server"] = properties.get('server', "") d["Id"] = arguments.get('ratingKey') #we use this because there is the id as value without any need of manipulating d["Path"] = arguments.get('key', "") d["Resolution"] = arguments.get('VideoResolution', "") d["Video"] = arguments.get('VideoCodec', "") d["Sound"] = arguments.get('AudioCodec', "") d["ArtBackdrop"] = arguments.get('fanart_image', "") d["ArtPoster"] = arguments.get('thumb', "") d["Creation"] = arguments.get('addedAt', 0) d["Key"] = arguments.get('key', "") d["ViewMode"] = "play" d["ScreenTitle"] = d["Title"] if d["Title"].upper() not in tmpAbc: tmpAbc.append(d["Title"].upper()) for genre in d["Genres"]: if genre not in tmpGenres: tmpGenres.append(genre) if (d["Seen"] == 0): image = None else: image = None parsedLibrary.append((d["Title"], d, d["Title"].lower(), "50", image)) sort = [("Title", None, False), ("Popularity", "Popularity", True), ] if self.checkFileCreationDate: sort.append(("File Creation", "Creation", True)) sort.append(("Filename", "Filename", False)) filter = [("All", (None, False), ("", )), ] filter.append(("Seen", ("Seen", False, 1), ("Seen", "Unseen", ))) if len(tmpGenres) > 0: tmpGenres.sort() filter.append(("Genre", ("Genres", True), tmpGenres)) if len(tmpAbc) > 0: tmpAbc.sort() filter.append(("Abc", ("Title", False, 1), tmpAbc)) printl ("", self, "C") return (parsedLibrary, ("ViewMode", "Id", ), None, None, sort, filter)