def ExecuteCommand(self, mycgi): self.log(u"mycgi.ParamCount(): " + unicode(mycgi.ParamCount()), xbmc.LOGDEBUG) self.resumeEnabled = self.addon.getSetting(u'resume_enabled') == u'true' self.watchedEnabled = self.addon.getSetting(u'show_watched') == u'true' self.log("mycgi: " + pformat(mycgi._GetParamDict())) (forwardedIP, episodeId, playFromStart, resume, deleteResume, forceResumeUnlock, clearCache, watched, unwatched) = mycgi.Params( u'forwardedip', u'episodeId', PLAYFROMSTART, RESUME, DELETERESUME, FORCERESUMEUNLOCK, u'clearcache', u'watched', u'unwatched') self.log("unicode((forwardedIP, episodeId, playFromStart, resume, deleteResume, forceResumeUnlock, clearCache, watched, unwatched)): " + unicode((forwardedIP, episodeId, playFromStart, resume, deleteResume, forceResumeUnlock, clearCache, watched, unwatched))) if self.httpManager.GetIsForwardedForIP(): forwardedIP = self.CreateForwardedForIP(forwardedIP) if forwardedIP <> u'': self.httpManager.SetForwardedForIP( forwardedIP ) if clearCache != u'': self.httpManager.ClearCache() return True if self.resumeEnabled: ResumePlayer.RESUME_FILE = os.path.join( self.dataFolder, self.GetProviderId() + u'player_resume.txt') ResumePlayer.RESUME_LOCK_FILE = os.path.join(self.dataFolder, self.GetProviderId() + u'player_resume_lock.txt') ResumePlayer.ADDON = self.addon if deleteResume: ResumePlayer.delete_resume_point(deleteResume) xbmc.executebuiltin(u'Container.Refresh') return True if forceResumeUnlock: ResumePlayer.force_release_lock() return True if episodeId <> u'' and playFromStart == u'' and resume == u'': # Only use default if playFromStart or resume are not explicitly set if int(self.addon.getSetting(u'playaction')) == 0: mycgi._GetParamDict()[RESUME] = u'1' if self.watchedEnabled: Watched.WATCHED_FILE = os.path.join( self.dataFolder, self.GetProviderId() + u'watched.txt') Watched.ADDON = self.addon if watched != u'': Watched.setWatched(episodeId) xbmc.executebuiltin( "Container.Refresh" ) return True if unwatched != u'': Watched.clearWatched(episodeId) xbmc.executebuiltin( "Container.Refresh" ) return True if mycgi.ParamCount() > 1: return self.ParseCommand(mycgi) else: return self.ShowRootMenu()
def GetPlayer(self, pid, live, playerName): if self.watchedEnabled: player = WatchedPlayer() player.initialise(live, playerName, self.GetWatchedPercent(), pid, self.resumeEnabled, self.log) return player elif self.resumeEnabled: player = ResumePlayer() player.init(pid, live, playerName) return player return super(TV3Provider, self).GetPlayer(pid, live, playerName)
def ResumeWatchListItem(self, url, episodeId, contextMenuItems, infoLabels, thumbnail): if self.watchedEnabled: self.log("url: %s, episodeId: %s" % (url, episodeId)) if Watched.isWatched(episodeId): infoLabels['PlayCount'] = 1 contextMenuItems.append( (u'Mark as unwatched', u"XBMC.RunPlugin(%s&unwatched=1)" % url)) else: contextMenuItems.append( (u'Mark as watched', u"XBMC.RunPlugin(%s&watched=1)" % url)) if self.resumeEnabled: resume, dates_added = ResumePlayer.load_resume_file() if episodeId in resume.keys(): resumeTime = self.ToHMS(resume[episodeId]) newTitle = u"%s [I](resumeable %s)[/I] " % ( infoLabels[u'Title'], resumeTime) infoLabels[u'Title'] = newTitle infoLabels[u'LastPlayed'] = dates_added[episodeId] cmdDelete = u"XBMC.RunPlugin(%s&%s=%s)" % ( self.GetURLStart(), DELETERESUME, episodeId) # Play from start cmdFromStart = u"XBMC.RunPlugin(%s&%s=1)" % (url, PLAYFROMSTART) cmdResume = u"XBMC.RunPlugin(%s&%s=1)" % (url, RESUME) contextMenuItems.append( (u'Resume from %s' % resumeTime, cmdResume)) contextMenuItems.append((u'Play from start', cmdFromStart)) contextMenuItems.append((u'Remove resume point', cmdDelete)) cmdForceUnlock = u"XBMC.RunPlugin(%s&%s=1)" % (self.GetURLStart(), FORCERESUMEUNLOCK) contextMenuItems.append( (u'Force unlock resume file', cmdForceUnlock)) newListItem = xbmcgui.ListItem(infoLabels['Title']) newListItem.setThumbnailImage(thumbnail) newListItem.setInfo(u'video', infoLabels) newListItem.setLabel(infoLabels['Title']) newListItem.setProperty("Video", "true") if len(contextMenuItems) > 0: newListItem.addContextMenuItems(contextMenuItems) return newListItem
def ResumeWatchListItem(self, url, episodeId, contextMenuItems, infoLabels, thumbnail): if self.watchedEnabled: self.log("url: %s, episodeId: %s" % (url, episodeId)) if Watched.isWatched(episodeId): infoLabels['PlayCount'] = 1 contextMenuItems.append((u'Mark as unwatched', u"XBMC.RunPlugin(%s&unwatched=1)" % url)) else: contextMenuItems.append((u'Mark as watched', u"XBMC.RunPlugin(%s&watched=1)" % url)) if self.resumeEnabled: resume, dates_added = ResumePlayer.load_resume_file() if episodeId in resume.keys(): resumeTime = self.ToHMS(resume[episodeId]) newTitle = u"%s [I](resumeable %s)[/I] " % (infoLabels[u'Title'], resumeTime) infoLabels[u'Title'] = newTitle infoLabels[u'LastPlayed'] = dates_added[episodeId] cmdDelete = u"XBMC.RunPlugin(%s&%s=%s)" % (self.GetURLStart(), DELETERESUME, episodeId) # Play from start cmdFromStart = u"XBMC.RunPlugin(%s&%s=1)" % (url, PLAYFROMSTART) cmdResume = u"XBMC.RunPlugin(%s&%s=1)" % (url, RESUME) contextMenuItems.append((u'Resume from %s' % resumeTime, cmdResume)) contextMenuItems.append((u'Play from start', cmdFromStart)) contextMenuItems.append((u'Remove resume point', cmdDelete)) cmdForceUnlock = u"XBMC.RunPlugin(%s&%s=1)" % (self.GetURLStart(), FORCERESUMEUNLOCK) contextMenuItems.append((u'Force unlock resume file', cmdForceUnlock)) newListItem = xbmcgui.ListItem( infoLabels['Title'] ) newListItem.setThumbnailImage(thumbnail) newListItem.setInfo(u'video', infoLabels) newListItem.setLabel(infoLabels['Title']) newListItem.setProperty("Video", "true") if len(contextMenuItems) > 0: newListItem.addContextMenuItems(contextMenuItems) return newListItem
def ExecuteCommand(self, mycgi): self.log(u"mycgi.ParamCount(): " + unicode(mycgi.ParamCount()), xbmc.LOGDEBUG) self.resumeEnabled = self.addon.getSetting( u'resume_enabled') == u'true' self.watchedEnabled = self.addon.getSetting(u'show_watched') == u'true' self.log("mycgi: " + pformat(mycgi._GetParamDict())) (forwardedIP, episodeId, playFromStart, resume, deleteResume, forceResumeUnlock, clearCache, watched, unwatched) = mycgi.Params(u'forwardedip', u'episodeId', PLAYFROMSTART, RESUME, DELETERESUME, FORCERESUMEUNLOCK, u'clearcache', u'watched', u'unwatched') self.log( "unicode((forwardedIP, episodeId, playFromStart, resume, deleteResume, forceResumeUnlock, clearCache, watched, unwatched)): " + unicode((forwardedIP, episodeId, playFromStart, resume, deleteResume, forceResumeUnlock, clearCache, watched, unwatched))) if self.httpManager.GetIsForwardedForIP(): forwardedIP = self.CreateForwardedForIP(forwardedIP) if forwardedIP <> u'': self.httpManager.SetForwardedForIP(forwardedIP) if clearCache != u'': self.httpManager.ClearCache() return True if self.resumeEnabled: ResumePlayer.RESUME_FILE = os.path.join( self.dataFolder, self.GetProviderId() + u'player_resume.txt') ResumePlayer.RESUME_LOCK_FILE = os.path.join( self.dataFolder, self.GetProviderId() + u'player_resume_lock.txt') ResumePlayer.ADDON = self.addon if deleteResume: ResumePlayer.delete_resume_point(deleteResume) xbmc.executebuiltin(u'Container.Refresh') return True if forceResumeUnlock: ResumePlayer.force_release_lock() return True if episodeId <> u'' and playFromStart == u'' and resume == u'': # Only use default if playFromStart or resume are not explicitly set if int(self.addon.getSetting(u'playaction')) == 0: mycgi._GetParamDict()[RESUME] = u'1' if self.watchedEnabled: Watched.WATCHED_FILE = os.path.join( self.dataFolder, self.GetProviderId() + u'watched.txt') Watched.ADDON = self.addon if watched != u'': Watched.setWatched(episodeId) xbmc.executebuiltin("Container.Refresh") return True if unwatched != u'': Watched.clearWatched(episodeId) xbmc.executebuiltin("Container.Refresh") return True if mycgi.ParamCount() > 1: return self.ParseCommand(mycgi) else: return self.ShowRootMenu()