Esempio n. 1
0
    def ParseCommand(self, mycgi):
        self.log(u"", xbmc.LOGDEBUG)

        (category, showId, episodeId, title, search, order, page, clearCache,
         watched, unwatched) = mycgi.Params(u'category', u'show', u'ep',
                                            u'title', u'search', u'order',
                                            u'page', u'clearcache', u'watched',
                                            u'unwatched')

        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 clearCache != u'':
            httpManager.ClearCache()
            return True

        if (showId <> u'' and episodeId == u''):
            return self.ShowEpisodes(showId, title)
        elif (category <> u''):
            return self.ShowCategory(category, title, order, page)
        elif (episodeId <> u''):
            (episodeNumber,
             seriesNumber) = mycgi.Params(u'episodeNumber', u'seriesNumber')
            return self.PlayVideoWithDialog(
                self.PlayEpisode, (showId, int(seriesNumber),
                                   int(episodeNumber), episodeId, title))
Esempio n. 2
0
    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()
Esempio n. 3
0
    def createNewListItem(self, episodeDetail):
        (infoLabels, thumbnail) = self.getInfolabelsAndLogo(episodeDetail)

        contextMenuItems = []
        if self.showWatched:
            if Watched().isWatched(episodeDetail.assetId):
                infoLabels['PlayCount'] = 1
                contextMenuItems.append(
                    (u'Mark as unwatched',
                     u"XBMC.RunPlugin(%s?unwatched=1&ep=%s)" %
                     (sys.argv[0], episodeDetail.assetId)))
            else:
                contextMenuItems.append(
                    (u'Mark as watched',
                     u"XBMC.RunPlugin(%s?watched=1&ep=%s)" %
                     (sys.argv[0], episodeDetail.assetId)))

        newListItem = xbmcgui.ListItem(infoLabels['Title'])
        newListItem.setThumbnailImage(thumbnail)
        newListItem.setInfo(u'video', infoLabels)

        if len(contextMenuItems) > 0:
            newListItem.addContextMenuItems(contextMenuItems)

        return newListItem
Esempio n. 4
0
    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
Esempio n. 5
0
    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
Esempio n. 6
0
    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()