Esempio n. 1
0
def __retrieveChannels__(tvChannels, dtUrl, channelType):
    contentDiv = BeautifulSoup.SoupStrainer('div', {'class':re.compile(r'\bhentry\b')})
    soup = HttpClient().getBeautifulSoup(url=dtUrl, parseOnlyThese=contentDiv)
    for tvChannelTag in soup.div.findAll('div', recursive=False):
        try:
            tvChannel = {}
            running_tvshows = []
            finished_tvshows = []
            tmp_tvshows_list = None
            firstRow = False
            for tag in tvChannelTag.findAll(re.compile('div|a'), recursive=False):
                if tag.name == 'div' and tag.get('class') == 'nav_up':
                    continue
                if not firstRow:
                    channelImg = ''
                    if(tag.find('img').has_key('src')):
                        channelImg = str(tag.find('img')['src'])
                    else:
                        channelImg = str(tag.find('img')['file'])
                    channelName = re.compile(BASE_WSITE_URL + '/category/(tv-serials|pakistan-tvs)/(.+?)/').findall(str(tag.find('a')['href']))[0][1]
                    channelName = string.upper(channelName.replace('-', ' '))
                    Logger.logDebug(channelName)
                    tvChannels[channelName] = tvChannel
                    tvChannel['iconimage'] = channelImg
                    tvChannel['channelType'] = channelType
                    firstRow = True
                else:
                    if tag.name == 'div' and tag.get('class') == 'dtLink':
                        txt = tag.getText()
                        Logger.logDebug(txt)
                        if re.search('running', txt, flags=re.IGNORECASE):
                            tmp_tvshows_list = running_tvshows
                            tvChannel['running_tvshows'] = running_tvshows
                        elif re.search('finished', txt, flags=re.IGNORECASE):
                            tmp_tvshows_list = finished_tvshows
                            tvChannel['finished_tvshows'] = finished_tvshows
                        else:
                            Logger.logWarning('UNKNOWN TV SHOW CATEGORY')
                    elif tag.name == 'a':
                        tvshowUrl = str(tag['href'])
                        tvshowName = tag.getText().encode('utf-8')
                        Logger.logDebug(tvshowName)
                        tmp_tvshows_list.append({'name':HttpUtils.unescape(tvshowName), 'url':tvshowUrl})
        except Exception, e:
            Logger.logFatal(e)
            Logger.logDebug(tvChannelTag)
Esempio n. 2
0
                 video_link['videoSourceImg'] = video_hosting_info.get_video_hosting_image()
                 video_link['videoSourceName'] = video_hosting_info.get_video_hosting_name()
             video_playlist_items.append(video_link)
             video_source_img = video_link['videoSourceImg']
             video_source_name = video_link['videoSourceName']
             
             item = ListItem()
             item.add_request_data('videoLink', video_link['videoLink'])
             item.add_request_data('videoTitle', video_link['videoTitle'])
             item.set_next_action_name('SnapAndPlayVideo')
             xbmcListItem = xbmcgui.ListItem(label='Source #' + str(video_source_id) + ' | ' + 'Part #' + str(video_part_index) , iconImage=video_source_img, thumbnailImage=video_source_img)
             item.set_xbmc_list_item_obj(xbmcListItem)
             response_obj.addListItem(item)
             prevAFont = child.findChild('font')
         except:
             Logger.logWarning('Unable to recognize a source = ' + str(video_link['videoLink']))
             video_source_img = None
             video_source_name = None
             video_part_index = 0
             video_playlist_items = []
             ignoreAllLinks = True
             prevAFont = None
     prevChild = child.name
 if len(video_playlist_items) > 0:
     response_obj.addListItem(__preparePlayListItem__(video_source_id, video_source_img, video_source_name, video_playlist_items))
     
 
 ''' Following new cool stuff is to get Smart Direct Play Feature'''
 playNowItem = __findPlayNowStream__(response_obj.get_item_list())
 if playNowItem is not None:
     request_obj.set_data({'videoPlayListItems': playNowItem.get_request_data()['videoPlayListItems']})