Ejemplo 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))
Ejemplo n.º 2
0
    def ParseCommand(self, mycgi):
        (category, search, allShows, calendar, date, page, thumbnail,
         resume) = mycgi.Params(u'category', u'search', u'allShows',
                                u'calendar', u'date', u'page', u'thumbnail',
                                u'resume')
        self.log(
            u"category: %s, search: %s, allShows: %s, calendar: %s, date: %s, page: %s, thumbnail: %s, resume: %s"
            % (category, str(search), str(allShows), calendar, date, page,
               thumbnail, str(resume)), xbmc.LOGDEBUG)

        if search <> u'':
            return self.DoSearch()

        if category <> u'':
            return self.ShowCategory(category)

        if allShows <> u'':
            if thumbnail <> u'':
                return self.ListAToZ(thumbnail)
            else:
                return self.ListAToZ()

        if calendar <> u'':
            return self.ListCalendar()

        if date <> u'':
            return self.ListByDate(date)

        if page == u'':
            # "Can't find 'page' parameter "
            logException = LoggingException(logMessage=self.language(30030))
            # 'Cannot proceed', Error processing command
            logException.process(self.language(30755), self.language(30780),
                                 self.logLevel(xbmc.LOGERROR))
            return False

        self.log(u"page = %s" % page, xbmc.LOGDEBUG)
        page = mycgi.URLUnescape(page)
        self.log(u"mycgi.URLUnescape(page) = %s" % page, xbmc.LOGDEBUG)

        if u' ' in page:
            page = page.replace(u' ', u'%20')

        resumeFlag = False
        if resume <> u'':
            resumeFlag = True

        try:
            return self.PlayVideoWithDialog(self.PlayEpisode,
                                            (page, resumeFlag))

        except (Exception) as exception:
            if not isinstance(exception, LoggingException):
                exception = LoggingException.fromException(exception)

            # "Error playing or downloading episode %s"
            exception.addLogMessage(self.language(30051) % u"")
            # "Error processing video"
            exception.process(severity=self.logLevel(xbmc.LOGERROR))
            return False
Ejemplo n.º 3
0
    def ExecuteCommand(self, mycgi):
        logger.debug(u"mycgi.ParamCount(): " + unicode(mycgi.ParamCount()))

        (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')

        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()
Ejemplo n.º 4
0
def executeCommand():
    pluginHandle = int(sys.argv[1])
    success = False

    if (mycgi.EmptyQS()):
        success = ShowProviders()
    else:
        (providerName, clearCache,
         testForwardedIP) = mycgi.Params(u'provider', u'clearcache',
                                         u'testforwardedip')

        if clearCache != u'':
            httpManager.ClearCache()
            return True

        elif testForwardedIP != u'':
            provider = Provider()
            provider.addon = addon

            httpManager.SetDefaultHeaders(provider.GetHeaders())
            forwardedIP = provider.CreateForwardedForIP('0.0.0.0')

            return TestForwardedIP(forwardedIP)

        elif providerName != u'':
            log(u"providerName: " + providerName, xbmc.LOGDEBUG)
            if providerName <> u'':
                provider = providerfactory.getProvider(providerName)

                if provider is None:
                    # ProviderFactory return none for providerName: %s
                    logException = LoggingException(
                        language(30000) % providerName)
                    # 'Cannot proceed', Error processing provider name
                    logException.process(language(30755), language(30020),
                                         xbmc.LOGERROR)
                    return False

                if provider.initialise(httpManager, sys.argv[0], pluginHandle,
                                       addon, language, PROFILE_DATA_FOLDER,
                                       RESOURCE_PATH):
                    success = provider.ExecuteCommand(mycgi)
                    log(u"executeCommand done", xbmc.LOGDEBUG)
                """
				print cookiejar
				print 'These are the cookies we have received so far :'

				for index, cookie in enumerate(cookiejar):
					print index, '  :  ', cookie
				cookiejar.save() 
				"""

    return success
Ejemplo n.º 5
0
    def ParseCommand(self, mycgi):
        self.log(u"", xbmc.LOGDEBUG)
        (channel, logo, loggedInStr) = mycgi.Params( u'channel', u'logo', u'loggedIn') 
       
        if loggedInStr == u'1':
            self.loggedIn = True
            
        if channel <> u'':
            if logo == u'' and channel in channelToLogo:
                logo = channelToLogo[channel]
                    
            return self.PlayVideoWithDialog(self.PlayChannel, (channel, logo))

        return False
Ejemplo n.º 6
0
    def ParseCommand(self, mycgi):
        self.log(u"", xbmc.LOGDEBUG)

        (category, showId, episodeId, title, search, order, page, season,
         thumbnail, premiereDate,
         resume) = mycgi.Params(u'category', u'show', u'episodeId', u'title',
                                u'search', u'order', u'page', u'season',
                                u'thumbnail', u'premiereDate', u'resume')

        if (showId <> u'' and episodeId == u''):
            return self.ShowEpisodes(showId, title, season)
        elif (category <> u''):
            return self.ShowCategory(category, title, order, page)
        elif (episodeId <> u''):
            resumeFlag = False
            if resume <> u'':
                resumeFlag = True

            (episodeNumber,
             seriesNumber) = mycgi.Params(u'episodeNumber', u'seriesNumber')
            return self.PlayVideoWithDialog(
                self.PlayEpisode,
                (showId, seriesNumber, episodeNumber, episodeId, title,
                 thumbnail, premiereDate, resumeFlag))
Ejemplo n.º 7
0
    def ParseCommand(self, mycgi):
        (categories, category, search, date, episodeId, series, latest,
         popular, live) = mycgi.Params(u'categories', u'category', u'search',
                                       u'date', u'episodeId', u'series',
                                       u'latest', u'popular', u'live')

        category = category.decode(u'latin1')
        episodeId = episodeId.decode(u'latin1')
        series = series.decode(u'latin1')

        logger.debug(u"(category: %s, episodeId: %s, series: %s)" %
                     (type(category), type(episodeId), type(series)))

        if search <> u'':
            return self.DoSearch(search)

        if categories != '':
            return self.ShowCategories()

        if category != '':
            return self.ShowCategory(category)

        if latest != '':
            return self.ListLatest()

        if date <> u'':
            return self.ListByDate(date)

        if popular != '':
            return self.ListEpisodes(popularUrl, True)

        if episodeId != '' and series != '':
            return self.PlayVideoWithDialog(self.ShowEpisode,
                                            (episodeId, series, appNormal))

        if live != '':
            return self.PlayVideoWithDialog(self.PlayLiveTV, ())

        return False
Ejemplo n.º 8
0
    def ParseCommand(self, mycgi):
        (listshows, episodeId, listAvailable, search, page, live,
         resume) = mycgi.Params(u'listshows', u'episodeId', u'listavailable',
                                u'search', u'page', u'live', u'resume')
        self.log(u"", xbmc.LOGDEBUG)
        self.log(
            u"listshows: %s, episodeId %s, listAvailable %s, search %s, page %s, resume: %s"
            % (str(listshows), episodeId, str(listAvailable), str(search),
               page, str(resume)), xbmc.LOGDEBUG)

        if episodeId <> '':
            resumeFlag = False
            if resume <> u'':
                resumeFlag = True

            #return self.PlayEpisode(episodeId)
            return self.PlayVideoWithDialog(self.PlayEpisode,
                                            (episodeId, resumeFlag))

        if search <> '':
            if page == '':
                return self.DoSearch()
            else:
                return self.DoSearchQuery(queryUrl=urlRoot + page)

        if page == '':
            if live <> '':
                return self.ShowLiveMenu()

            # "Can't find 'page' parameter "
            logException = LoggingException(logMessage=self.language(30030))
            # 'Cannot proceed', Error processing command
            logException.process(self.language(30010), self.language(30780),
                                 self.logLevel(xbmcc.LOGERROR))
            return False

        page = page
        # TODO Test this
        self.log(u"page = %s" % page, xbmc.LOGDEBUG)
        #self.log(u"type(page): " + repr(type(page)), xbmc.LOGDEBUG)
        ##page = mycgi.URLUnescape(page)
        #self.log(u"page = %s" % page, xbmc.LOGDEBUG)
        #self.log(u"type(mycgi.URLUnescape(page)): " + repr(type(page)), xbmc.LOGDEBUG)
        #        self.log(u"mycgi.URLUnescape(page) = %s" % page, xbmc.LOGDEBUG)

        if u' ' in page:
            page = page.replace(u' ', u'%20')

        try:
            self.log(u"urlRoot: " + urlRoot + u", page: " + page)
            html = None
            html = self.httpManager.GetWebPage(urlRoot + page, 1800)
        except (Exception) as exception:
            if not isinstance(exception, LoggingException):
                exception = LoggingException.fromException(exception)

            if html is not None:
                msg = "html:\n\n%s\n\n" % html
                exception.addLogMessage(msg)

            # Error getting web page
            exception.addLogMessage(self.language(30050))
            exception.process(severity=self.logLevel(xbmc.LOGERROR))
            return False

        if live <> '':
            #return self.PlayLiveTV(html)
            return self.PlayVideoWithDialog(self.PlayLiveTV, (html, None))

        if listshows <> u'':
            return self.ListShows(html)

        if listAvailable <> u'':

            soup = BeautifulSoup(html)
            availableLink = soup.find('a', 'button-more-episodes')

            if availableLink is None:
                pattern = "/player/ie/show/(.+)/"
                match = re.search(pattern, html, re.DOTALL)

                if match is not None:
                    episodeId = match.group(1)
                    resumeFlag = False
                    if resume <> u'':
                        resumeFlag = True

                    return self.PlayVideoWithDialog(self.PlayEpisode,
                                                    (episodeId, resumeFlag))

            return self.ListAvailable(html)

        return self.ListSubMenu(html)
Ejemplo n.º 9
0
		# Error getting web page
		exception.addLogMessage("Error getting web page")
		exception.printLogMessages(logging.ERROR)
		return False


	
#==============================================================================
def executeCommand():
	success = False

	if ( mycgi.EmptyQS() ):
		success = ShowProviders()
        print success
	else:
		(providerName, clearCache, testForwardedIP) = mycgi.Params( u'provider', u'clearcache', u'testforwardedip' )

		if clearCache != u'':
			httpManager.ClearCache()
			return True
		
		elif testForwardedIP != u'':
			provider = Provider()

			httpManager.SetDefaultHeaders( provider.GetHeaders() )
			forwardedIP = provider.CreateForwardedForIP('0.0.0.0')
			
			return TestForwardedIP(forwardedIP)
			
		elif providerName != u'':
			logger.debug(u"providerName: " + providerName)