def list_videos(plugin, item_id, category_url, **kwargs): resp = urlquick.get(category_url) root = resp.parse() video_integral = root.find(".//div[@class='col-md-6']") if video_integral is not None: item = Listitem() item.label = video_integral.find('.//img').get('alt') video_url = URL_ROOT(video_integral.find('.//a').get('href')) item.art['thumb'] = video_integral.find('.//img').get('src') item.set_callback(get_video_url, item_id=item_id, video_url=video_url, video_label=LABELS[item_id] + ' - ' + item.label, item_dict=item2dict(item)) item_post_treatment(item, is_playable=True, is_downloadable=True) yield item for video in root.iterfind(".//div[@class='col-md-3']"): item = Listitem() item.label = video.find('.//img').get('alt') video_url = URL_ROOT(video.find('.//a').get('href')) item.art['thumb'] = video.find('.//img').get('src') item.set_callback(get_video_url, item_id=item_id, video_url=video_url, video_label=LABELS[item_id] + ' - ' + item.label, item_dict=item2dict(item)) item_post_treatment(item, is_playable=True, is_downloadable=True) yield item
def list_videos(plugin, item_id, mode, page, **kwargs): resp = urlquick.get(URL_FRANCETV_SPORT % mode + '?page=%s' % page) json_parser = json.loads(resp.text) for video_datas in json_parser["page"]["flux"]: video_title = video_datas["title"] video_image = '' if 'image' in video_datas: video_image = video_datas["image"]["large_16_9"] video_duration = 0 if 'duration' in video_datas: video_duration = int(video_datas["duration"]) video_url = URL_ROOT_SPORT + video_datas["url"] date_value = time.strftime('%Y-%m-%d', time.localtime(video_datas["updated"])) item = Listitem() item.label = video_title item.info['duration'] = video_duration item.art['thumb'] = video_image item.info.date(date_value, '%Y-%m-%d') item.set_callback(get_video_url, item_id=item_id, video_url=video_url, video_label=LABELS[item_id] + ' - ' + item.label, item_dict=item2dict(item)) item_post_treatment(item, is_playable=True, is_downloadable=True) yield item yield Listitem.next_page(item_id=item_id, mode=mode, page=str(int(page) + 1))
def list_videos_seasons(plugin, item_id, next_url, **kwargs): resp = urlquick.get(next_url) json_parser = json.loads(resp.text) program_title = json_parser['currentPage']['displayName'] for video_datas in json_parser['episodes']['contents']: if 'subtitle' in video_datas: video_title = program_title + ' ' + video_datas['title'] + ' ' + video_datas['subtitle'] else: video_title = program_title + ' ' + video_datas['title'] video_image = video_datas['URLImage'] video_plot = '' if 'summary' in video_datas: video_plot = video_datas['summary'] video_url = video_datas['URLMedias'] item = Listitem() item.label = video_title item.art['thumb'] = video_image item.info['plot'] = video_plot item.set_callback( get_video_url, item_id=item_id, next_url=video_url, video_label=LABELS[item_id] + ' - ' + item.label, item_dict=item2dict(item)) item_post_treatment(item, is_playable=True, is_downloadable=True) yield item
def list_videos_other(plugin, item_id, program_part_url, page=0, **kwargs): # URL example: http://api-front.yatta.francetv.fr/standard/publish/taxonomies/france-2_cash-investigation/contents/?size=20&page=0&sort=begin_date:desc&filter=with-no-vod,only-visible url_program = "standard/publish/taxonomies/%s/contents/" % program_part_url resp = urlquick.get(URL_API(url_program), params={ 'size': 500, 'page': page, 'filter': "with-no-vod,only-visible", 'sort': "sort = begin_date:desc" }) json_parser = json.loads(resp.text) for video in json_parser['result']: if video['type'] != 'integrale' and video['type'] != 'extrait': item = Listitem() broadcast_id = populate_item(item, video) item.set_callback(get_video_url, item_id=item_id, broadcast_id=broadcast_id, video_label=LABELS[item_id] + " - " + item.label, item_dict=item2dict(item)) item_post_treatment(item, is_playable=True, is_downloadable=True) yield item # More videos... if json_parser['cursor']['next'] is not None and json_parser['cursor'][ 'last'] is not None: yield Listitem.next_page(item_id=item_id, program_part_url=program_part_url, page=json_parser['cursor']['next'])
def list_videos_last(plugin, item_id, page=1, **kwargs): url_last = "standard/publish/channels/%s/contents/" % item_id resp = urlquick.get(URL_API(url_last), params={ 'size': 20, 'page': page, 'filter': "with-no-vod,only-visible", 'sort': "begin_date:desc" }) json_parser = json.loads(resp.text) for video in json_parser['result']: item = Listitem() broadcast_id = populate_item(item, video, True) item.set_callback(get_video_url, item_id=item_id, broadcast_id=broadcast_id, video_label=LABELS[item_id] + ' - ' + item.label, item_dict=item2dict(item)) item_post_treatment(item, is_playable=True, is_downloadable=True) yield item # More videos... if json_parser['cursor']['next'] is not None: yield Listitem.next_page(item_id=item_id, page=json_parser['cursor']['next'])
def list_videos(plugin, item_id, category_url, page, **kwargs): resp = urlquick.get(category_url + '?page=%s' % page) root = resp.parse() for video_data in root.iterfind( ".//div[@class='c-card-video js-card h-flex c-wall__item']"): video_title = video_data.get('title') video_image = '' if video_data.find('.//img') is not None: video_image = 'https:' + video_data.find('.//img').get('data-src') video_url = URL_ROOT + video_data.find('.//a').get('href') video_duration = 0 # TODO item = Listitem() item.label = video_title item.art['thumb'] = video_image item.info['duration'] = video_duration item.set_callback(get_video_url, item_id=item_id, video_url=video_url, video_label=LABELS[item_id] + ' - ' + item.label, item_dict=item2dict(item)) item_post_treatment(item, is_playable=True, is_downloadable=True) yield item # More videos... yield Listitem.next_page(item_id=item_id, category_url=category_url, page=str(int(page) + 1))
def list_videos(plugin, item_id, day_id, **kwargs): resp = urlquick.get(URL_DAYS) root = resp.parse("ul", attrs={"id": "slick-missed-day-%s" % (day_id)}) for broadcast in root.iterfind(".//li"): video_time = broadcast.find( ".//time[@class='m-section__scroll__item__bottom__time']" ).text.replace('.', ':') video_title = video_time + " - " + broadcast.find( ".//span[@class='m-section__scroll__item__bottom__title']").text subtitle = broadcast.find( "span[@class='m-section__scroll__item__bottom__title--sub']") if subtitle is not None and subtitle.text is not None: video_title += ": " + subtitle video_image = URL_ROOT + broadcast.find('.//img').get('data-src') video_url = URL_ROOT + broadcast.find('.//a').get('href') item = Listitem() item.label = video_title item.art['thumb'] = video_image item.set_callback(get_video_url, item_id=item_id, video_url=video_url, item_dict=item2dict(item)) item_post_treatment(item, is_playable=True, is_downloadable=False) yield item
def list_videos_episodes(plugin, item_id, program_url, **kwargs): resp = urlquick.get(program_url + '?ApiKey=%s' % API_KEY) json_parser = json.loads(resp.text) video_datas = json_parser["components"][0]["episode"] video_title = video_datas["title"] if 'header' in video_datas["images"]: video_image = URL_IMAGE % video_datas["images"]["header"]["id"] else: video_image = '' video_plot = video_datas["description"] video_id = video_datas["id"] video_duration = video_datas["duration"] date_value = video_datas['broadcastDate'].split('T')[0] item = Listitem() item.label = video_title item.art['thumb'] = video_image item.info['plot'] = video_plot item.info['duration'] = video_duration item.info.date(date_value, "%Y-%m-%d") item.set_callback(get_video_url, item_id=item_id, video_id=video_id, item_dict=item2dict(item)) item_post_treatment(item, is_playable=True, is_downloadable=False) yield item
def get_playlist_urls(plugin, item_id, video_id, url, **kwargs): resp = urlquick.get(url) json_parser = json.loads(resp.text) for video in json_parser: current_video_id = str(video['id']) if current_video_id != video_id: continue playlist_videos = [] for clip in video['clips']: clip_id = str(clip['video_id']) item = Listitem() item.label = clip['title'] populate_item(item, clip) video = get_video_url(plugin, item_id=item_id, video_id=clip_id, video_label=LABELS[item_id] + ' - ' + item.label, item_dict=item2dict(item)) playlist_videos.append(video) return playlist_videos
def list_videos(plugin, item_id, program_url, **kwargs): resp = urlquick.get(program_url) root = resp.parse("ul", attrs={"class": "list-vids"}) for video_datas in root.iterfind(".//li"): video_title = video_datas.find('.//h2').text video_image = URL_ROOT + '/videoimages/' + video_datas.find( ".//div[@class='img']").get('data-img') video_plot = '' if video_datas.find(".//div[@class='resume']").text is not None: video_plot = video_datas.find( ".//div[@class='resume']").text.strip() video_url = URL_ROOT + video_datas.find('.//a').get('href') item = Listitem() item.label = video_title item.art['thumb'] = video_image item.info['plot'] = video_plot item.set_callback(get_video_url, item_id=item_id, video_label=LABELS[item_id] + ' - ' + item.label, video_url=video_url, item_dict=item2dict(item)) item_post_treatment(item, is_playable=True, is_downloadable=False) yield item
def list_videos(plugin, item_id, next_url, page, **kwargs): resp = urlquick.get(next_url % page) root = resp.parse() for video_data in root.iterfind(".//div[@class='ftve-thumbnail ']"): video_title = video_data.find('.//h4').find('.//a').get('title') video_image = video_data.find( ".//div[@class='thumbnail-img lazy']").get('data-original') video_data_contenu = video_data.get('data-contenu') item = Listitem() item.label = video_title item.art['thumb'] = video_image item.set_callback(get_video_url, item_id=item_id, video_data_contenu=video_data_contenu, video_label=LABELS[item_id] + ' - ' + item.label, item_dict=item2dict(item)) item_post_treatment(item, is_playable=True, is_downloadable=True) yield item yield Listitem.next_page(item_id=item_id, next_url=next_url, page=str(int(page) + 1))
def list_videos(plugin, item_id, program_url, **kwargs): resp = urlquick.get(program_url) root = resp.parse() list_videos_datas = root.findall(".//li[@class='push type-episode']") list_videos_datas += root.findall( ".//li[@class='push type-episode active seen']") for video_datas in list_videos_datas: if video_datas.find(".//div[@class='description']").text is not None: video_title = video_datas.find( ".//div[@class='title']").text.strip() + ' - ' + \ video_datas.find( ".//div[@class='description']").text.strip() else: video_title = video_datas.find( ".//div[@class='title']").text.strip() video_url = URL_ROOT_NOUVELLES_ECRITURES % item_id + \ video_datas.find('.//a').get('href') video_image = '' if video_datas.find('.//img') is not None: video_image = video_datas.find('.//img').get('src') item = Listitem() item.label = video_title item.art['thumb'] = video_image item.set_callback(get_video_url, item_id=item_id, video_url=video_url, video_label=LABELS[item_id] + ' - ' + item.label, item_dict=item2dict(item)) item_post_treatment(item, is_playable=True, is_downloadable=True) yield item
def list_videos_bonus(plugin, item_id, category_url, page, **kwargs): resp = urlquick.get(category_url + '/page/%s' % str(page)) root = resp.parse() at_least_one_item = False video_integral = root.find(".//div[@class='col-md-6']") if video_integral is not None: at_least_one_item = True item = Listitem() item.label = video_integral.find('.//img').get('alt') video_url = URL_ROOT(video_integral.find('.//a').get('href')) item.art['thumb'] = video_integral.find('.//img').get('src') item.set_callback(get_video_url, item_id=item_id, video_url=video_url, video_label=LABELS[item_id] + ' - ' + item.label, item_dict=item2dict(item)) item_post_treatment(item, is_playable=True, is_downloadable=True) yield item for video in root.iterfind(".//div[@class='col-md-3']"): at_least_one_item = True item = Listitem() item.label = video.find('.//img').get('alt') video_url = URL_ROOT(video.find('.//a').get('href')) item.art['thumb'] = video.find('.//img').get('src') item.set_callback(get_video_url, item_id=item_id, video_url=video_url, video_label=LABELS[item_id] + ' - ' + item.label, item_dict=item2dict(item)) item_post_treatment(item, is_playable=True, is_downloadable=True) yield item if page is not None and at_least_one_item: # More videos... yield Listitem.next_page(item_id=item_id, category_url=category_url, page=page + 1) else: plugin.notify(plugin.localize(LABELS['No videos found']), '') yield False
def generic_menu(plugin, **kwargs): """ Build a generic addon menu with all not hidden items """ plugin.redirect_single_item = True menu_id = kwargs.get('item_id') menu = get_sorted_menu(plugin, menu_id) if not menu: # If the selected menu is empty just reload the current menu yield False for index, (item_order, item_id, item_infos) in enumerate(menu): item = Listitem() # Set item label item.label = get_item_label(item_id) # Set item art if 'thumb' in item_infos: item.art["thumb"] = common.get_item_media_path(item_infos['thumb']) if 'fanart' in item_infos: item.art["fanart"] = common.get_item_media_path( item_infos['fanart']) # Set item params # If this item requires a module to work, get # the module path to be loaded if 'module' in item_infos: item.params['item_module'] = item_infos['module'] item.params['item_id'] = item_id item.params['item_dict'] = item2dict(item) # Get the next action to trigger if this # item will be selected by the user item_callback = eval(item_infos['callback']) item.set_callback(item_callback) add_context_menus_to_item(plugin, item, index, menu_id, len(menu), item_infos=item_infos) yield item
def list_videos(plugin, item_id, program_slug, video_type_value, offset, **kwargs): params = { 'id': '6708f510f2af7e75114ab3c4378142b2ce25cd636ff5a1ae11f47ce7ad9c4a91', 'variables': '{"programSlug":"%s","offset":%d,"limit":20,"sort":{"type":"DATE","order":"DESC"},"types":["%s"]}' % (program_slug, int(offset), video_type_value) } headers = { 'content-type': 'application/json', 'referer': 'https://www.tf1.fr/programmes-tv', 'User-Agent': web_utils.get_random_ua() } resp = urlquick.get(URL_API, params=params, headers=headers) json_parser = json.loads(resp.text) for video_datas in json_parser['data']['programBySlug']['videos']['items']: video_title = video_datas['title'] try: video_image = video_datas['decoration']['images'][1]['sources'][0][ 'url'] except Exception: video_image = '' video_plot = video_datas['decoration']['description'] video_duration = video_datas['publicPlayingInfos']['duration'] video_id = video_datas['streamId'] item = Listitem() item.label = video_title item.art['thumb'] = video_image item.info['plot'] = video_plot item.info['duration'] = video_duration item.info.date(video_datas['date'].split('T')[0], '%Y-%m-%d') item.set_callback(get_video_url, item_id=item_id, video_label=LABELS[item_id] + ' - ' + item.label, video_id=video_id, item_dict=item2dict(item)) item_post_treatment(item, is_playable=True, is_downloadable=True) yield item if (20 + int(offset) * 20) < json_parser['data']['programBySlug']['videos']['total']: yield Listitem.next_page(item_id=item_id, program_slug=program_slug, video_type_value=video_type_value, offset=str(int(offset) + 1))
def list_videos_programs(plugin, item_id, program_url, season_name, **kwargs): resp = urlquick.get(URL_CLIENT_KEY_JS) client_key_value = 'client-key %s' % re.compile( r'client-key \"\.concat\(\"(.*?)\"').findall(resp.text)[0] headers = { 'Authorization': client_key_value, 'Accept': 'application/json, text/plain, */*' } resp2 = urlquick.get(URL_VIDEOS % program_url, headers=headers) json_parser = json.loads(resp2.text) for season_datas in json_parser["EmisodeLineups"]: if season_name in season_datas["Name"]: for video_datas in season_datas["LineupItems"]: if video_datas["IsFree"] is True: if video_datas["EpisodeTitle"] in video_datas[ "ProgramTitle"]: video_title = video_datas["ProgramTitle"] else: video_title = video_datas[ "ProgramTitle"] + ' - ' + video_datas[ "EpisodeTitle"] video_plot = video_datas["Description"] video_image = video_datas["ImageUrl"].replace( 'w_200,h_300', 'w_300,h_200') video_duration = video_datas["Details"]["LengthInSeconds"] video_id = video_datas["IdMedia"] item = Listitem() item.label = video_title item.art['thumb'] = video_image item.info['plot'] = video_plot item.info['duration'] = video_duration if video_datas["Details"]["AirDate"] is not None: publication_date = video_datas["Details"][ "AirDate"].split(' ')[0] item.info.date(publication_date, "%Y-%m-%d") item.set_callback(get_video_url, item_id=item_id, video_label=LABELS[item_id] + ' - ' + item.label, video_id=video_id, item_dict=item2dict(item)) item_post_treatment(item, is_playable=True, is_downloadable=False) yield item
def list_videos(plugin, item_id, next_url, page, **kwargs): resp = urlquick.get(next_url + '/page/' + page) json_parser = json.loads(resp.text) if 'videos' in json_parser: list_id = 'videos' elif 'contents' in json_parser: list_id = 'contents' at_least_one_item = False for video_datas in json_parser[list_id]: at_least_one_item = True video_title = video_datas['title'] video_plot = video_datas['description'] date_epoch = video_datas['lastPublicationDate'] date_value = time.strftime('%Y-%m-%d', time.localtime(date_epoch)) video_url = URL_STREAM_ROOT + video_datas['url'] video_image = '' for media_datas in video_datas['medias']: if 'urlThumbnail' in media_datas: video_image = URL_STREAM_ROOT + media_datas['urlThumbnail'] break item = Listitem() item.label = video_title item.info['plot'] = video_plot item.art['thumb'] = video_image item.info.date(date_value, '%Y-%m-%d') item.set_callback(get_video_url, item_id=item_id, video_url=video_url, video_label=LABELS[item_id] + ' - ' + item.label, item_dict=item2dict(item)) item_post_treatment(item, is_playable=True, is_downloadable=True) yield item if at_least_one_item: yield Listitem.next_page(item_id=item_id, next_url=next_url, page=str(int(page) + 1)) else: plugin.notify(plugin.localize(LABELS['No videos found']), '') yield False
def list_videos(plugin, item_id, program_id, sub_category_id, **kwargs): url = '' if sub_category_id is None: url = URL_VIDEOS2 % program_id else: url = URL_VIDEOS % (program_id, sub_category_id) resp = urlquick.get(url) json_parser = json.loads(resp.text) if not json_parser: plugin.notify(plugin.localize(LABELS['No videos found']), '') yield False for video in json_parser: video_id = str(video['id']) item = Listitem() item.label = video['title'] is_downloadable = False if cqu.get_kodi_version() < 18: is_downloadable = True if 'type' in video and video['type'] == 'playlist': populate_item(item, video) item.set_callback(get_playlist_urls, item_id=item_id, video_id=video_id, url=url) else: populate_item(item, video['clips'][0]) item.set_callback(get_video_url, item_id=item_id, video_id=video_id, video_label=LABELS[item_id] + ' - ' + item.label, item_dict=item2dict(item)) item_post_treatment(item, is_playable=True, is_downloadable=is_downloadable) yield item
def add_context_menus_to_item(plugin, item, index, menu_id, menu_len, **kwargs): # Move up if index > 0: item.context.script(move_item, plugin.localize(LABELS['Move up']), direction='up', item_id=item.params['item_id'], menu_id=menu_id) # Move down if index < menu_len - 1: item.context.script(move_item, plugin.localize(LABELS['Move down']), direction='down', item_id=item.params['item_id'], menu_id=menu_id) # Hide item.context.script(hide_item, plugin.localize(LABELS['Hide']), item_id=item.params['item_id']) # Connect/Disconnect VPN add_vpn_context(item) # Add to add-on favourites is_playable = False if 'is_playable' in kwargs: is_playable = kwargs['is_playable'] elif 'item_infos' in kwargs and \ kwargs['item_infos']['callback'] == 'live_bridge': is_playable = True fav.add_fav_context(item, item2dict(item), is_playable=is_playable, channel_infos=kwargs.get('channel_infos', None)) return
def list_videos(plugin, item_id, program_id, program_season_number, **kwargs): resp = urlquick.get(URL_VIDEOS % program_id) json_parser = json.loads(resp.text) at_least_one_item = False if 'episode' in json_parser["videos"]: if str(program_season_number) in json_parser["videos"]["episode"]: for video_datas in json_parser["videos"]["episode"][str( program_season_number)]: at_least_one_item = True video_title = video_datas["title"] video_duration = old_div(int(video_datas["videoDuration"]), 1000) video_plot = video_datas["description"] video_image = video_datas["image"]["src"] video_id = video_datas["path"] item = Listitem() item.label = video_title item.art["thumb"] = video_image item.art["fanart"] = video_image item.info["plot"] = video_plot item.info["duration"] = video_duration item.set_callback(get_video_url, item_id=item_id, video_id=video_id, video_label=LABELS[item_id] + ' - ' + item.label, item_dict=item2dict(item)) item_post_treatment(item, is_playable=True, is_downloadable=True) yield item if not at_least_one_item: plugin.notify(plugin.localize(LABELS['No videos found']), '') yield False
def list_videos(plugin, item_id, season_id, **kwargs): resp = urlquick.get(URL_VIDEOS % season_id) json_parser = json.loads(resp.text) for video_datas in json_parser["value"]: video_title = video_datas["Title"] video_image = URL_IMAGES % (video_datas["Images"][0]["Id"], video_datas["Id"]) video_plot = video_datas["ShortDescription"] video_id = video_datas["Id"] item = Listitem() item.label = video_title item.art['thumb'] = video_image item.info['plot'] = video_plot item.set_callback(get_video_url, item_id=item_id, video_id=video_id, item_dict=item2dict(item)) item_post_treatment(item, is_playable=True, is_downloadable=False) yield item
def list_videos_days(plugin, item_id, day_id, **kwargs): resp = urlquick.get(URL_CLIENT_KEY_JS) client_key_value = 'client-key %s' % re.compile( r'client-key \"\.concat\(\"(.*?)\"').findall(resp.text)[0] headers = { 'Authorization': client_key_value, 'Accept': 'application/json, text/plain, */*' } resp2 = urlquick.get(URL_REPLAY_BY_DAY, headers=headers) json_parser = json.loads(resp2.text) for day_datas in json_parser["Lineups"]: if day_datas["Name"] == day_id: for video_datas in day_datas["LineupItems"]: if video_datas["IsFree"] is True: video_title = video_datas[ "ProgramTitle"] + ' ' + video_datas["HeadTitle"] video_plot = video_datas["Description"] video_image = video_datas["ImageUrl"].replace( 'w_200,h_300', 'w_300,h_200') video_id = video_datas["IdMedia"] item = Listitem() item.label = video_title item.art['thumb'] = video_image item.info['plot'] = video_plot item.set_callback(get_video_url, item_id=item_id, video_label=LABELS[item_id] + ' - ' + item.label, video_id=video_id, item_dict=item2dict(item)) item_post_treatment(item, is_playable=True, is_downloadable=False) yield item
def list_videos(plugin, item_id, program_url, **kwargs): resp = urlquick.get(program_url) root = resp.parse() for video_datas in root.iterfind( ".//a[@class='slider-inline-style--content video_mosaic']"): video_title = video_datas.get('title') video_plot = video_datas.get('description') if video_datas.find('.//img').get('data-srcset'): video_image = video_datas.find('.//img').get('data-srcset') else: video_image = video_datas.find('.//img').get('src') id_diffusion = re.compile(r'video\/(.*?)\@Regions').findall( video_datas.get('href'))[0] item = Listitem() item.label = video_title item.art['thumb'] = video_image item.info['plot'] = video_plot date_value = '' if video_datas.find( ".//p[@class='slider-inline-style--text text-light m-t-0']" ).text is not None: date_value = video_datas.find( ".//p[@class='slider-inline-style--text text-light m-t-0']" ).text.split(' du ')[1] item.info.date(date_value, '%d/%m/%Y') item.set_callback(get_video_url, item_id=item_id, id_diffusion=id_diffusion, video_label=LABELS[item_id] + ' - ' + item.label, item_dict=item2dict(item)) item_post_treatment(item, is_playable=True, is_downloadable=True) yield item
def list_videos(plugin, item_id, program_url, **kwargs): resp = urlquick.get(program_url) root = resp.parse() for video_datas in root.iterfind(".//a[@class='video_mosaic']"): video_title = video_datas.get('title') video_plot = video_datas.get('description') video_image = video_datas.find('.//img').get('src') id_diffusion = re.compile(r'video\/(.*?)\@Regions').findall( video_datas.get('href'))[0] video_duration = 0 if video_datas.find(".//p[@class='length']").text is not None: duration_values = video_datas.find( ".//p[@class='length']").text.split(' : ')[1].split(':') video_duration = int(duration_values[0]) * 3600 + int( duration_values[1]) * 60 + int(duration_values[2]) item = Listitem() item.label = video_title item.art['thumb'] = video_image item.info['plot'] = video_plot item.info['duration'] = video_duration date_value = '' if video_datas.find(".//p[@class='date']").text is not None: date_value = video_datas.find(".//p[@class='date']").text.split( ' : ')[1] item.info.date(date_value, '%d/%m/%Y') item.set_callback(get_video_url, item_id=item_id, id_diffusion=id_diffusion, video_label=LABELS[item_id] + ' - ' + item.label, item_dict=item2dict(item)) item_post_treatment(item, is_playable=True, is_downloadable=True) yield item
def list_videos(plugin, item_id, page, **kwargs): resp = urlquick.get(URL_VIDEOS % item_id) if item_id == 'tvbreizh': resp = urlquick.get(URL_VIDEOS % item_id) else: resp = urlquick.get(URL_VIDEOS % item_id + '?page=%s' % page) root = resp.parse("div", attrs={"class": "view-content"}) for video_datas in root.iterfind("./div"): video_title = video_datas.find(".//span[@class='field-content']").find( './/a').text video_plot = '' if video_datas.find(".//div[@class='field-resume']") is not None: video_plot = video_datas.find( ".//div[@class='field-resume']").text.strip() video_image = URL_ROOT % item_id + \ video_datas.find('.//img').get('src') video_url = URL_ROOT % item_id + '/' + \ video_datas.find('.//a').get('href') item = Listitem() item.label = video_title item.art['thumb'] = video_image item.info['plot'] = video_plot item.set_callback(get_video_url, item_id=item_id, video_label=LABELS[item_id] + ' - ' + item.label, video_url=video_url, item_dict=item2dict(item)) item_post_treatment(item, is_playable=True, is_downloadable=True) yield item if 'tvbreizh' not in item_id: yield Listitem.next_page(item_id=item_id, page=str(int(page) + 1))
def list_videos(plugin, item_id, serie_id, **kwargs): resp = urlquick.get(URL_VIDEOS % serie_id) json_parser = json.loads(resp.text) for video_datas in json_parser["episodes"]: video_title = video_datas["brand_name"] + \ ' - ' ' S%sE%s' % (video_datas["series_number"], str(video_datas["episode_number"])) + ' - ' + video_datas["name"] video_image = video_datas["image"] video_plot = video_datas["synopsis"] video_duration = video_datas["duration"] * 60 video_id = video_datas["video_id"] item = Listitem() item.label = video_title item.art['thumb'] = video_image item.info['plot'] = video_plot item.info['duration'] = video_duration item.set_callback(get_video_url, item_id=item_id, data_video_id=video_id, item_dict=item2dict(item)) item_post_treatment(item) yield item
def list_video_more_infos(plugin, item_id, video_url_info, **kwargs): resp = urlquick.get(video_url_info) json_parser = json.loads(resp.text) video_title = json_parser["seoTitle"] video_image = json_parser["image"]["pathHorizontal"] video_plot = json_parser["seoDescription"] video_duration = int(json_parser["duration"]) video_url = json_parser["urlVideo"] item = Listitem() item.label = video_title item.art['thumb'] = video_image item.info['duration'] = video_duration item.info['plot'] = video_plot item.set_callback(get_video_url, item_id=item_id, video_url=video_url, video_label=LABELS[item_id] + ' - ' + item.label, item_dict=item2dict(item)) item_post_treatment(item, is_playable=True, is_downloadable=True) yield item
def list_videos(plugin, item_id, program_id, sub_category_id, **kwargs): url = '' if sub_category_id is None: url = URL_VIDEOS2 % program_id else: url = URL_VIDEOS % (program_id, sub_category_id) resp = urlquick.get(url, headers={ 'User-Agent': web_utils.get_random_ua, 'x-customer-name': 'rtlbe' }) json_parser = json.loads(resp.text) # TO DO Playlist More one 'clips' at_least_one_item = False for video in json_parser: video_id = str(video['id']) title = video['title'] duration = video['clips'][0]['duration'] description = '' if 'description' in video: description = video['description'] try: aired = video['clips'][0]['product']['last_diffusion'] aired = aired aired = aired[:10] # year = aired[:4] # date : string (%d.%m.%Y / 01.01.2009) # aired : string (2008-12-07) # day = aired.split('-')[2] # mounth = aired.split('-')[1] # year = aired.split('-')[0] # date = '.'.join((day, mounth, year)) except Exception: aired = '' # year = '' # date = '' img = '' program_imgs = video['clips'][0]['images'] program_img = '' for img in program_imgs: if img['role'] == 'vignette': external_key = img['external_key'] program_img = URL_IMG % (external_key) item = Listitem() at_least_one_item = True item.label = title item.info['plot'] = description item.info['duration'] = duration item.art["thumb"] = program_img item.art["fanart"] = program_img try: item.info.date(aired, '%Y-%m-%d') except Exception: pass is_downloadable = False if cqu.get_kodi_version() < 18: is_downloadable = True item.set_callback(get_video_url, item_id=item_id, video_id=video_id, video_label=LABELS[item_id] + ' - ' + item.label, item_dict=item2dict(item)) item_post_treatment(item, is_playable=True, is_downloadable=is_downloadable) yield item if not at_least_one_item: plugin.notify(plugin.localize(LABELS['No videos found']), '') yield False
def list_videos_franchise(plugin, item_id, program_url, **kwargs): if 'page=' in program_url: resp = urlquick.get(program_url + '&ApiKey=%s' % (API_KEY)) json_parser = json.loads(resp.text) for video_datas in json_parser["items"]: if 'seasonNumber' in video_datas and video_datas[ 'seasonNumber'] is not None: video_title = video_datas["title"] + " - S%sE%s" % ( str(video_datas['seasonNumber']), str(video_datas['episodeNumber'])) else: video_title = video_datas["title"] if 'header' in video_datas["images"]: video_image = URL_IMAGE % video_datas["images"]["header"]["id"] else: video_image = '' video_plot = video_datas["description"] video_id = video_datas["id"] video_duration = video_datas["duration"] date_value = video_datas['broadcastDate'].split('T')[0] item = Listitem() item.label = video_title item.art['thumb'] = video_image item.info['plot'] = video_plot item.info['duration'] = video_duration item.info.date(date_value, "%Y-%m-%d") item.set_callback(get_video_url, item_id=item_id, video_id=video_id, item_dict=item2dict(item)) item_post_treatment(item, is_playable=True, is_downloadable=False) yield item if 'next' in json_parser["_links"]: yield Listitem.next_page( item_id=item_id, program_url=json_parser["_links"]['next']['href']) else: resp = urlquick.get(program_url + '?ApiKey=%s' % (API_KEY)) json_parser = json.loads(resp.text) for video_datas in json_parser["components"][2]["data"]["items"]: if 'seasonNumber' in video_datas and video_datas[ 'seasonNumber'] is not None: video_title = video_datas["title"] + " - S%sE%s" % ( str(video_datas['seasonNumber']), str(video_datas['episodeNumber'])) else: video_title = video_datas["title"] if 'header' in video_datas["images"]: video_image = URL_IMAGE % video_datas["images"]["header"]["id"] else: video_image = '' video_plot = video_datas["description"] video_id = video_datas["id"] video_duration = video_datas["duration"] date_value = video_datas['broadcastDate'].split('T')[0] item = Listitem() item.label = video_title item.art['thumb'] = video_image item.info['plot'] = video_plot item.info['duration'] = video_duration item.info.date(date_value, "%Y-%m-%d") item.set_callback(get_video_url, item_id=item_id, video_id=video_id, item_dict=item2dict(item)) item_post_treatment(item, is_playable=True, is_downloadable=False) yield item if 'next' in json_parser["components"][2]["data"]["_links"]: yield Listitem.next_page(item_id=item_id, program_url=json_parser["components"][2] ["data"]["_links"]['next']['href'])
def tv_guide_menu(plugin, **kwargs): # Move up and move down action only work with this sort method plugin.add_sort_methods(xbmcplugin.SORT_METHOD_UNSORTED) menu_id = kwargs.get('item_id') menu = get_sorted_menu(plugin, menu_id) channels_id = [] for index, (channel_order, channel_id, channel_infos) in enumerate(menu): channels_id.append(channel_id) # Load the graber module accroding to the country # (e.g. resources.lib.channels.tv_guides.fr_live) tv_guide_module_path = 'resources.lib.channels.tv_guides.' + menu_id tv_guide_module = importlib.import_module(tv_guide_module_path) # For each channel grab the current program according to the current time tv_guide = tv_guide_module.grab_tv_guide(channels_id) for index, (channel_order, channel_id, channel_infos) in enumerate(menu): item = Listitem() # Set item label item.label = get_item_label(channel_id) # Set item art if 'thumb' in channel_infos: item.art["thumb"] = common.get_item_media_path( channel_infos['thumb']) if 'fanart' in channel_infos: item.art["fanart"] = common.get_item_media_path( channel_infos['fanart']) # If this item requires a module to work, get # the module path to be loaded if 'module' in channel_infos: item.params['item_module'] = channel_infos['module'] # If we have program infos from the grabber if channel_id in tv_guide: guide_infos = tv_guide[channel_id] if 'title' in guide_infos: item.label = item.label + ' — ' + guide_infos['title'] item.info['originaltitle'] = guide_infos.get('originaltitle') # e.g Divertissement, Documentaire, Film, ... item.info['genre'] = guide_infos.get('genre') plot = [] if 'specific_genre' in guide_infos: if 'genre' not in guide_infos: item.info['genre'] = guide_infos['specific_genre'] elif guide_infos.get('genre') in guide_infos['specific_genre']: item.info['genre'] = guide_infos['specific_genre'] else: plot.append(guide_infos['specific_genre']) # start_time and stop_time must be a string if 'start_time' in guide_infos and 'stop_time' in guide_infos: plot.append(guide_infos['start_time'] + ' - ' + guide_infos['stop_time']) elif 'start_time' in guide_infos: plot.append(guide_infos['start_time']) if 'subtitle' in guide_infos: plot.append(guide_infos['subtitle']) if 'plot' in guide_infos: plot.append(guide_infos['plot']) item.info['plot'] = '\n'.join(plot) item.info['episode'] = guide_infos.get('episode') item.info['season'] = guide_infos.get('season') item.info["rating"] = guide_infos.get('rating') item.info["duration"] = guide_infos.get('duration') if 'fanart' in guide_infos: item.art["fanart"] = guide_infos['fanart'] if 'thumb' in guide_infos: item.art["thumb"] = guide_infos['thumb'] item.params['item_id'] = channel_id item.params['item_dict'] = item2dict(item) # Get the next action to trigger if this # item will be selected by the user item.set_callback(eval(channel_infos['callback'])) add_context_menus_to_item(plugin, item, index, menu_id, len(menu), is_playable=True, channel_infos=channel_infos) yield item