def handleProgress(self): ''' ''' printl("", self, "S") currentTime = self.getPlayPosition()[1] / 90000 totalTime = self.getPlayLength()[1] / 90000 progress = currentTime / (totalTime / 100) #progress = 0 printl( "played time is %s secs of %s @ %s%%" % (currentTime, totalTime, progress), self, "I") instance = Singleton() plexInstance = instance.getPlexInstance() 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.getURL( "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.getURL("http://" + self.server + "/:/scrobble?key=" + self.id + "&identifier=com.plexapp.plugins.library") printl("", self, "C")
def playEntry(self, selection): ''' ''' printl("", self, "S") media_id = selection[1]['Id'] server = selection[1]['ArtPoster'] instance = Singleton() plexInstance = instance.getPlexInstance() self.playerData = plexInstance.playLibraryMedia( media_id, server, False) resumeStamp = self.playerData['resumeStamp'] printl("resumeStamp: " + str(resumeStamp), self, "I") if resumeStamp > 0: self.session.openWithCallback( self.handleResume, MessageBox, _(" This file was partially played.\n\n Do you want to resume?" ), MessageBox.TYPE_YESNO) else: self.session.open(DP_Player, self.playerData) printl("", self, "C")
def stopTranscoding(self): ''' ''' printl("", self, "S") instance = Singleton() plexInstance = instance.getPlexInstance() #sample from log /video/:/transcode/segmented/stop?session=0EBD197D-389A-4784-8CC5-709BAD5E1137&X-Plex-Client-Capabilities=protocols%3Dhttp-live-streaming%2Chttp-mp4-streaming%2Chttp-streaming-video%2Chttp-streaming-video-720p%2Chttp-mp4-video%2Chttp-mp4-video-720p%3BvideoDecoders%3Dh264%7Bprofile%3Ahigh%26resolution%3A1080%26level%3A41%7D%3BaudioDecoders%3Dmp3%2Caac%7Bbitrate%3A160000%7D&X-Plex-Client-Platform=iOS&X-Plex-Product=Plex%2FiOS&X-Plex-Version=3.0.2&X-Plex-Device-Name=DDiPhone [192.168.45.6:62662] (4 live) plexInstance.getURL("http://" + self.server + "/video/:/transcode/segmented/stop?session=" + self.transcodingSession) printl("", self, "C")
def getFilterData(self): ''' ''' printl("", self, "S") instance = Singleton() plexInstance = instance.getPlexInstance() printl("self.s_url = " + self.s_url, self, "D") menuData = plexInstance.getSectionFilter(self.s_url) self["menu"].setList(menuData) self.g_filterDataMenu = menuData #lets save the menu to call it when cancel is pressed self.refreshMenu(0) printl("", self, "S")
def startThemePlayback(self): ''' ''' printl("", self, "S") printl("start pĺaying theme", self, "I") accessToken = Singleton().getPlexInstance().g_myplex_accessToken theme = self.extraData["theme"] server = self.details["server"] printl("theme: " + str(theme), self, "D") url = "http://" + str(server) + str(theme) + "?X-Plex-Token=" + str(accessToken) sref = "4097:0:0:0:0:0:0:0:0:0:%s" % quote_plus(url) printl("sref: " + str(sref), self, "D") self.session.nav.stopService() self.session.nav.playService(eServiceReference(sref)) printl("", self, "C")
def getServerData(self): ''' ''' printl("", self, "S") instance = Singleton() instance.getPlexInstance(PlexLibrary(self.session, self.g_serverConfig)) plexInstance = instance.getPlexInstance() serverData = plexInstance.getAllSections() self["menu"].setList(serverData) self.g_serverDataMenu = serverData #lets save the menu to call it when cancel is pressed self.refreshMenu(0) printl("", self, "C")
def addSearchString(self, searchString): ''' ''' printl("", self, "S") # sample: http://192.168.45.190:32400/search?type=1&query=fringe instance = Singleton() instance.getPlexInstance(PlexLibrary(self.session, self.g_serverConfig)) plexInstance = instance.getPlexInstance() serverUrl = plexInstance.getServerFromURL(self.s_url) if searchString is not "" and searchString is not None: self.s_url = serverUrl + "/search?type=1&query=" + searchString self.executeSelectedEntry() printl("", self, "C")
def getServerData(self, filter=None): ''' ''' printl("", self, "S") instance = Singleton() instance.getPlexInstance(PlexLibrary(self.session, self.g_serverConfig)) plexInstance = instance.getPlexInstance() summerize = config.plugins.dreamplex.summerizeSections.value if summerize == True and filter == None: serverData = plexInstance.getSectionTypes() self.g_sectionDataMenu = serverData else: serverData = plexInstance.displaySections(filter) self.g_serverDataMenu = serverData #lets save the menu to call it when cancel is pressed self["menu"].setList(serverData) self.refreshMenu(0) printl("", self, "C")
def __init__(self, session, libraryName, loadLibrary, playEntry, viewName, select=None, sort=None, filter=None): ''' ''' printl("", self, "S") self.session = session DP_View.__init__(self, session, libraryName, loadLibrary, playEntry, viewName, select, sort, filter) # get needed config parameters self.mediaPath = config.plugins.dreamplex.mediafolderpath.value self.playTheme = config.plugins.dreamplex.playTheme.value self.fastScroll = config.plugins.dreamplex.fastScroll.value # get data from plex library self.image_prefix = Singleton().getPlexInstance().getServerName( ).lower() # init skin elements self["functionsContainer"] = Label() self["btn_red"] = Pixmap() self["btn_blue"] = Pixmap() self["btn_yellow"] = Pixmap() self["btn_zero"] = Pixmap() self["btn_nine"] = Pixmap() self["btn_pvr"] = Pixmap() self["btn_menu"] = Pixmap() self["txt_red"] = Label() self["txt_filter"] = Label() self["txt_blue"] = Label() self["txt_blue"].setText(_("toogle View ") + _("(current 'Default')")) self["txt_yellow"] = Label() if self.fastScroll == True: self["txt_yellow"].setText("fastScroll = On") else: self["txt_yellow"].setText("fastScroll = Off") self["txt_pvr"] = Label() self["txt_pvr"].setText("load additional data") self["txt_menu"] = Label() self["txt_menu"].setText("show media functions") self["poster"] = Pixmap() self["mybackdrop"] = Pixmap() self["audio"] = MultiPixmap() self["resolution"] = MultiPixmap() self["aspect"] = MultiPixmap() self["codec"] = MultiPixmap() self["rated"] = MultiPixmap() self["title"] = Label() self["tag"] = Label() self["shortDescription"] = ScrollLabel() self["genre"] = Label() self["year"] = Label() self["runtime"] = Label() self["total"] = Label() self["current"] = Label() self["backdroptext"] = Label() self["postertext"] = Label() self["rating_stars"] = ProgressBar() self.skinName = self.viewName[2] self.EXscale = (AVSwitch().getFramebufferScale()) self.EXpicloadPoster = ePicLoad() self.EXpicloadBackdrop = ePicLoad() self.onLayoutFinish.append(self.setPara) printl("", self, "C")
def loadLibrary(self, params): ''' ''' printl("", self, "S") printl("params: " + str(params), self, "D") if self.showEpisodesDirectly == True: printl("show episodes in OnDeck ...", self, "I") url = self.g_url library = Singleton().getPlexInstance().getEpisodesOfSeason(url) sort = [ ("by title", None, False), ] filter = [ ("All", (None, False), ("", )), ] #filter.append(("Seen", ("Seen", False, 1), ("Seen", "Unseen", ))) printl("", self, "C") return (library, ( "viewMode", "ratingKey", ), None, "None", sort, filter) else: # Diplay all TVShows if params is None: printl("show TV shows ...", self, "I") url = self.g_url library = Singleton().getPlexInstance().albums(url) # sort sort = [ ("by title", None, False), ("by year", "year", True), ("by rating", "rating", True), ] filter = [ ("All", (None, False), ("", )), ] #if len(tmpGenres) > 0: #tmpGenres.sort() #filter.append(("Genre", ("Genres", True), tmpGenres)) printl("", self, "C") return (library, ( "viewMode", "ratingKey", ), None, None, sort, filter) # (libraryArray, onEnterPrimaryKeys, onLeavePrimaryKeys, onLeaveSelectEntry # Display the Seasons Menu elif params["viewMode"] == "ShowSeasons": printl("show seasons of TV show ...", self, "I") url = params["url"] printl("URL: " + str(url), self, "D") library = Singleton().getPlexInstance().tracks(url) sort = (("by season", "season", False), ) filter = [ ("All", (None, False), ("", )), ] printl("", self, "C") return (library, ( "viewMode", "ratingKey", ), None, "backToShows", sort, filter) # (libraryArray, onEnterPrimaryKeys, onLeavePrimaryKeys, onLeaveSelectEntry # Display the Episodes Menu elif params["viewMode"] == "ShowEpisodes": printl("show episodes of season ...", self, "I") url = params["url"] library = Singleton().getPlexInstance().tracks(url) sort = [ ("by title", None, False), ] filter = [ ("All", (None, False), ("", )), ] #filter.append(("Seen", ("Seen", False, 1), ("Seen", "Unseen", ))) printl("", self, "C") return (library, ( "viewMode", "ratingKey", ), None, "backToSeasons", sort, filter) # (libraryArray, onEnterPrimaryKeys, onLeavePrimaryKeys, onLeaveSelectEntry printl("", self, "C")
def loadLibrary(self, params): ''' ''' printl("", self, "S") printl("params =" + str(params), self, "D") # Diplay all TVShows if params is None: printl("show TV shows ...", self, "I") parsedLibrary = [] url = self.g_url instance = Singleton() plexInstance = instance.getPlexInstance() library = plexInstance.getShowsFromSection(url) tmpAbc = [] tmpGenres = [] for tvshow in library: #=============================================================== # printl ("-> url = " + str(tvshow[0]), self, "D") # printl ("-> properties = " + str(tvshow[1]), self, "D") # printl ("-> arguments = " + str(tvshow[2]), self, "D") # printl ("-> context = " + str(tvshow[3]), self, "D") #=============================================================== url = tvshow[0] properties = tvshow[1] arguments = tvshow[2] context = tvshow[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["Id"] = arguments.get( 'ratingKey' ) #we use this because there is the id as value without any need of manipulating d["Tag"] = arguments.get('tagline', "") d["Path"] = arguments.get('key', "") d["Popularity"] = arguments.get('rating', 0) 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["Seen"] = arguments.get('playcount', 0) d["Creation"] = arguments.get('addedAt', 0) d["Banner"] = arguments.get('banner', "") d["server"] = arguments.get('server', "") d["ViewMode"] = "ShowSeasons" d["ScreenTitle"] = d["Title"] 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), ) filter = [ ("All", (None, False), ("", )), ] 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)) return (parsedLibrary, ( "ViewMode", "Id", ), None, None, sort, filter) # Display the Seasons Menu elif params["ViewMode"] == "ShowSeasons": printl("show seasons of TV show ...", self, "I") parsedLibrary = [] url = params["url"] instance = Singleton() plexInstance = instance.getPlexInstance() library = plexInstance.getSeasonsOfShow(url) seasons = [] for season in library: #=============================================================== # printl ("-> url = " + str(season[0]), self, "D") # printl ("-> properties = " + str(season[1]), self, "D") # printl ("-> arguments = " + str(season[2]), self, "D") # printl ("-> context = " + str(season[3]), self, "D") #=============================================================== url = season[0] properties = season[1] arguments = season[2] context = season[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["Id"] = arguments.get( 'ratingKey' ) #we use this because there is the id as value without any need of manipulating d["Tag"] = arguments.get('tagline', "") d["Path"] = arguments.get('key', "") d["Popularity"] = arguments.get('rating', 0) 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["Seen"] = arguments.get('playcount', 0) d["Creation"] = arguments.get('addedAt', 0) d["Banner"] = arguments.get('banner', "") d["server"] = arguments.get('server', "") d["ViewMode"] = "ShowEpisodes" d["ScreenTitle"] = d["Title"] if (d["Seen"] == 0): image = None else: image = None print "appending title " + d["Title"] parsedLibrary.append( (d["Title"], d, d["Title"].lower(), "50", image)) sort = (("Title", None, False), ) filter = [ ("All", (None, False), ("", )), ] return (parsedLibrary, ( "ViewMode", "Id", "Season", ), None, None, sort, filter) # Display the Episodes Menu elif params["ViewMode"] == "ShowEpisodes": printl("show episodes of season ...", self, "I") parsedLibrary = [] url = params["url"] instance = Singleton() plexInstance = instance.getPlexInstance() library = plexInstance.getEpisodesOfSeason(url) for episode in library: #=============================================================== # printl ("-> url = " + str(episode[0]), self, "D") # printl ("-> properties = " + str(episode[1]), self, "D") # printl ("-> arguments = " + str(episode[2]), self, "D") # printl ("-> context = " + str(episode[3]), self, "D") #=============================================================== url = episode[0] properties = episode[1] arguments = episode[2] context = episode[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["Id"] = arguments.get( 'ratingKey' ) #we use this because there is the id as value without any need of manipulating d["Tag"] = arguments.get('tagline', "") d["Path"] = arguments.get('key', "") d["Popularity"] = arguments.get('rating', 0) d["Resolution"] = arguments.get('VideoResolution', "") d["Video"] = arguments.get('VideoCodec', "") d["Sound"] = arguments.get('AudioCodec', "") d["ArtBackdrop"] = arguments.get('thumb', "") d["ArtPoster"] = arguments.get('fanart_image', "") d["Seen"] = arguments.get('playcount', 0) d["Creation"] = arguments.get('addedAt', 0) d["Banner"] = arguments.get('banner', "") d["server"] = arguments.get('server', "") d["ViewMode"] = "play" d["ScreenTitle"] = d["Title"] 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), ] filter = [ ("All", (None, False), ("", )), ] filter.append(("Seen", ("Seen", False, 1), ( "Seen", "Unseen", ))) return (parsedLibrary, ( "ViewMode", "Id", "Episodes", ), None, None, sort, filter) printl("", self, "C")