def _extract(doc): rtree = select_all(doc, 'li.list-item') results = PlayItemList() for l in rtree: a = select_one(l, 'a') url = get_attr(a, 'href') if url is None: continue if url.startswith('/iplayer'): url = "http://www.bbc.co.uk" + url pdiv = select_one(l, 'div.primary') idiv = select_one(pdiv, 'div.r-image') if idiv is None: idiv = select_one(pdiv, 'div.rs-image') idiv = select_one(idiv, 'source') img = get_attr(idiv, 'srcset') else: img = get_attr(idiv, 'data-ip-src') sdiv = select_one(l, 'div.secondary') title = get_text(select_one(sdiv, 'div.title')) subtitle = get_text(select_one(sdiv, 'div.subtitle')) synopsis = get_text(select_one(sdiv, 'p.synopsis')) item = PlayItem(title, img, url, subtitle, synopsis) a = select_one(l, 'a.view-more-container') if a is not None: link = "http://bbc.co.uk" + a.get('href') item.add_action(MoreEpisodesAction(link, title)) results.add(item) return results
def _extract(doc): rtree = select_all(doc, 'li.list-item') results = PlayItemList() for l in rtree: a = select_one(l, 'a') url = get_attr(a, 'href') if url is None or not url.startswith('/iplayer'): continue url = "http://www.bbc.co.uk" + url pdiv = select_one(l, 'div.primary') idiv = select_one(pdiv, 'div.r-image') img = get_attr(idiv, 'data-ip-src') sdiv = select_one(l, 'div.secondary') title = get_text(select_one(sdiv, 'div.title')) subtitle = get_text(select_one(sdiv, 'div.subtitle')) synopsis = get_text(select_one(sdiv, 'p.synopsis')) item = PlayItem(title, img, url, subtitle, synopsis) a = select_one(l, 'a.view-more-container') if a is not None: link = "http://bbc.co.uk" + a.get('href') item.add_action(MoreEpisodesAction(link, title)) results.add(item) return results
def _extract_grid(doc): rtree = select_all(doc, 'li.grid__item') results = PlayItemList() for l in rtree: a = select_one(l, 'a') url = get_attr(a, 'href') if url is None: continue if url.startswith('/iplayer'): url = "http://www.bbc.co.uk" + url idiv = select_one(l, 'div.rs-image') idiv = select_one(idiv, 'img') img = get_attr(idiv, 'srcset').split()[0] sdiv = select_one(l, 'div.content-item__info__text') avail = select_one(sdiv, 'div.content-item__labels') if get_text_content(avail) == "Not available": continue title = get_text_content(select_one(sdiv, 'div.content-item__title')) subtitle = get_text_content( select_one(sdiv, 'div.content-item__description')) if title.endswith("..."): title = title[:-3] if subtitle.endswith("..."): subtitle = subtitle[:-3] item = PlayItem(title, img, url, subtitle) a = select_one(l, 'a.js-view-all-episodes') if a is not None: link = "http://bbc.co.uk" + a.get('href') item.add_action(MoreEpisodesAction(link, title)) results.add(item) return results
def search(q): q = q.replace(' ', '-') q = q.replace("'", '') doc = get_doc(_SEARCH_URL + q) rtree = select_all(doc, 'div.search-wrapper') results = PlayItemList() for l in rtree: el = select_one(l, 'div.remaining-time') if el is not None and get_text(el).strip() == 'unavailable': continue el = select_one(l, 'h4 a') url = get_attr(el, 'href') title = get_text(el) el = select_one(l, "div.search-result-image a img") img = get_attr(el, 'src') el = select_one(l, ".search-episode-count") matched = int(get_attr(el, 'data-matched_episodes')) episodes = get_text(el) episodes = int(episodes[0:episodes.find(' ')]) action = None if episodes > matched: action = MoreEpisodesAction(url, title) eps = select_all(l, ".episode") for e in eps: el = select_one(e, ".episode-title a") url = _PREFIX + get_attr(el, 'href') subtitle = get_text(el) el = select_one(e, ".description") synopsis = get_text_content(el) item = PlayItem(title, img, url, subtitle, synopsis) results.add(item) if action: item.add_action(action) break return results
def search(q): q = q.replace(' ', '-') q = q.replace("'", '') doc = get_doc(_SEARCH_URL + q) rtree = select_all(doc, 'div.search-wrapper') results = PlayItemList() for l in rtree: el = select_one(l, 'h4 a') url = get_attr(el, 'href') title = get_text(el) el = select_one(l, "div.search-result-image a img") img = get_attr(el, 'src') el = select_one(l, ".search-episode-count") matched = int(get_attr(el, 'data-matched_episodes')) episodes = get_text(el) episodes = int(episodes[0:episodes.find(' ')]) action = None if episodes > matched: action = MoreEpisodesAction(url, title) eps = select_all(l, ".episode") for e in eps: el = select_one(e, ".episode-title a") url = _PREFIX + get_attr(el, 'href') subtitle = get_text(el) el = select_one(e, ".description") synopsis = get_text_content(el) item = PlayItem(title, img, url, subtitle, synopsis) results.add(item) if action: item.add_action(action) break return results
def feed(idx): url = _FEEDLIST[idx]['url'] doc = get_doc(url) rtree = select_all(doc, "a.complex-link") results = PlayItemList() for l in rtree: url = get_attr(l, 'href') el = select_one(l, '.tout__title') if el is None: continue title = get_text(el) el = select_one(l, 'img.fluid-media__media') img = get_attr(el, 'src') el = select_one(l, 'p.tout__meta') subtitle = get_text_content(el) if subtitle == 'No episodes available': continue item = PlayItem(title, img, url, subtitle) if subtitle != '1 episode': item.add_action(MoreEpisodesAction(url, title)) results.add(item) if idx == 0: global _SHOWLIST _SHOWLIST = results return results
def search(q): shows = get_json(_ALL_SHOWS_URL) results = PlayItemList() for i in shows: if not 'episode' in i['url']: continue if q.lower() in i['title'].lower(): item = PlayItem(i['title'], i['image']['jelly'], i['url']['episode'], i['synopses']) print i['url']['episode'] item.add_action(MoreEpisodesAction(i['url']['episode'], i['title'])) results.add(item) #results.add(PlayItem(i['title'], i['image']['jelly'], i['url']['episode'], i['synopses'])) return results
def feed(idx): url = _FEEDLIST[idx]['url'] doc = get_doc(url) rtree = select_all(doc, 'li.programme') results = PlayItemList() for l in rtree: el = select_one(l, '.programme-title a') url = _PREFIX + get_attr(el, 'href') title = get_text(el) el = select_one(l, 'img') img = get_attr(el, 'src') subtitle = get_text(select_one(l, '.episode-info span.episode-free')) item = PlayItem(title, img, url, subtitle) if (subtitle is not None) and (not subtitle.startswith('1 ')): item.add_action(MoreEpisodesAction(url, title)) results.add(item) return results
def feed(idx): url = _FEEDLIST[idx]['url'] doc = get_doc(url) livetree = select_all(doc, "div.genie-container") results = PlayItemList() for l in livetree: img = get_attr(l, "data-video-posterframe") title = get_attr(l, "data-video-channel-id") item = PlayItem(title.upper(), img, url, 'Watch LIVE TV') results.add(item) rtree = select_all(doc, "a.complex-link") for l in rtree: url = get_attr(l, 'href') el = select_one(l, '.tout__title') if el is None: el = select_one(l, '.slice__title') if el is None: continue title = get_text(el) el = select_one(l, 'img.fluid-media__media') img = get_attr(el, 'src') el = select_one(l, 'p.tout__summary') if el is None: el = select_one(l, 'p.tout__meta') if el is None: el = select_one(l, 'p.slice__meta') subtitle = get_text_content(el) if subtitle == 'No episodes available': continue item = PlayItem(title, img, url, subtitle) if subtitle != '1 episode': item.add_action(MoreEpisodesAction(url, title)) results.add(item) return results
def _extract_grid(idx, doc): rtree = select_all(doc, 'li.grid__item') results = PlayItemList() count = 0 for l in rtree: a = select_one(l, 'a') url = get_attr(a, 'href') if url is None: continue if url.startswith('/iplayer'): url = "http://www.bbc.co.uk" + url idiv = select_one(l, 'div.rs-image') idiv = select_one(idiv, 'source') img = get_attr(idiv, 'srcset').split()[0] sdiv = select_one(l, 'div.content-item__info__text') avail = select_one(sdiv, 'div.content-item__labels') if get_text_content(avail) == "Not available": continue title = get_text_content(select_one(sdiv, 'div.content-item__title')) subtitle = get_text_content( select_one(sdiv, 'div.content-item__description')) if title.endswith("..."): title = title[:-3] if subtitle.endswith("..."): subtitle = subtitle[:-3] item = PlayItem(title, img, url, subtitle) a = select_one(l, 'a.js-view-all-episodes') if a is not None: link = "http://bbc.co.uk" + a.get('href') item.add_action(MoreEpisodesAction(link, title)) if count == 0: seriestree = select_all(doc, 'li.scrollable-nav__item') for st in seriestree: a = select_one(st, 'a') url = get_attr(a, 'href') if url is None: continue if url.startswith('/iplayer'): url = "http://www.bbc.co.uk" + url sdiv = select_one(st, 'span.button__text') title = get_text_content(sdiv) if title is None: continue item.add_action(MoreEpisodesAction(url, title)) count = count + 1 results.add(item) if idx is not None: if idx == 1: item1 = PlayItem( "BBC One", "https://static.bbci.co.uk/tviplayer/img/navigation/bbcone.svg", "https://a.files.bbci.co.uk/media/live/manifesto/audio_video/simulcast/hls/uk/hls_mobile_wifi_rw/aks/bbc_one_london.m3u8", "BBC One Live", "Watch Live TV") results.add(item1) elif idx == 2: item2 = PlayItem( "BBC Two", "https://static.bbci.co.uk/tviplayer/img/navigation/bbctwo.svg", "https://a.files.bbci.co.uk/media/live/manifesto/audio_video/simulcast/hls/uk/hls_mobile_wifi_rw/llnws/bbc_two_england.m3u8", "BBC Two Live", "Watch Live TV") results.add(item2) elif idx == 4: #item3 = PlayItem("BBC Three", "https://static.bbci.co.uk/tviplayer/img/navigation/bbcfour.svg", "https://a.files.bbci.co.uk/media/live/manifesto/audio_video/simulcast/hls/uk/hls_mobile_wifi_rw/llnws/bbc_four.m3u8", "BBC Four Live", "Watch Live TV") #results.add(item3) item4 = PlayItem( "BBC Four", "https://static.bbci.co.uk/tviplayer/img/navigation/bbcfour.svg", "https://a.files.bbci.co.uk/media/live/manifesto/audio_video/simulcast/hls/uk/hls_mobile_wifi_rw/llnws/bbc_four.m3u8", "BBC Four Live", "Watch Live TV") results.add(item4) elif idx == 17: item5 = PlayItem( "BBC News", "https://static.bbci.co.uk/tviplayer/img/navigation/bbcnews.svg", "https://a.files.bbci.co.uk/media/live/manifesto/audio_video/simulcast/hls/uk/hls_mobile_wifi_rw/aks/bbc_news24.m3u8", "BBC News Live", "Watch Live TV") results.add(item5) return results