def _list_videos(html): pattern_video = '<li class="teaser">(.*?)</li>' pattern_video_data = 'href="(.*?)".*?<img src="(.*?)".*?"title">(.*?)<' videos = re.findall(pattern_video, html, re.DOTALL) parser = HTMLParser() for video in videos: if '<div class="video_indicator">' in video: try: video_data = re.findall(pattern_video_data, video, re.DOTALL)[0] except: continue url, thumb, title = video_data title = parser.unescape(title.decode('utf-8', 'ignore')) thumb = parser.unescape(thumb.decode('utf-8', 'ignore')) gui.add_video(title, thumb, {'f': 'play', 'url': url}) # now look for more videos button index_more_videos = html.find( '<div class="more jsb_ jsb_MoreTeasersButton" data-jsb="') if index_more_videos != -1: url_more_videos = html[index_more_videos + 55:html.find('"', index_more_videos + 55)] if url_more_videos.startswith('url='): url_more_videos = url_more_videos[4:] gui.add_folder('[B]Nächste Seite[/B]', None, { 'f': 'more', 'url': url_more_videos })
def list_videos(resource, reliveOnly): try: json_url = RAN_API_BASE + resource print ("###########"+json_url) response = requests.get(json_url, headers={'Accept-Encoding': 'gzip'}) videos = response.json()['contents'] except: return gui.end_listing() try: is_livestream = videos[0]['type'] == 'livestream' except (KeyError, IndexError): is_livestream = False if is_livestream: videos = sorted(videos, key=lambda k: k.get('streamdate_start')) timestamp_now = time.time() for video in videos: if is_livestream: stream_date_end = video['streamdate_end'] if stream_date_end >= timestamp_now: stream_date_start = video['streamdate_start'] if stream_date_start <= timestamp_now: duration_in_seconds = stream_date_end - timestamp_now playable = True print("YYY: "+video["resource"]) title = '[B][COLOR red]%s[/COLOR][/B]' % video['teaser']['title'] year = datetime.datetime.now().year else: date = datetime.datetime.fromtimestamp(stream_date_start) year = date.year date = date.strftime('%d.%m.%Y, %H:%M') duration_in_seconds = stream_date_end - stream_date_start playable = False title = video['teaser']['title'] title = '[COLOR blue]%s[/COLOR] %s' % (date, video['teaser']['title']) else: continue else: duration_in_seconds = video['duration_in_seconds'] date = datetime.datetime.fromtimestamp(video['published']) year = date.year date = date.strftime('%d.%m.%Y') playable = True title = '[COLOR blue]%s[/COLOR] %s' % (date, video['teaser']['title']) resource = video['resource'] thumb = video['teaser']['image'] # .replace('ran_app_1280x720', 'ran_app_512x288') desc = video['teaser']['image_alt'] or video['teaser']['title'] if 'False' in reliveOnly or 'Relive' in video['teaser']['title'] or 'Re-Live' in video['teaser']['title']: gui.add_video(title, thumb, {'f': 'play', 'resource': resource}, {'Title': video['teaser']['title'], 'Plot': desc, 'Genre': 'Sport', 'Year': year}, duration_in_seconds, thumb, is_playable=playable) gui.make_info_view_possible() gui.info_view() gui.end_listing()
def list_videos(resource): try: json_url = RAN_API_BASE + resource response = requests.get(json_url, headers={'Accept-Encoding': 'gzip'}) videos = response.json()['contents'] except: return gui.end_listing() try: is_livestream = videos[0]['type'] == 'livestream' except (KeyError, IndexError): is_livestream = False if is_livestream: videos = sorted(videos, key=lambda k: k.get('streamdate_start')) timestamp_now = time.time() for video in videos: if is_livestream: stream_date_end = video['streamdate_end'] if stream_date_end >= timestamp_now: stream_date_start = video['streamdate_start'] if stream_date_start <= timestamp_now: duration_in_seconds = stream_date_end - timestamp_now playable = True title = '[B][COLOR red]%s[/COLOR][/B]' % video['teaser']['title'] year = datetime.datetime.now().year else: date = datetime.datetime.fromtimestamp(stream_date_start) year = date.year date = date.strftime('%d.%m.%Y, %H:%M') duration_in_seconds = stream_date_end - stream_date_start playable = False title = video['teaser']['title'] title = '[COLOR blue]%s[/COLOR] %s' % (date, video['teaser']['title']) else: continue else: duration_in_seconds = video['duration_in_seconds'] date = datetime.datetime.fromtimestamp(video['published']) year = date.year date = date.strftime('%d.%m.%Y') playable = True title = '[COLOR blue]%s[/COLOR] %s' % (date, video['teaser']['title']) resource = video['resource'] thumb = video['teaser']['image'] # .replace('ran_app_1280x720', 'ran_app_512x288') desc = video['teaser']['image_alt'] or video['teaser']['title'] gui.add_video(title, thumb, {'f': 'play', 'resource': resource}, {'Title': video['teaser']['title'], 'Plot': desc, 'Genre': 'Sport', 'Year': year}, duration_in_seconds, thumb, is_playable=playable) gui.make_info_view_possible() gui.info_view() gui.end_listing()
def _list_videos(html): pattern_video = '<li class="teaser">(.*?)</li>' pattern_video_data = 'href="(.*?)".*?<img src="(.*?)".*?"title">(.*?)<' videos = re.findall(pattern_video, html, re.DOTALL) parser = HTMLParser() for video in videos: if '<div class="video_indicator">' in video: try: video_data = re.findall(pattern_video_data, video, re.DOTALL)[0] except: continue url, thumb, title = video_data title = parser.unescape(title.decode('utf-8', 'ignore')) thumb = parser.unescape(thumb.decode('utf-8', 'ignore')) gui.add_video(title, thumb, {'f': 'play', 'url': url}) # now look for more videos button index_more_videos = html.find('<div class="more jsb_ jsb_MoreTeasersButton" data-jsb="') if index_more_videos != -1: url_more_videos = html[index_more_videos + 55:html.find('"', index_more_videos + 55)] if url_more_videos.startswith('url='): url_more_videos = url_more_videos[4:] gui.add_folder('[B]Nächste Seite[/B]', None, {'f': 'more', 'url': url_more_videos})