def ListWatching(logged_in): if (CheckLogin(logged_in) == False): CreateBaseDirectory('video') return identity_cookie = None cookie_jar = None cookie_jar = GetCookieJar() for cookie in cookie_jar: if (cookie.name == 'IDENTITY'): identity_cookie = cookie.value break url = "https://ibl.api.bbci.co.uk/ibl/v1/user/watching?identity_cookie=%s" % identity_cookie html = OpenURL(url) json_data = json.loads(html) watching_list = json_data.get('watching').get('elements') for watching in watching_list: programme = watching.get('programme') episode = watching.get('episode') title = episode.get('title') subtitle = episode.get('subtitle') if (subtitle): title += ", " + subtitle episode_id = episode.get('id') plot = episode.get('synopses').get('large') or " " aired = episode.get('release_date') image_url = ParseImageUrl(episode.get('images').get('standard')) aired = ParseAired(aired) url = "http://www.bbc.co.uk/iplayer/episode/%s" % (episode_id) CheckAutoplay(title, url, image_url, plot, aired)
def ListFollowing(logged_in): if(CheckLogin(logged_in) == False): CreateBaseDirectory('audio') return """Scrapes all episodes of the favourites page.""" html = OpenURL('https://www.bbc.co.uk/radio/favourites/programmes') programmes = html.split('<div class="favourites follow ') for programme in programmes: if not programme.startswith('media'): continue series_id = '' series_name = '' series_id_match = re.search(r'<a aria-label="(.*?)" class="follows__image-link" href="http://www.bbc.co.uk/programmes/(.*?)">',programme) if series_id_match: series_name = series_id_match.group(1) series_id = series_id_match.group(2) episode_name = '' episode_id = '' episode_id_match = re.search(r'<a aria-label="(.*?)" class="size-e clr-white" href="http://www.bbc.co.uk/programmes/(.*?)#play"',programme) if episode_id_match: episode_name = episode_id_match.group(1) episode_id = episode_id_match.group(2) episode_image = '' series_image = '' series_image_match = re.search(r'<img class="media__image" src="(.*?)"',programme) if series_image_match: series_image = "https:%s" % series_image_match.group(1) episode_image = series_image station = '' station_match = re.search(r'<a href="(.*?)" class="clr-light-grey">\s*(.*?)\s*</a>',programme, flags=(re.DOTALL | re.MULTILINE)) if station_match: station = station_match.group(2).strip() description = '' if series_id: series_title = "%s - %s" % (station, series_name) AddMenuEntry(series_title, series_id, 131, series_image, description, '') if episode_id: if series_name: episode_title = "%s - %s - %s" % (station, series_name, episode_name) else: episode_title = "%s - %s" % (station, episode_name) episode_url = "http://www.bbc.co.uk/programmes/%s" % episode_id # xbmc.log(episode_url) CheckAutoplay(episode_title, episode_url, episode_image, ' ', '') xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_TITLE) xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_UNSORTED)
def ListWatching(logged_in): if (CheckLogin(logged_in) == False): CreateBaseDirectory('video') return cookie_jar = None cookie_jar = GetCookieJar() url = "https://www.bbc.co.uk/iplayer/watching" html = OpenURL(url) json_data = ScrapeJSON(html) if json_data: ParseJSON(json_data, url)
def ListFavourites(logged_in): if (CheckLogin(logged_in) == False): CreateBaseDirectory('video') return """Scrapes all episodes of the favourites page.""" html = OpenURL( 'http://www.bbc.co.uk/iplayer/usercomponents/favourites/programmes.json' ) json_data = json.loads(html) # favourites = json_data.get('favourites') programmes = json_data.get('programmes') for programme in programmes: id = programme.get('id') url = "http://www.bbc.co.uk/iplayer/brand/%s" % (id) title = programme.get('title') initial_child = programme.get('initial_children')[0] subtitle = initial_child.get('subtitle') episode_title = title if subtitle: episode_title = title + ' - ' + subtitle image = initial_child.get('images') image_url = ParseImageUrl(image.get('standard')) synopses = initial_child.get('synopses') plot = synopses.get('small') try: aired = FirstShownToAired(initial_child.get('release_date')) except: aired = '' CheckAutoplay(episode_title, url, image_url, plot, aired) more = programme.get('count') if more: episodes_url = "http://www.bbc.co.uk/iplayer/episodes/" + id AddMenuEntry( '[B]%s[/B] - %s %s' % (title, more, translation(30313)), episodes_url, 128, image_url, '', '') xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_TITLE) xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_DATE)
def ListListenList(logged_in): if (CheckLogin(logged_in) == False): CreateBaseDirectory('audio') return """Scrapes all episodes of the favourites page.""" html = OpenURL('http://www.bbc.co.uk/radio/favourites') programmes = html.split('<div class="favourites box-link favourite ') for programme in programmes: if not programme.startswith('media'): continue data_available_match = re.search(r'data-is-available="(.*?)"', programme) if ((not data_available_match) or (data_available_match.group(1) == '')): continue series_id = '' series_name = '' series_id_match = re.search( r'<a href="/programmes/(.*?)" class="media__meta-row size-f clr-light-grey text--single-line">\s*(.*?)\s*</a>', programme) if series_id_match: series_name = series_id_match.group(2) series_id = series_id_match.group(1) episode_name = '' episode_id = '' episode_id_match = re.search( r'<a aria-label="(.*?) Duration: (.*?)" class="favourites__brand-link(.*?)" href="/programmes/(.*?)#play">', programme) if episode_id_match: episode_name = episode_id_match.group(1) episode_id = episode_id_match.group(4) episode_image = '' episode_image_match = re.search( r'<img alt="" class="favourites__brand-image media__image " src="(.*?)"', programme) if episode_image_match: episode_image = "http:%s" % episode_image_match.group(1) series_image = '' series_image_match = re.search( r'<img class="media__image avatar-image--small" src="(.*?)">', programme) if series_image_match: series_image = "http:%s" % series_image_match.group(1) series_image = re.sub(r'96x96', '640x360', series_image) station = '' station_match = re.search( r'<span class="favourites__network-name.*?<a href="(.*?)" class="clr-light-grey">\s+?(.*?)\s+?<', programme, flags=(re.DOTALL | re.MULTILINE)) if station_match: station = station_match.group(2).strip() description = '' description_match = re.search( r'<p class="favourites__description media__meta-row size-f clr-white.*?">\s+?(.*?)\s+?</p>', programme, flags=(re.DOTALL | re.MULTILINE)) if description_match: description = description_match.group(1).strip() if series_id: series_title = "[B]%s - %s[/B]" % (station, series_name) AddMenuEntry(series_title, series_id, 131, series_image, description, '') if episode_id: if series_name: episode_title = "[B]%s[/B] - %s - %s" % (station, series_name, episode_name) episode_url = "http://www.bbc.co.uk/programmes/%s" % episode_id else: episode_title = "[B]%s[/B] - %s" % (station, episode_name) episode_url = "http://www.bbc.co.uk/radio/play/%s" % episode_id # xbmc.log(episode_url) CheckAutoplay(episode_title, episode_url, episode_image, ' ', '') xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_TITLE) xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_UNSORTED)
pass try: logged_in = params['logged_in'] == 'True' except: pass try: keyword = utf8_unquote_plus(params["keyword"]) except: pass # These are the modes which tell the plugin where to go. if mode == 1: KidsMode() elif mode is None or url is None or len(url) < 1: CreateBaseDirectory(content_type) # Modes 101-119 will create a main directory menu entry elif mode == 101: Video.ListLive() elif mode == 102: Video.ListAtoZ() elif mode == 103: Video.ListCategories() elif mode == 104: Video.Search(keyword) elif mode == 105:
def ListFavourites(logged_in): if (CheckLogin(logged_in) == False): CreateBaseDirectory('audio') return """Scrapes all episodes of the favourites page.""" html = OpenURL('http://www.bbc.co.uk/radio/favourites') programmes = html.split('<li class="my-item" data-appid="radio" ') for programme in programmes: if not programme.startswith('data-type="tlec"'): continue series_id = '' series_id_match = re.search(r'data-id="(.*?)"', programme) if series_id_match: series = series_id_match.group(1) programme_id = '' programme_id_match = re.search( r'<a href="http://www.bbc.co.uk/programmes/(.*?)"', programme) if programme_id_match: programme_id = programme_id_match.group(1) name = '' name_match = re.search( r'<span class="my-episode-brand" itemprop="name">(.*?)</span>', programme) if name_match: name = name_match.group(1) episode = '' episode_match = re.search( r'<span class="my-episode" itemprop="name">(.*?)</span>', programme) if episode_match: episode = "(%s)" % episode_match.group(1) image = '' image_match = re.search(r'itemprop="image" src="(.*?)"', programme) if image_match: image = image_match.group(1) synopsis = '' synopsis_match = re.search(r'<span class="my-item-info">(.*?)</span>', programme) if synopsis_match: synopsis = synopsis_match.group(1) station = '' station_match = re.search( r'<span class="my-episode-broadcaster" itemprop="name">(.*?)\.</span>', programme) if station_match: station = station_match.group(1).strip() title = "[B]%s - %s[/B]" % (station, name) episode_title = "[B]%s[/B] - %s %s" % (station, name, episode) if series: AddMenuEntry(title, series, 131, image, synopsis, '') if programme_id: url = "http://www.bbc.co.uk/programmes/%s" % programme_id CheckAutoplay(episode_title, url, image, ' ', '') xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_TITLE) xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_UNSORTED)