def get_series(): series_list = [] json_data = get_index() category_data = None for c in json_data['get']['response']['Menu']['children']: if c['name'] == 'Programs': category_data = c['children'] break series_data = None for s in category_data: if s['name'] == 'Programs A-Z': series_data = s['children'] break for entry in series_data: try: series = classes.Series() series.title = entry.get('name') series.id = entry.get('dealcodes') series.thumbnail = entry.get('thumbnail') series.num_episodes = int(entry.get('totalMpegOnly', 0)) if series.num_episodes > 0: series_list.append(series) except Exception: utils.log('Error parsing entry: %s' % entry) return series_list
def parse_programme_from_feed(data): xml = ET.fromstring(data) show_list = [] for item in xml.getiterator('item'): title = item.find('title').text if title.startswith('Trailer'): continue show = None for s in show_list: if s.title == title: show = s break if show: show.increment_num_episodes() else: show = classes.Series() show.title = title show.description = item.find('description').text show.thumbnail = item.find('{http://search.yahoo.com/mrss/}thumbnail').attrib['url'] show_list.append(show) return show_list
def get_index(): """ Fetch the index of all shows available """ series_list = [] data = api_query("select * from plus7.showlist where device = 'ios'") json_data = json.loads(data) series_data = json_data['query']['results']['json']['show_data'] for series in series_data: title = series_data[series]['title'] # Don't show any 'promo' shows. They don't get returned by Brightcove if (title.find('Extras') > -1 or title.find('healthyMEtv') > -1): utils.log("Skipping series %s (hide extras)" % title) continue s = classes.Series() s.id = series s.title = series_data[series]['title'] s.description = series_data[series]['info'] s.thumbnail = series_data[series]['thumbnail'] series_list.append(s) return series_list
def parse_programme_from_feed(data, keyword): jsondata = json.loads(data) show_list = [] href_list = [] show_index = json.loads(comm.fetch_url(config.INDEX_URL)) series_houseno_list = [(x['href'][-13:-6], x['episodeCount']) for item in show_index['index'] for x in item['episodes']] for section in jsondata[u'index']: for item in section[u'episodes']: houseno = item['episodeHouseNumber'][:7] title = item[u'seriesTitle'] if title.startswith(u'Trailer'): continue show = None if keyword == 'category/news' or keyword == 'channel/news24': for s in show_list: if s.series_houseno == houseno: show = s break if s.title == title: show = s break if not show: show = classes.Series() show.series_houseno = houseno episode_count = 0 for houseno in series_houseno_list: if houseno[0] == show.series_houseno: episode_count = houseno[1] show.num_episodes = episode_count break # some shows have multiple house no's, try matching titles if episode_count == 0: for group in show_index['index']: for listing in group['episodes']: if listing['seriesTitle'] == title: show.num_episodes = listing['episodeCount'] break show.title = title if u'title' in item: show.description = item[u'title'] title_match = re.match('^[Ss]eries\s?(?P<series>\w+)', show.description) if title_match: show.title += ' Series ' + title_match.groups()[0] else: show.description = item[u'seriesTitle'] show.thumbnail = item['thumbnail'] show.series_url = item['href'] href_list.append(item['href']) show_list.append(show) return show_list
def get_categories(url): # TODO(andy): Switch to use this function resp = fetch_cache_url(url) json_data = json.loads(resp) series_list = [] for entry in json_data['entries']: try: series = classes.Series() series.title = entry.get('name') series.id = entry.get('dealcodes') series.thumbnail = entry.get('thumbnail') series.num_episodes = int(entry.get('totalMpegOnly', 0)) if series.num_episodes > 0: series_list.append(series) except Exception: utils.log('Error parsing entry: %s' % entry) return series_list
def get_index(): """ Fetch the index of all shows available """ series_list = [] data = api_query("select * from plus7.showlist where device = 'ios'") json_data = json.loads(data) series_data = json_data['query']['results']['json']['show_data'] for series in series_data: s = classes.Series() s.id = series s.title = series_data[series]['title'] s.description = series_data[series]['info'] s.thumbnail = series_data[series]['thumbnail'] series_list.append(s) return series_list
def get_index(): """ This function pulls in the index, which contains the TV series """ series_list = [] data = fetch_url(config.index_url) data = data.replace('\n','') token = re.findall(r"<!-- Body Content -->(.*)<!-- //Body Content -->", data)[0] token2 = re.findall(r'<div class="bd" id="atoz">(.*)</div>', token)[0] urls = re.findall(r'<a href="(.*?)"', token2) titles = re.findall(r'alt="(.*?)"', token2) imgs = re.findall(r'src="(.*?)\?', token2) for i in xrange(len(urls)): series = classes.Series() series.title = titles[i] series.thumbnail = imgs[i] series.url = urls[i] series_list.append(series) return series_list
def parse_index(soup): """ This function parses the index, which is an overall listing of all programs available in iView. The index is divided into 'series' and 'items'. Series are things like 'beached az', while items are things like 'beached az Episode 8'. """ series_list = [] index = json.loads(soup) for series in index: new_series = classes.Series() #{u'a': u'9995608', # u'b': u'Wildscreen Series 1', # u'e': u'shopdownload', # u'f': [{u'a': u'9995608', # u'f': u'2010-05-30 00:00:00', # u'g': u'2010-07-17 00:00:00'}] #} new_series.id = series['a'] new_series.title = series['b'] new_series.keywords = series['e'].split(" ") new_series.num_episodes = int(len(series['f'])) new_series.description = series['c'] new_series.thumbnail = series['d'] # Only include a program if isn't a 'Shop Download' if new_series.has_keyword("shopdownload"): utils.log("Skipping shopdownload: %s" % new_series.title) continue if new_series.title == "ABC News 24": utils.log("Skipping: %s" % new_series.title) continue if new_series.num_episodes > 0: utils.log("Found series: %s" % (new_series.get_list_title())) series_list.append(new_series) return series_list