Пример #1
0
    def GetStreamUrl(self, key, url, playerId, contentRefId = None, contentId = None, streamType = "RTMP"):
        self.log("", xbmc.LOGDEBUG)
        try:
            self.amfResponse = None
            self.amfResponse = self.GetEpisodeInfo(key, url, playerId, contentRefId = contentRefId, contentId = contentId)
            name = self.amfResponse[u'name']
           
            self.log(u"Name field: " + name)
           
            preferredRate = self.GetBitRateSetting()
           
           
            defaultStreamUrl = self.amfResponse[u'programmedContent'][u'videoPlayer'][u'mediaDTO'][u'FLVFullLengthURL']

            self.log(u"defaultStreamUrl: %s" % defaultStreamUrl)
           
            if preferredRate is None and defaultStreamUrl.upper().startswith(streamType):
                return defaultStreamUrl 

            originalRenditions = self.amfResponse[u'programmedContent'][u'videoPlayer'][u'mediaDTO'][u'renditions']
            self.log(u"renditions:\n\n%s\n\n" % pformat(originalRenditions))

            renditions = []
            renditionsOther = []
            for rendition in originalRenditions:
                ### TODO Check if this upsets aertv/tg4...
                ###if rendition[u'encodingRate'] == 0:
                ###    continue
                
                if rendition['defaultURL'].upper().startswith(streamType):
                    renditions.append(rendition)
                else:
                    renditionsOther.append(rendition)
            
            if len(renditions) == 0:
                self.log(u"Unable to find stream of type '%s'" % streamType, xbmc.LOGWARNING)
                renditions = renditionsOther

            self.log(u"renditions: %s" % utils.drepr(renditions))
            bitrate = self.ChooseBitRate(preferredRate, renditions)

            if bitrate == None:
                return defaultStreamUrl
            
            return bitrate

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

            if self.amfResponse is not None:
                msg = "self.amfResponse:\n\n%s\n\n" % utils.drepr(self.amfResponse)
                exception.addLogMessage(msg)

            raise exception
Пример #2
0
    def AttemptLogin(self, values, logUrl = False):
        self.log(u"", xbmc.LOGDEBUG)
        try:
            loginJSONText = None
            loginJSON = None
            
            url = self.GetAPIUrl(values)

            loginJSONText = self.httpManager.GetWebPageDirect(url, logUrl = logUrl)
            loginJSON = _json.loads(loginJSONText)
            
            for key in loginJSON:
                self.log(u"loginJSON['%s'] exists" % key, xbmc.LOGDEBUG)
                
            if u'user' in loginJSON:
                self.log(u"loginJSON['user']", xbmc.LOGDEBUG)

                for key in loginJSON[u'user']:
                    if key == u'fname' or key == u'lname' or key == 'email':
                        self.log(u"loginJSON['user']['%s'] exists" % key, xbmc.LOGDEBUG)
                    else:
                        self.log(u"loginJSON['user']['%s'] = %s" % (key, utils.drepr(loginJSON[u'user'][key])), xbmc.LOGDEBUG)
                        
                         
            # Check for failed login
            if loginJSON[u'user'][u'login'] != True:
                # Show error message
                if u'status' in loginJSON[u'user']: 
                    statusMessage = loginJSON[u'user'][u'status']
                else:
                    statusMessage = u"None"
                
                    
                # 'AerTV login failed', 
                logException = LoggingException(self.language(30101))
                # "Status Message: %s
                logException.process(self.language(30102) % statusMessage, u"", xbmc.LOGDEBUG)

                return None
            
            self.log(u"AerTV successful login", xbmc.LOGDEBUG)
            return loginJSON
        except (Exception) as exception:
            if not isinstance(exception, LoggingException):
                exception = LoggingException.fromException(exception)

            if loginJSONText is not None:
                msg = u"loginJSONText:\n\n%s\n\n" % loginJSONText
                exception.addLogMessage(msg)
            
            if loginJSON is not None:
                msg = u"epgJSON:\n\n%s\n\n" % utils.drepr(loginJSON)
                exception.addLogMessage(msg)

            raise exception
Пример #3
0
    def AttemptLogin(self, values, logUrl = False):
        self.log(u"", xbmc.LOGDEBUG)
        try:
            loginJSONText = None
            loginJSON = None
            
            url = self.GetAPIUrl(values)

            loginJSONText = self.httpManager.GetWebPageDirect(url, logUrl = logUrl)
            loginJSON = _json.loads(loginJSONText)
            
            for key in loginJSON:
                self.log(u"loginJSON['%s'] exists" % key, xbmc.LOGDEBUG)
                
            if u'user' in loginJSON:
                self.log(u"loginJSON['user']", xbmc.LOGDEBUG)

                for key in loginJSON[u'user']:
                    if key == u'fname' or key == u'lname' or key == 'email':
                        self.log(u"loginJSON['user']['%s'] exists" % key, xbmc.LOGDEBUG)
                    else:
                        self.log(u"loginJSON['user']['%s'] = %s" % (key, utils.drepr(loginJSON[u'user'][key])), xbmc.LOGDEBUG)
                        
                         
            # Check for failed login
            if loginJSON[u'user'][u'login'] != True:
                # Show error message
                if u'status' in loginJSON[u'user']: 
                    statusMessage = loginJSON[u'user'][u'status']
                else:
                    statusMessage = u"None"
                
                    
                # 'AerTV login failed', 
                logException = LoggingException(self.language(30101))
                # "Status Message: %s
                logException.process(self.language(30102) % statusMessage, u"", xbmc.LOGDEBUG)

                return None
            
            self.log(u"AerTV successful login", xbmc.LOGDEBUG)
            return loginJSON
        except (Exception) as exception:
            if not isinstance(exception, LoggingException):
                exception = LoggingException.fromException(exception)

            if loginJSONText is not None:
                msg = u"loginJSONText:\n\n%s\n\n" % loginJSONText
                exception.addLogMessage(msg)
            
            if loginJSON is not None:
                msg = u"epgJSON:\n\n%s\n\n" % utils.drepr(loginJSON)
                exception.addLogMessage(msg)

            raise exception
Пример #4
0
    def GetStreamUrl(self, key, url, playerId, contentRefId = None, contentId = None, streamType = "RTMP"):
        logger.debug("")
        try:
            self.amfResponse = None
            self.amfResponse = self.GetEpisodeInfo(key, url, playerId, contentRefId = contentRefId, contentId = contentId)
            name = self.amfResponse[u'name']
           
            logger.info(u"Name field: " + name)
           
            preferredRate = self.GetBitRateSetting()
           
           
            defaultStreamUrl = self.amfResponse[u'programmedContent'][u'videoPlayer'][u'mediaDTO'][u'FLVFullLengthURL']

            logger.info(u"defaultStreamUrl: %s" % defaultStreamUrl)
           
            if preferredRate is None and defaultStreamUrl.upper().startswith(streamType):
                return defaultStreamUrl 

            originalRenditions = self.amfResponse[u'programmedContent'][u'videoPlayer'][u'mediaDTO'][u'renditions']
            logger.info(u"renditions: %s" % utils.drepr(originalRenditions))

            renditions = []
            renditionsOther = []
            for rendition in originalRenditions:
                if rendition[u'encodingRate'] == 0:
                    continue
                
                if rendition['defaultURL'].upper().startswith(streamType):
                    renditions.append(rendition)
                else:
                    renditionsOther.append(rendition)
            
            if len(renditions) == 0:
                logger.warning(u"Unable to find stream of type '%s'" % streamType)
                renditions = renditionsOther

            logger.info(u"renditions: %s" % utils.drepr(renditions))
            bitrate = self.ChooseBitRate(preferredRate, renditions)

            if bitrate == None:
                return defaultStreamUrl
            
            return bitrate

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

            if self.amfResponse is not None:
                msg = "self.amfResponse:\n\n%s\n\n" % utils.drepr(self.amfResponse)
                exception.addLogMessage(msg)

            raise exception
Пример #5
0
    def AddEpisodeToList(self, listItems, episode):
        self.log(u"", xbmc.LOGDEBUG)

        try:
            htmlparser = HTMLParser.HTMLParser()

            href = episode[u'href']
            title = htmlparser.unescape( episode.find(u'span', u"thumbnail-title").contents[0] )
            date = episode.find(u'span', u"thumbnail-date").contents[0]
            #description = ...
            thumbnail = episode.find(u'img', u'thumbnail')[u'src']

            newLabel = title + u", " + date

            newListItem = xbmcgui.ListItem( label=newLabel )
            newListItem.setThumbnailImage(thumbnail)

            if self.addon.getSetting( u'RTE_descriptions' ) == u'true':
                infoLabels = self.GetEpisodeInfo(self.GetEpisodeIdFromURL(href))
            else:
                infoLabels = {u'Title': title, u'Plot': title}

            newListItem.setInfo(u'video', infoLabels)
            newListItem.setProperty(u"Video", u"true")
            #newListItem.setProperty('IsPlayable', 'true')

            self.log(u"label == " + newLabel, xbmc.LOGDEBUG)

            if u"episodes available" in date:
                url = self.GetURLStart()  + u'&listavailable=1' + u'&page=' + mycgi.URLEscape(href)
                folder = True
            else:
                newListItem.setProperty("Video", "true")
                #newListItem.setProperty('IsPlayable', 'true')

                folder = False
                match = re.search( u"/player/[^/]+/show/([0-9]+)/", href )
                if match is None:
                    self.log(u"No show id found in page href: '%s'" % href, xbmc.LOGWARNING)
                    return

                episodeId = match.group(1)

                url = self.GetURLStart() + u'&episodeId=' +  mycgi.URLEscape(episodeId)

                if self.resumeEnabled:
                    resumeKey = episodeId
                    self.ResumeListItem(url, newLabel, newListItem, resumeKey)

            listItems.append( (url, newListItem, folder) )
        except (Exception) as exception:
            if not isinstance(exception, LoggingException):
                exception = LoggingException.fromException(exception)

            msg = u"episode:\n\n%s\n\n" % utils.drepr(episode)
            exception.addLogMessage(msg)

            # Error getting episode details
            exception.addLogMessage(self.language(30099))
            exception.process(self.logLevel(xbmc.LOGWARNING))
Пример #6
0
    def GetEpisodeInfo(self, key, url, playerId, contentRefId = None, contentId = None):
        self.log(u'ContentRefId:' + str(contentRefId) + u'contentId:' + str(contentId) + u', URL:' + url + u', playerId: ' + unicode(playerId) + u', key: ' + unicode(key) )  
        self.log(u"RemotingService", xbmc.LOGDEBUG)
        
        try:            
            if self.proxyConfig is not None: 
                self.proxyConfig.Enable()
            
            serviceName = 'com.brightcove.experience.ExperienceRuntimeFacade'
            service = self.GetRemotingService(key, serviceName)

            hashValue = self.GetAmfClassHash(serviceName)
            self.log(u'hashValue:' + str(hashValue))
         
            pyamf.register_class(ViewerExperienceRequest, 'com.brightcove.experience.ViewerExperienceRequest')
            pyamf.register_class(ContentOverride, 'com.brightcove.experience.ContentOverride')
            content_override = ContentOverride(contentRefId = contentRefId, contentId = contentId)
            viewer_exp_req = ViewerExperienceRequest(url, [content_override], int(playerId), key)
            
            self.log( content_override.tostring() )
            self.log( viewer_exp_req.tostring() )
    
            # Make the request
            response = service.getDataForExperience(hashValue, viewer_exp_req)
            
            self.log(u"response: " + utils.drepr(response), xbmc.LOGDEBUG)
        finally:
            if self.proxyConfig is not None: 
                self.proxyConfig.Disable()
    
        return response
Пример #7
0
    def GetQSData(self, vidId, bitlyUrl, js):
        self.log("", xbmc.LOGDEBUG)
        
        try:
            pattern = u"function (createPlayerHtml.+?)^}"
            match=re.search(pattern, js, re.MULTILINE | re.DOTALL)
            createPlayerHtml = match.group(1)
            
            bc_params = {}
            pattern = u"[^/][^/]\s+(bc_params\s*\[.+?\]\s*=.+?);"
            paramAppends = re.findall(pattern, createPlayerHtml)
            
            for paramAppend in paramAppends:
                paramAppend = paramAppend.replace(u'true', u'True')
                paramAppend = paramAppend.replace(u'["', u'[u"')
                paramAppend = paramAppend.replace(u'= "', u'= u"')
                self.log(u"paramAppend: %s" % paramAppend, xbmc.LOGDEBUG)
                exec(paramAppend)
            
            if bc_params < 10:
                self.log(self.language(30036), xbmc.LOGWARNING)
                self.log(utils.drepr(bc_params), xbmc.LOGDEBUG)
                return self.GetDefaultQSData(vidId, bitlyUrl)
        except (Exception) as exception:
            if not isinstance(exception, LoggingException):
                exception = LoggingException.fromException(exception)

            # Unable to determine qsdata. Using default values.
            exception.addLogMessage(self.language(40600))
            exception.process(severity = xbmc.LOGWARNING)

            return self.GetDefaultQSData(vidId, bitlyUrl)
            
        return bc_params
Пример #8
0
    def GetEpisodeInfo(self, key, url, playerId, contentRefId = None, contentId = None):
        logger.debug(u"RemotingService")
        
        try:            
            if self.proxyConfig is not None: 
                self.proxyConfig.Enable()
            
            serviceName = 'com.brightcove.experience.ExperienceRuntimeFacade'
            service = self.GetRemotingService(key, serviceName)

            hashValue = self.GetAmfClassHash(serviceName)
            logger.info(u'hashValue:' + str(hashValue))
         
            pyamf.register_class(ViewerExperienceRequest, 'com.brightcove.experience.ViewerExperienceRequest')
            pyamf.register_class(ContentOverride, 'com.brightcove.experience.ContentOverride')
            content_override = ContentOverride(contentRefId = contentRefId, contentId = contentId)
            viewer_exp_req = ViewerExperienceRequest(url, [content_override], int(playerId), key)
            
            # Make the request
            response = service.getDataForExperience(hashValue, viewer_exp_req)
            
            logger.debug(u"response: " + utils.drepr(response))
        finally:
            if self.proxyConfig is not None: 
                self.proxyConfig.Disable()
    
        return response
Пример #9
0
    def PostBinary(self, site, path, data, headers = None):
        logger.debug(u"(%s)" % (site + path))
        
        try:
            if self.proxyConfig is not None: 
                self.proxyConfig.Enable()
                
            repeat = True
            firstTime = True
    
            while repeat:
                repeat = False
                try:
                    if site.startswith(u"http://"):
                        site = site[7:]
                    
                    headers = self.PrepareHeaders(headers)
    
                    logger.info(u"headers: " + repr(headers))
                    
                    conn = httplib.HTTPConnection(site)
                    conn.request("POST", path, data, headers)
                    response = conn.getresponse()
                except ( httplib.HTTPException ) as exception:
                    logger.error( u'HTTPError: ' + unicode(exception))
                    raise exception
                except ( socket.timeout ) as exception:
                    logger.error( u'Timeout exception: ' + unicode(exception))
                    if firstTime:
#                        self.log ( u'Timeout exception: ' + unicode(exception), xbmc.LOGERROR )
#                        xbmc.executebuiltin(u'XBMC.Notification(%s, %s)' % (u'Socket timed out', 'Trying again'))
                        repeat = True
                    else:
                        """
                        The while loop is normally only processed once.
                        When a socket timeout happens it executes twice.
                        The following code executes after the second timeout.
                        """
                        logger.error("if you see this msg often consider changing your Socket Timeout settings")
                        raise exception
        
                    firstTime = False
        except ( Exception ) as exception:
            raise exception
        finally:
            if self.proxyConfig is not None: 
                self.proxyConfig.Disable()
    
        logger.debug(u"response.status, response.reason: " + unicode(response.status) + ', ' + response.reason)
        logger.debug(u"response.getheaders(): " + utils.drepr(response.getheaders()))
        
        if response.status <> 200:
            return self.PostBinaryRequestsModule(site, path, data, headers)
        
        if response.getheader(u'content-encoding', u'') == u'gzip':
            logger.debug(u"gzipped page")
            gzipper = gzip.GzipFile(fileobj=StringIO.StringIO(response.read()))
            return gzipper.read()
        
        return response.read()
Пример #10
0
    def ShowVinesByTag(self, page, label):
        self.log("page: " + repr(page))
        url = urlRoot + page
        
        try:
            jsonText = None
            listItems = []
            html = self.httpManager.GetWebPageDirect(url)

            pattern = "<script.*>\s*var\s*vines\s*=\s*(\[.*\])\s*;\s*</script>"
            match = re.search(pattern, html, re.MULTILINE | re.DOTALL)

            jsonText = match.group(1)
    
            jsonData = _json.loads(jsonText)

            soup = BeautifulSoup(html)
            
            previous = soup.find('li', 'previous')
            next = soup.find('li', 'next')
            
            if previous:
                listItem = xbmcgui.ListItem("<< " + previous.text)
                url = self.GetURLStart() + u'&page=' + previous.a['href'] 
                listItems.append((url, listItem, True))
            else:
                self.AddOrderLinks(soup, listItems)
                
            for vineData in jsonData:
                url = vineData['vineVideoURL']
                icon = vineData['vineImageURL']
              
                infoLabels = {u'Title': vineData['vineDescription'], u'Plot': vineData['vineDescription']}
                
                self.log("infoLabels: " + utils.drepr(infoLabels))
                listItem = xbmcgui.ListItem(vineData['vineDescription'], iconImage = icon )
                listItem.setInfo(u'video', infoLabels)
                listItems.append((url, listItem))
            
            if next:
                listItem = xbmcgui.ListItem(">> " + next.text)
                url = self.GetURLStart() + u'&page=' + next.a['href']
                listItems.append((url, listItem, True))
                
            xbmcplugin.addDirectoryItems( handle=self.pluginHandle, items=listItems )
            xbmcplugin.endOfDirectory( handle=self.pluginHandle, succeeded=True )

            self.log( "listItems: " + repr(listItems)) 

        except (Exception) as exception:
            exception = LoggingException.fromException(exception)

            if jsonText is not None:
                msg = u"jsonText:\n\n%s\n\n" % jsonText
                exception.addLogMessage(msg)
                
            # Error processing web page
            exception.addLogMessage(self.language(30780))
            exception.process(self.language(30280), self.language(30780), severity = self.logLevel( xbmc.LOGERROR ))
Пример #11
0
 def LogLoginInfo(self, loginJSON):
     self.log(u'is_paid_subscriber: %s' % utils.getDictionaryValue(loginJSON[u'user'], u'is_paid_subscriber'))
     self.log(u'login: %s' % utils.getDictionaryValue(loginJSON[u'user'], u'login'))
     self.log(u'status: %s' % utils.getDictionaryValue(loginJSON[u'user'], u'status'))
     
     packages = utils.getDictionaryValue(loginJSON[u'user'], u'packages')
     
     if packages:
         self.log(u'status: %s' % utils.drepr(packages))
Пример #12
0
 def LogLoginInfo(self, loginJSON):
     self.log(u'is_paid_subscriber: %s' % utils.getDictionaryValue(loginJSON[u'user'], u'is_paid_subscriber'))
     self.log(u'login: %s' % utils.getDictionaryValue(loginJSON[u'user'], u'login'))
     self.log(u'status: %s' % utils.getDictionaryValue(loginJSON[u'user'], u'status'))
     
     packages = utils.getDictionaryValue(loginJSON[u'user'], u'packages')
     
     if packages:
         self.log(u'status: %s' % utils.drepr(packages))
Пример #13
0
    def GetEPGDetails(self, channelEntry, startCutOff, endCutOff):
        detail = [channelEntry[u'channel'][u'logo']]
        videoCount = 0

        self.log(u"startCutOff: %s, endCutOff: %s" % (repr(startCutOff), repr(endCutOff)), xbmc.LOGDEBUG)
        for video in channelEntry[u'videos']:
            try:
                self.log(u"repr(datetime): " + repr(datetime))
                self.log(u"video: " + utils.drepr(video))
                self.log(u"video['starttime']: " + video[u'starttime'])

                try:
                    startTime = datetime.strptime(video[u'starttime'], TIME_FORMAT)
                    endTime = datetime.strptime(video[u'endtime'], TIME_FORMAT)
                except TypeError:
                    startTime = datetime.fromtimestamp(time.mktime(time.strptime(video[u'starttime'], TIME_FORMAT)))
                    endTime = datetime.fromtimestamp(time.mktime(time.strptime(video[u'endtime'], TIME_FORMAT)))
                    
                if startTime >= startCutOff and startTime < endCutOff:
                    self.log(u"startTime >= startCutOff and startTime < endCutOff", xbmc.LOGDEBUG)
                    videoCount = videoCount + 1
    
                    if endTime > endCutOff:
                        self.log(u"endTime > endCutOff", xbmc.LOGDEBUG)
                        # Add "Now ... Ends at ..." if count is 0, or "Next..."
                        detail.append(video) 
                        break
                    else:
                        self.log(u"endTime <= endCutOff", xbmc.LOGDEBUG)
                        # Add Now .../Next ... depending on count
                        detail.append(video) 
    
                elif startTime < startCutOff and endTime > startCutOff:
                    self.log(u"startTime < startCutOff and endTime > startCutOff", xbmc.LOGDEBUG)
                    videoCount = videoCount + 1
    
                    # Add Now .../Next ... depending on count
                    detail.append(video)
                else:
                    self.log(u"Ignoring video: " + video[u'name'])
                    
                if (videoCount > 1):
                    break
            except (Exception) as exception:
                if not isinstance(exception, LoggingException):
                    exception = LoggingException.fromException(exception)
    
                self.log(u"video: %s" % repr(video))
                
                # Error processing EPG entry
                exception.addLogMessage(self.language(30027))
                exception.printLogMessages(severity = xbmc.LOGWARNING)

        return detail
Пример #14
0
    def GetEPGDetails(self, channelEntry, startCutOff, endCutOff):
        detail = [channelEntry[u'channel'][u'logo']]
        videoCount = 0

        self.log(u"startCutOff: %s, endCutOff: %s" % (repr(startCutOff), repr(endCutOff)), xbmc.LOGDEBUG)
        for video in channelEntry[u'videos']:
            try:
                self.log(u"repr(datetime): " + repr(datetime))
                self.log(u"video: " + utils.drepr(video))
                self.log(u"video['starttime']: " + video[u'starttime'])

                try:
                    startTime = datetime.strptime(video[u'starttime'], TIME_FORMAT)
                    endTime = datetime.strptime(video[u'endtime'], TIME_FORMAT)
                except TypeError:
                    startTime = datetime.fromtimestamp(time.mktime(time.strptime(video[u'starttime'], TIME_FORMAT)))
                    endTime = datetime.fromtimestamp(time.mktime(time.strptime(video[u'endtime'], TIME_FORMAT)))
                    
                if startTime >= startCutOff and startTime < endCutOff:
                    self.log(u"startTime >= startCutOff and startTime < endCutOff", xbmc.LOGDEBUG)
                    videoCount = videoCount + 1
    
                    if endTime > endCutOff:
                        self.log(u"endTime > endCutOff", xbmc.LOGDEBUG)
                        # Add "Now ... Ends at ..." if count is 0, or "Next..."
                        detail.append(video) 
                        break
                    else:
                        self.log(u"endTime <= endCutOff", xbmc.LOGDEBUG)
                        # Add Now .../Next ... depending on count
                        detail.append(video) 
    
                elif startTime < startCutOff and endTime > startCutOff:
                    self.log(u"startTime < startCutOff and endTime > startCutOff", xbmc.LOGDEBUG)
                    videoCount = videoCount + 1
    
                    # Add Now .../Next ... depending on count
                    detail.append(video)
                else:
                    self.log(u"Ignoring video: " + video[u'name'])
                    
                if (videoCount > 1):
                    break
            except (Exception) as exception:
                if not isinstance(exception, LoggingException):
                    exception = LoggingException.fromException(exception)
    
                self.log(u"video: %s" % repr(video))
                
                # Error processing EPG entry
                exception.addLogMessage(self.language(30027))
                exception.printLogMessages(severity = xbmc.LOGWARNING)

        return detail
Пример #15
0
    def GetHttpLibResponse(self, site, path, headers = None):
        self.log(u"(%s)" % (site + path), xbmc.LOGDEBUG)

        try:
            if self.proxyConfig is not None: 
                self.proxyConfig.Enable()
            repeat = True
            firstTime = True
            addon = sys.modules["__main__"].addon
    
            while repeat:
                repeat = False
                try:
                    if site.startswith("http://"):
                        site = site[7:]
                    
                    headers = self.PrepareHeaders(addon, headers)
    
                    self.log("headers: " + repr(headers))
                    
                    conn = httplib.HTTPConnection(site)
                    conn.request("GET", path, headers = headers)
                    #conn.putheader('Connection','Keep-Alive')
                    response = conn.getresponse()
                except ( httplib.HTTPException ) as exception:
                    self.log ( u'HTTPError: ' + unicode(exception), xbmc.LOGERROR)
                    raise exception
                except ( socket.timeout ) as exception:
                    self.log ( u'Timeout exception: ' + unicode(exception), xbmc.LOGERROR )
                    if firstTime:
                        self.log ( u'Timeout exception: ' + unicode(exception), xbmc.LOGERROR )
                        xbmc.executebuiltin(u'XBMC.Notification(%s, %s)' % (u'Socket timed out', 'Trying again'))
                        repeat = True
                    else:
                        """
                        The while loop is normally only processed once.
                        When a socket timeout happens it executes twice.
                        The following code executes after the second timeout.
                        """
                        self.log ( u'Timeout exception: ' + unicode(exception) + ", if you see this msg often consider changing your Socket Timeout settings", xbmc.LOGERROR )
                        raise exception
        
                    firstTime = False
        except ( Exception ) as exception:
            raise exception
        finally:
            if self.proxyConfig is not None: 
                self.proxyConfig.Disable()

        self.log (u"response.status, response.reason: " + unicode(response.status) + ', ' + response.reason, xbmc.LOGDEBUG)
        self.log (u"response.getheaders(): " + utils.drepr(response.getheaders()), xbmc.LOGDEBUG)
        
        return response
Пример #16
0
    def GetHttpLibResponse(self, site, path, headers = None):
        logger.debug(u"(%s)" % (site + path))

        try:
            if self.proxyConfig is not None: 
                self.proxyConfig.Enable()
            repeat = True
            firstTime = True
    
            while repeat:
                repeat = False
                try:
                    if site.startswith("http://"):
                        site = site[7:]
                    
                    headers = self.PrepareHeaders(headers)
    
                    logger.info("headers: " + repr(headers))
                    
                    conn = httplib.HTTPConnection(site)
                    conn.request("GET", path, headers = headers)
                    #conn.putheader('Connection','Keep-Alive')
                    response = conn.getresponse()
                except ( httplib.HTTPException ) as exception:
                    logger.error( u'HTTPError: ' + unicode(exception))
                    raise exception
                except ( socket.timeout ) as exception:
                    logger.error( u'Timeout exception: ' + unicode(exception))
                    if firstTime:
#                        self.log ( u'Timeout exception: ' + unicode(exception), xbmc.LOGERROR )
#                        xbmc.executebuiltin(u'XBMC.Notification(%s, %s)' % (u'Socket timed out', 'Trying again'))
                        repeat = True
                    else:
                        """
                        The while loop is normally only processed once.
                        When a socket timeout happens it executes twice.
                        The following code executes after the second timeout.
                        """
                        logger.error( 'if you see this msg often consider changing your Socket Timeout settings')
                        raise exception
        
                    firstTime = False
        except ( Exception ) as exception:
            raise exception
        finally:
            if self.proxyConfig is not None: 
                self.proxyConfig.Disable()

        logger.debug(u"response.status, response.reason: " + unicode(response.status) + ', ' + response.reason)
        logger.debug(u"response.getheaders(): " + utils.drepr(response.getheaders()))
        
        return response
Пример #17
0
    def ShowRootMenu(self):
        self.log(u"", xbmc.LOGDEBUG)
        
        try:
            channels = None
            epgJSON = None 
            
            channels = self.GetAvailableChannels()
            
            if self.addon.getSetting( u'AerTV_show_epg' ) <> u'false':
                values = [{u'api':u'epg'}, {u'type':u'basic'}]
                url = self.GetAPIUrl(values)
                
                epgJSONText = self.httpManager.GetWebPage(url, 300)
                
                self.log(u"epgJSONText: \n\n%s\n\n" % epgJSONText, xbmc.LOGDEBUG)
                
                epgJSON = _json.loads(epgJSONText)
                
                return self.ShowEPG(channels, epgJSON)
            else:
                return self.ShowChannelList(channels)
        
        except (Exception) as exception:
            if not isinstance(exception, LoggingException):
                exception = LoggingException.fromException(exception)

            if epgJSON is not None:
                msg=u"epgJSON:\n\n%s\n\n" % utils.drepr(epgJSON)
                exception.addLogMessage(msg)

            if channels is not None:
                msg=u"channels:\n\n%s\n\n" % utils.drepr(channels)
                exception.addLogMessage(msg)

            # Cannot show root menu
            exception.addLogMessage(self.language(30010))
            exception.process(severity = self.logLevel(xbmc.LOGERROR))
            return False
Пример #18
0
 def do_vquery(self, q):
     """
     See query.
     """
     results = self._query(q)
     if results is None:
         return
     if len(results) == 0:
         print 'No results.'
         return
     results = [(b.pop('$val'), b) for b in results]
     for val, b in sorted(results):
         print _repr(val), 'where', drepr(b)
     print
Пример #19
0
Файл: repl.py Проект: nwf/dyna
 def do_vquery(self, q):
     """
     See query.
     """
     results = self._query(q)
     if results is None:
         return
     if len(results) == 0:
         print "No results."
         return
     results = [(b.pop("$val"), b) for b in results]
     for val, b in sorted(results):
         print _repr(val), "where", drepr(b)
     print
Пример #20
0
    def AddSegments(self, playList):
        self.log("", xbmc.LOGDEBUG)
        self.amfResponse = None
        if self.totalParts < 2:
            return

        title = self.addon.getAddonInfo('name')
        icon = self.addon.getAddonInfo('icon')
        msg = self.language(30097) # Adding more parts
        xbmc.executebuiltin('XBMC.Notification(%s, %s, 5000, %s)' % (title, msg, icon))

        self.log("Find videos parts for refence Id %s" % self.referenceId, xbmc.LOGDEBUG)
        for partNumber in range(2, self.totalParts + 1):
            try:
                self.amfResponse = None
                self.log("Getting part %d" % partNumber, xbmc.LOGDEBUG)
                partReference = self.referenceId[:-1] + unicode(partNumber)
                mediaDTO = self.FindMediaByReferenceId(self.playerKey, self.playerId, partReference, self.publisherId)

                (infoLabels, logo, rtmpVar, defaultFilename) = self.GetPlayListDetailsFromAMF(mediaDTO, appNormal, self.episodeId, live = False)

                listItem = self.CreateListItem(infoLabels, logo) 
                url = rtmpVar.getPlayUrl()

                if self.GetPlayer(None, None, None).isPlaying():
                    playList.add(url, listItem)
        
            except (Exception) as exception:
                if not isinstance(exception, LoggingException):
                    exception = LoggingException.fromException(exception)
                    
                if self.amfResponse is not None:
                    msg = "self.amfResponse:\n\n%s\n\n" % utils.drepr(self.amfResponse)
                    exception.addLogMessage(msg)

                # Error processing 
                exception.addLogMessage(self.language(30197))

                # Error playing or downloading episode %s
                exception.process('' , '', self.logLevel(xbmc.LOGDEBUG))
Пример #21
0
    def FindMediaByReferenceId(self, key, playerId, referenceId, pubId):
        self.log("", xbmc.LOGDEBUG)
        
        try:            
            if self.proxyConfig is not None: 
                self.proxyConfig.Enable()

            serviceName = 'com.brightcove.player.runtime.PlayerMediaFacade'
            service = self.GetRemotingService(key, serviceName)

            hashValue = self.GetAmfClassHash(serviceName)
    
            self.log(u'hashValue:' + str(hashValue))
     
            response = service.findMediaByReferenceId(hashValue, int(playerId), referenceId, pubId)
            
            self.log(u"response: " + utils.drepr(response), xbmc.LOGDEBUG)

        finally:
            if self.proxyConfig is not None: 
                self.proxyConfig.Disable()
    
        return response
Пример #22
0
    def FindMediaByReferenceId(self, key, playerId, referenceId, pubId):
        logger.debug("")
        
        try:            
            if self.proxyConfig is not None: 
                self.proxyConfig.Enable()

            serviceName = 'com.brightcove.player.runtime.PlayerMediaFacade'
            service = self.GetRemotingService(key, serviceName)

            hashValue = self.GetAmfClassHash(serviceName)
    
            logger.info(u'hashValue:' + str(hashValue))
     
            response = service.findMediaByReferenceId(hashValue, int(playerId), referenceId, pubId)
            
            logger.debug(u"response: " + utils.drepr(response))

        finally:
            if self.proxyConfig is not None: 
                self.proxyConfig.Disable()
    
        return response
Пример #23
0
    def PostBinaryRequestsModule(self, site, path, data, headers=None):
        try:
            import requests
        except:
            self.log(u"Can't import requests module", xbmc.LOGDEBUG)
            return None

        self.log(u"(%s)" % (site + path), xbmc.LOGDEBUG)

        try:
            if self.proxyConfig is not None:
                self.proxyConfig.Enable()

            repeat = True
            firstTime = True
            addon = sys.modules[u"__main__"].addon

            while repeat:
                repeat = False
                try:
                    url = "http://" + site + path
                    headers = self.PrepareHeaders(addon, headers)

                    self.log(u"headers: " + repr(headers))
                    response = requests.post(url, data=data, headers=headers)

                except (requests.exceptions.RequestException) as exception:
                    self.log(u'RequestException: ' + unicode(exception),
                             xbmc.LOGERROR)
                    raise exception
                except (requests.exceptions.ConnectionError) as exception:
                    self.log(u'ConnectionError: ' + unicode(exception),
                             xbmc.LOGERROR)
                    raise exception
                except (requests.exceptions.HTTPError) as exception:
                    self.log(u'HTTPError: ' + unicode(exception),
                             xbmc.LOGERROR)
                    raise exception
                except (requests.exceptions.URLRequired) as exception:
                    self.log(u'URLRequired: ' + unicode(exception),
                             xbmc.LOGERROR)
                    raise exception
                except (requests.exceptions.TooManyRedirects) as exception:
                    self.log(u'TooManyRedirects: ' + unicode(exception),
                             xbmc.LOGERROR)
                    raise exception
                except (requests.exceptions.Timeout) as exception:
                    self.log(u'Timeout exception: ' + unicode(exception),
                             xbmc.LOGERROR)
                    if firstTime:
                        self.log(u'Timeout exception: ' + unicode(exception),
                                 xbmc.LOGERROR)
                        xbmc.executebuiltin(
                            u'XBMC.Notification(%s, %s)' %
                            (u'Socket timed out', 'Trying again'))
                        repeat = True
                    else:
                        """
                        The while loop is normally only processed once.
                        When a socket timeout happens it executes twice.
                        The following code executes after the second timeout.
                        """
                        self.log(
                            u'Timeout exception: ' + unicode(exception) +
                            ", if you see this msg often consider changing your Socket Timeout settings",
                            xbmc.LOGERROR)
                        raise exception

                    firstTime = False
        except (Exception) as exception:
            raise exception
        finally:
            if self.proxyConfig is not None:
                self.proxyConfig.Disable()

        self.log(
            u"response.status, response.reason: " +
            unicode(response.status_code) + ', ' + response.reason,
            xbmc.LOGDEBUG)
        self.log(u"response.getheaders(): " + utils.drepr(response.headers),
                 xbmc.LOGDEBUG)

        response.raise_for_status()
        """
        if response.getheader(u'content-encoding', u'') == u'gzip':
            self.log (u"gzipped page", xbmc.LOGDEBUG)
            gzipper = gzip.GzipFile(fileobj=StringIO.StringIO(response.read()))
            return gzipper.read()
        """

        return response.content
Пример #24
0
 def PostBinaryRequestsModule(self, site, path, data, headers = None):
     try:
         import requests
     except:
         self.log(u"Can't import requests module", xbmc.LOGDEBUG)
         return None
     
     self.log(u"(%s)" % (site + path), xbmc.LOGDEBUG)
     
     try:
         if self.proxyConfig is not None: 
             self.proxyConfig.Enable()
             
         repeat = True
         firstTime = True
         addon = sys.modules[u"__main__"].addon
 
         while repeat:
             repeat = False
             try:
                 url = "http://" + site + path
                 headers = self.PrepareHeaders(addon, headers)
 
                 self.log(u"headers: " + repr(headers))
                 response = requests.post(url, data = data, headers = headers)
                 
             except ( requests.exceptions.RequestException ) as exception:
                 self.log ( u'RequestException: ' + unicode(exception), xbmc.LOGERROR)
                 raise exception
             except ( requests.exceptions.ConnectionError ) as exception:
                 self.log ( u'ConnectionError: ' + unicode(exception), xbmc.LOGERROR)
                 raise exception
             except ( requests.exceptions.HTTPError ) as exception:
                 self.log ( u'HTTPError: ' + unicode(exception), xbmc.LOGERROR)
                 raise exception
             except ( requests.exceptions.URLRequired ) as exception:
                 self.log ( u'URLRequired: ' + unicode(exception), xbmc.LOGERROR)
                 raise exception
             except ( requests.exceptions.TooManyRedirects ) as exception:
                 self.log ( u'TooManyRedirects: ' + unicode(exception), xbmc.LOGERROR)
                 raise exception
             except ( requests.exceptions.Timeout ) as exception:
                 self.log ( u'Timeout exception: ' + unicode(exception), xbmc.LOGERROR )
                 if firstTime:
                     self.log ( u'Timeout exception: ' + unicode(exception), xbmc.LOGERROR )
                     xbmc.executebuiltin(u'XBMC.Notification(%s, %s)' % (u'Socket timed out', 'Trying again'))
                     repeat = True
                 else:
                     """
                     The while loop is normally only processed once.
                     When a socket timeout happens it executes twice.
                     The following code executes after the second timeout.
                     """
                     self.log ( u'Timeout exception: ' + unicode(exception) + ", if you see this msg often consider changing your Socket Timeout settings", xbmc.LOGERROR )
                     raise exception
     
                 firstTime = False
     except ( Exception ) as exception:
         raise exception
     finally:
         if self.proxyConfig is not None: 
             self.proxyConfig.Disable()
 
     self.log (u"response.status, response.reason: " + unicode(response.status_code) + ', ' + response.reason, xbmc.LOGDEBUG)
     self.log (u"response.getheaders(): " + utils.drepr(response.headers), xbmc.LOGDEBUG)
     
     response.raise_for_status()
 
     """
     if response.getheader(u'content-encoding', u'') == u'gzip':
         self.log (u"gzipped page", xbmc.LOGDEBUG)
         gzipper = gzip.GzipFile(fileobj=StringIO.StringIO(response.read()))
         return gzipper.read()
     """
     
     return response.content
Пример #25
0
 def PostBinary(self, site, path, data, headers = None):
     self.log(u"(%s)" % (site + path), xbmc.LOGDEBUG)
     
     try:
         if self.proxyConfig is not None: 
             self.proxyConfig.Enable()
             
         repeat = True
         firstTime = True
         addon = sys.modules[u"__main__"].addon
 
         while repeat:
             repeat = False
             try:
                 if site.startswith(u"http://"):
                     site = site[7:]
                 
                 headers = self.PrepareHeaders(addon, headers)
 
                 self.log(u"headers: " + repr(headers))
                 
                 conn = httplib.HTTPConnection(site)
                 conn.request("POST", path, data, headers)
                 response = conn.getresponse()
             except ( httplib.HTTPException ) as exception:
                 self.log ( u'HTTPError: ' + unicode(exception), xbmc.LOGERROR)
                 raise exception
             except ( socket.timeout ) as exception:
                 self.log ( u'Timeout exception: ' + unicode(exception), xbmc.LOGERROR )
                 if firstTime:
                     self.log ( u'Timeout exception: ' + unicode(exception), xbmc.LOGERROR )
                     xbmc.executebuiltin(u'XBMC.Notification(%s, %s)' % (u'Socket timed out', 'Trying again'))
                     repeat = True
                 else:
                     """
                     The while loop is normally only processed once.
                     When a socket timeout happens it executes twice.
                     The following code executes after the second timeout.
                     """
                     self.log ( u'Timeout exception: ' + unicode(exception) + ", if you see this msg often consider changing your Socket Timeout settings", xbmc.LOGERROR )
                     raise exception
     
                 firstTime = False
     except ( Exception ) as exception:
         raise exception
     finally:
         if self.proxyConfig is not None: 
             self.proxyConfig.Disable()
 
     self.log (u"response.status, response.reason: " + unicode(response.status) + ', ' + response.reason, xbmc.LOGDEBUG)
     self.log (u"response.getheaders(): " + utils.drepr(response.getheaders()), xbmc.LOGDEBUG)
     
     if response.status <> 200:
         return self.PostBinaryRequestsModule(site, path, data, headers)
     
     if response.getheader(u'content-encoding', u'') == u'gzip':
         self.log (u"gzipped page", xbmc.LOGDEBUG)
         gzipper = gzip.GzipFile(fileobj=StringIO.StringIO(response.read()))
         return gzipper.read()
     
     return response.read()
Пример #26
0
    def GetHTTPResponse(self, url, values=None, headers=None, logUrl=True):
        global lastCode

        if logUrl:
            self.log(u"url: " + url, xbmc.LOGDEBUG)

        try:
            if self.proxyConfig is not None:
                self.proxyConfig.Enable()

            repeat = True
            firstTime = True
            addon = sys.modules["__main__"].addon

            while repeat:
                repeat = False
                try:
                    # Test socket.timeout
                    #raise socket.timeout
                    postData = None
                    if values is not None:
                        postData = urllib.urlencode(values)
                        self.log("postData: " + repr(postData))

                    headers = self.PrepareHeaders(addon, headers)

                    self.log("headers: " + repr(headers), xbmc.LOGDEBUG)

                    request = urllib2.Request(url, postData, headers)
                    response = urllib2.urlopen(request)
                    """
                    self.log( 'Here are the headers of the page :', xbmc.LOGDEBUG )
                    self.log( handle.info(), xbmc.LOGDEBUG )
                    cookiejar = sys.modules["__main__"].cookiejar
                    self.log( cookiejar, xbmc.LOGDEBUG )
                    self.log( 'These are the cookies we have received so far :', xbmc.LOGDEBUG )

                    for index, cookie in enumerate(cookiejar):
                        self.log( index + '  :  ' + cookie, xbmc.LOGDEBUG )
                    cookiejar.save(COOKIE_PATH)
                    """
                except (urllib2.HTTPError) as err:
                    self.log(u'HTTPError: ' + unicode(err), xbmc.LOGERROR)
                    lastCode = err.code
                    self.log(u"lastCode: " + unicode(lastCode), xbmc.LOGDEBUG)
                    raise err
                except (urllib2.URLError) as err:
                    self.log(u'URLError: ' + unicode(err), xbmc.LOGERROR)
                    lastCode = -1
                    raise err
                except (socket.timeout) as exception:
                    self.log(u'Timeout exception: ' + unicode(exception),
                             xbmc.LOGERROR)
                    if firstTime:
                        self.log(u'Timeout exception: ' + unicode(exception),
                                 xbmc.LOGERROR)
                        xbmc.executebuiltin(
                            u'XBMC.Notification(%s, %s)' %
                            (u'Socket timed out', 'Trying again'))
                        repeat = True
                    else:
                        """
                        The while loop is normally only processed once.
                        When a socket timeout happens it executes twice.
                        The following code executes after the second timeout.
                        """
                        self.log(
                            u'Timeout exception: ' + unicode(exception) +
                            ", if you see this msg often consider changing your Socket Timeout settings",
                            xbmc.LOGERROR)
                        raise exception

                    firstTime = False
                """
                else:
                    print 'Here are the headers of the page :'
                    print response.info()
                    print self.cookiejar
                    print 'These are the cookies we have received so far :'

                    for index, cookie in enumerate(self.cookiejar):
                        print index, '  :  ', cookie
                    #self.cookiejar.save(sys.modules["__main__"].COOKIE_PATH)
                    self.cookiejar.save() 
                """

        except (Exception) as exception:
            raise exception
        finally:
            if self.proxyConfig is not None:
                self.proxyConfig.Disable()

        self.log(u"response.info(): " + utils.drepr(response.info().items()),
                 xbmc.LOGDEBUG)
        lastCode = response.getcode()
        self.log(u"lastCode: " + unicode(lastCode), xbmc.LOGDEBUG)

        return response
Пример #27
0
    def GetHTTPResponse(self,  url, values = None, headers = None, logUrl = True):
        global lastCode
    
        if logUrl:
            self.log (u"url: " + url, xbmc.LOGDEBUG)    

        try:    
            if self.proxyConfig is not None: 
                self.proxyConfig.Enable()

            repeat = True
            firstTime = True
            addon = sys.modules["__main__"].addon
    
            while repeat:
                repeat = False
                try:
                    # Test socket.timeout
                    #raise socket.timeout
                    postData = None
                    if values is not None:
                        postData = urllib.urlencode(values)
                        self.log("postData: " + repr(postData))
                    
                    headers = self.PrepareHeaders(addon, headers)
                    
                    self.log("headers: " + repr(headers), xbmc.LOGDEBUG)
                    
                    request = urllib2.Request(url, postData, headers)
                    response = urllib2.urlopen(request)
                    """
                    self.log( 'Here are the headers of the page :', xbmc.LOGDEBUG )
                    self.log( handle.info(), xbmc.LOGDEBUG )
                    cookiejar = sys.modules["__main__"].cookiejar
                    self.log( cookiejar, xbmc.LOGDEBUG )
                    self.log( 'These are the cookies we have received so far :', xbmc.LOGDEBUG )

                    for index, cookie in enumerate(cookiejar):
                        self.log( index + '  :  ' + cookie, xbmc.LOGDEBUG )
                    cookiejar.save(COOKIE_PATH)
                    """
                except ( urllib2.HTTPError ) as err:
                    self.log ( u'HTTPError: ' + unicode(err), xbmc.LOGERROR)
                    lastCode = err.code
                    self.log (u"lastCode: " + unicode(lastCode), xbmc.LOGDEBUG)
                    raise err
                except ( urllib2.URLError ) as err:
                    self.log ( u'URLError: ' + unicode(err), xbmc.LOGERROR )
                    lastCode = -1
                    raise err
                except ( socket.timeout ) as exception:
                    self.log ( u'Timeout exception: ' + unicode(exception), xbmc.LOGERROR )
                    if firstTime:
                        self.log ( u'Timeout exception: ' + unicode(exception), xbmc.LOGERROR )
                        xbmc.executebuiltin(u'XBMC.Notification(%s, %s)' % (u'Socket timed out', 'Trying again'))
                        repeat = True
                    else:
                        """
                        The while loop is normally only processed once.
                        When a socket timeout happens it executes twice.
                        The following code executes after the second timeout.
                        """
                        self.log ( u'Timeout exception: ' + unicode(exception) + ", if you see this msg often consider changing your Socket Timeout settings", xbmc.LOGERROR )
                        raise exception
        
                    firstTime = False
                """
                else:
                    print 'Here are the headers of the page :'
                    print response.info()
                    print self.cookiejar
                    print 'These are the cookies we have received so far :'

                    for index, cookie in enumerate(self.cookiejar):
                        print index, '  :  ', cookie
                    #self.cookiejar.save(sys.modules["__main__"].COOKIE_PATH)
                    self.cookiejar.save() 
                """

        except ( Exception ) as exception:
            raise exception
        finally:
            if self.proxyConfig is not None: 
                self.proxyConfig.Disable()
    
        self.log (u"response.info(): " + utils.drepr(response.info().items()), xbmc.LOGDEBUG)
        lastCode = response.getcode()
        self.log (u"lastCode: " + unicode(lastCode), xbmc.LOGDEBUG)

        return response
Пример #28
0
    def AddEpisodeToList(self, listItems, episode):
        logger.debug(u"")

        try:
            htmlparser = HTMLParser.HTMLParser()

            href = episode[u'href']
            title = htmlparser.unescape(
                episode.find(u'span', u"thumbnail-title").contents[0])
            date = episode.find(u'span', u"thumbnail-date").contents[0]
            #description = ...
            thumbnail = episode.find(u'img', u'thumbnail')[u'src']

            newLabel = title + u", " + date

            if self.config.get("RTE", 'descriptions', "True") == 'True':
                infoLabels = self.GetEpisodeInfo(
                    self.GetEpisodeIdFromURL(href))
            else:
                infoLabels = {u'Title': newLabel, u'Plot': title}

            logger.debug(u"label == " + newLabel)

            if u"episodes available" in date:
                url = self.GetURLStart(
                ) + u'&listavailable=1' + u'&page=' + mycgi.URLEscape(href)

                newListItem = {
                    'label': newLabel,
                    'thumbnail': thumbnail,
                    'videoInfo': infoLabels
                }
                #                newListItem = xbmcgui.ListItem( label=newLabel )
                #                newListItem.setThumbnailImage(thumbnail)
                #                newListItem.setInfo(u'video', infoLabels)

                folder = True
            else:
                #newListItem.setProperty('IsPlayable', 'true')

                folder = False
                match = re.search(u"/player/[^/]+/show/([0-9]+)/", href)
                if match is None:
                    logger.warning(u"No show id found in page href: '%s'" %
                                   href)
                    return

                episodeId = match.group(1)

                url = self.GetURLStart() + u'&episodeId=' + mycgi.URLEscape(
                    episodeId)

                contextMenuItems = []
                newListItem = {
                    'label': newLabel,
                    'episodeId': episodeId,
                    'thumbnail': thumbnail,
                    'Video': True,
                    'contextMenuItems': contextMenuItems,
                    'videoInfo': infoLabels,
                    'url': url
                }
#                newListItem = self.ResumeWatchListItem(url, episodeId, contextMenuItems, infoLabels, thumbnail)

            listItems.append((url, newListItem, folder))
        except (Exception) as exception:
            if not isinstance(exception, LoggingException):
                exception = LoggingException.fromException(exception)

            msg = u"episode:\n\n%s\n\n" % utils.drepr(episode)
            exception.addLogMessage(msg)

            # Error getting episode details
            exception.addLogMessage("Error getting episode details")
            exception.process(self.logLevel(logging.WARNING))