diff options
Diffstat (limited to 'plugin.video.catchuptvandmore/resources/lib/channels/fr/lcp.py')
-rw-r--r--[-rwxr-xr-x] | plugin.video.catchuptvandmore/resources/lib/channels/fr/lcp.py | 170 |
1 files changed, 102 insertions, 68 deletions
diff --git a/plugin.video.catchuptvandmore/resources/lib/channels/fr/lcp.py b/plugin.video.catchuptvandmore/resources/lib/channels/fr/lcp.py index e1065d9..60de692 100755..100644 --- a/plugin.video.catchuptvandmore/resources/lib/channels/fr/lcp.py +++ b/plugin.video.catchuptvandmore/resources/lib/channels/fr/lcp.py @@ -47,8 +47,10 @@ URL_LIVE_SITE = 'http://www.lcp.fr/le-direct' URL_DAILYMOTION_EMBED = 'http://www.dailymotion.com/embed/video/%s' -URL_VIDEO_REPLAY = 'http://play1.qbrick.com/config/avp/v1/player/media/%s/darkmatter/%s/' -#VideoID, AccountId +URL_VIDEO_REPLAY = 'http://play1.qbrick.com/config/avp/v1/player/' \ + 'media/%s/darkmatter/%s/' +# VideoID, AccountId + def channel_entry(params): """Entry function of the module""" @@ -63,35 +65,37 @@ def channel_entry(params): elif 'play' in params.next: return get_video_url(params) + CATEGORIES = { - 'http://www.lcp.fr/actualites' : 'Actualités', - 'http://www.lcp.fr/emissions' : 'Émissions', - 'http://www.lcp.fr/documentaires' : 'Documentaires' + 'http://www.lcp.fr/actualites': 'Actualités', + 'http://www.lcp.fr/emissions': 'Émissions', + 'http://www.lcp.fr/documentaires': 'Documentaires' } CORRECT_MOUNTH = { - 'janvier' : '01', - 'février' : '02', - 'mars' : '03', - 'avril' : '04', - 'mai' : '05', - 'juin' : '06', - 'juillet' : '07', - 'août' : '08', - 'septembre' : '09', - 'octobre' : '10', - 'novembre' : '11', - 'décembre' : '12' + 'janvier': '01', + 'février': '02', + 'mars': '03', + 'avril': '04', + 'mai': '05', + 'juin': '06', + 'juillet': '07', + 'août': '08', + 'septembre': '09', + 'octobre': '10', + 'novembre': '11', + 'décembre': '12' } -@common.PLUGIN.cached(common.CACHE_TIME) + +@common.PLUGIN.mem_cached(common.CACHE_TIME) def root(params): """Add Replay and Live in the listing""" modes = [] # Add Replay Desactiver modes.append({ - 'label' : 'Replay', + 'label': 'Replay', 'url': common.PLUGIN.get_url( action='channel_entry', next='list_shows_1', @@ -102,7 +106,7 @@ def root(params): # Add Live modes.append({ - 'label' : 'Live TV', + 'label': 'Live TV', 'url': common.PLUGIN.get_url( action='channel_entry', next='live_cat', @@ -119,7 +123,8 @@ def root(params): ), ) -@common.PLUGIN.cached(common.CACHE_TIME) + +@common.PLUGIN.mem_cached(common.CACHE_TIME) def list_shows(params): """Build shows listing""" shows = [] @@ -174,26 +179,27 @@ def list_shows(params): root_html = open(file_path).read() root_soup = bs(root_html, 'html.parser') - emissions_soup = root_soup.find_all('div',class_='content') + emissions_soup = root_soup.find_all('div', class_='content') for emission in emissions_soup: emission_name = emission.find('h2').get_text().encode('utf-8') emission_img = emission.find('img')['src'].encode('utf-8') - emission_url = URL_ROOT + emission.find('a')['href'].encode('utf-8') + emission_url = URL_ROOT + emission.find( + 'a')['href'].encode('utf-8') shows.append({ - 'label': emission_name, - 'thumb': emission_img, - 'url': common.PLUGIN.get_url( - action='channel_entry', - emission_url=emission_url, - emission_name=emission_name, - page='0', - next='list_videos_emissions', - window_title=emission_name - ) - }) + 'label': emission_name, + 'thumb': emission_img, + 'url': common.PLUGIN.get_url( + action='channel_entry', + emission_url=emission_url, + emission_name=emission_name, + page='0', + next='list_videos_emissions', + window_title=emission_name + ) + }) return common.PLUGIN.create_listing( shows, @@ -203,7 +209,8 @@ def list_shows(params): ) ) -@common.PLUGIN.cached(common.CACHE_TIME) + +@common.PLUGIN.mem_cached(common.CACHE_TIME) def list_videos(params): """Build videos listing""" videos = [] @@ -227,28 +234,34 @@ def list_videos(params): root_html = open(file_path).read() root_soup = bs(root_html, 'html.parser') - video_soup = root_soup.find_all('div', class_="node node-lcp-tv-episode node-teaser clearfix") + video_soup = root_soup.find_all( + 'div', class_="node node-lcp-tv-episode node-teaser clearfix") for video in video_soup: title = video.find('h2').find('a').get_text().encode('utf-8') - value_date = video.find('div', class_="content").find('span', class_="date").get_text().encode('utf-8') + value_date = video.find( + 'div', class_="content").find( + 'span', class_="date").get_text().encode('utf-8') date = value_date.split(' ') day = date[0] try: mounth = CORRECT_MOUNTH[date[1]] - except: + except Exception: mounth = '00' year = date[2] date = '.'.join((day, mounth, year)) aired = '-'.join((year, mounth, day)) duration = 0 - duration = int(video.find('div', class_="content").find('div', class_="duration").find('div').find('span').get_text()) * 60 + duration = int( + video.find( + 'div', class_="content").find( + 'div', class_="duration").find( + 'div').find('span').get_text()) * 60 img = video.find('a').find('img')['src'].encode('utf-8') url_video = URL_ROOT + video['about'].encode('utf-8') - info = { 'video': { 'title': title, @@ -282,7 +295,7 @@ def list_videos(params): ), 'is_playable': True, 'info': info, - 'context_menu': context_menu # A ne pas oublier pour ajouter le bouton "Download" à chaque vidéo + 'context_menu': context_menu }) # More videos... @@ -315,20 +328,24 @@ def list_videos(params): root_html = open(file_path).read() root_soup = bs(root_html, 'html.parser') - video_soup = root_soup.find_all('div', class_="node node-lcp-reportage node-promoted node-teaser actu-teaser clearfix") + video_soup = root_soup.find_all( + 'div', + class_="node node-lcp-reportage " + "node-promoted node-teaser actu-teaser clearfix") for video in video_soup: title = video.find('h2').find('a').get_text().encode('utf-8') - aired = video.find('div', class_="content").find('div', class_="field field_submitted").get_text() + aired = video.find( + 'div', class_="content").find( + 'div', class_="field field_submitted").get_text() date = '' duration = 0 - year = int(aired.split('/',-1)[2]) + year = int(aired.split('/', -1)[2]) img = video.find('a').find('img')['src'].encode('utf-8') url_video = URL_ROOT + video['about'].encode('utf-8') - info = { 'video': { 'title': title, @@ -362,7 +379,7 @@ def list_videos(params): ), 'is_playable': True, 'info': info, - 'context_menu': context_menu # A ne pas oublier pour ajouter le bouton "Download" à chaque vidéo + 'context_menu': context_menu }) # More videos... @@ -382,11 +399,14 @@ def list_videos(params): elif params.next == 'list_videos_emissions': # Cas emission (2 cas) (-0) ou (sans -0) - # 1ère page http://www.lcp.fr/emissions/evenements/replay-0 (url départ => http://www.lcp.fr/emissions/evenements-0) + # 1ère page http://www.lcp.fr/emissions/evenements/replay-0 + # (url départ => http://www.lcp.fr/emissions/evenements-0) # 1ère page http://www.lcp.fr/emissions/evenements/replay-0?page=1 # ainsi de suite - # 1ère page : http://www.lcp.fr/emissions/en-voiture-citoyens/replay (url départ => http://www.lcp.fr/emissions/en-voiture-citoyens) - # 2ème page : http://www.lcp.fr/emissions/en-voiture-citoyens/replay?page=1 + # 1ère page : http://www.lcp.fr/emissions/en-voiture-citoyens/replay + # (url départ => http://www.lcp.fr/emissions/en-voiture-citoyens) + # 2ème page : + # http://www.lcp.fr/emissions/en-voiture-citoyens/replay?page=1 # ainsi de suite if params.page == 0 and '-0' not in params.emission_url: @@ -396,7 +416,8 @@ def list_videos(params): elif params.page == 0 and '-0' in params.emission_url: url = params.emission_url[:-2] + '/replay-0' elif params.page > 0 and '-0' in params.emission_url: - url = params.emission_url[:-2] + '/replay-0?page=' + str(params.page) + url = params.emission_url[:-2] + \ + '/replay-0?page=' + str(params.page) file_path = utils.download_catalog( url, @@ -407,29 +428,36 @@ def list_videos(params): root_html = open(file_path).read() root_soup = bs(root_html, 'html.parser') - video_soup = root_soup.find_all('div', class_="node node-lcp-tv-episode node-teaser clearfix") + video_soup = root_soup.find_all( + 'div', class_="node node-lcp-tv-episode node-teaser clearfix") for video in video_soup: - title = video.find('h2').find('a').get_text().encode('utf-8') + ' - ' + video.find('h4').find('a').get_text().encode('utf-8') - value_date = video.find('div', class_="content").find('span', class_="date").get_text().encode('utf-8') + title = video.find( + 'h2').find('a').get_text().encode( + 'utf-8') + ' - ' + video.find( + 'h4').find('a').get_text().encode('utf-8') + value_date = video.find( + 'div', class_="content").find( + 'span', class_="date").get_text().encode('utf-8') date = value_date.split(' ') day = date[0] try: mounth = CORRECT_MOUNTH[date[1]] - except: + except Exception: mounth = '00' year = date[2] date = '.'.join((day, mounth, year)) aired = '-'.join((year, mounth, day)) duration = 0 - duration = int(video.find('div', class_="content").find('div', class_="duration").find('div').find('span').get_text()) * 60 + duration = int(video.find('div', class_="content").find( + 'div', class_="duration").find( + 'div').find('span').get_text()) * 60 img = video.find('a').find('img')['src'].encode('utf-8') url_video = URL_ROOT + video['about'].encode('utf-8') - info = { 'video': { 'title': title, @@ -463,7 +491,7 @@ def list_videos(params): ), 'is_playable': True, 'info': info, - 'context_menu': context_menu # A ne pas oublier pour ajouter le bouton "Download" à chaque vidéo + 'context_menu': context_menu }) # More videos... @@ -494,7 +522,7 @@ def list_videos(params): ) -@common.PLUGIN.cached(common.CACHE_TIME) +@common.PLUGIN.mem_cached(common.CACHE_TIME) def list_live(params): """Build live listing""" lives = [] @@ -512,7 +540,7 @@ def list_live(params): class_='embed-responsive-item') url_live_embeded = live_soup.get('src') - url_live = 'http:%s' % url_live_embeded + url_live = 'http:%s' % url_live_embeded title = '%s Live' % params.channel_name.upper() @@ -528,7 +556,7 @@ def list_live(params): 'label': title, 'fanart': img, 'thumb': img, - 'url' : common.PLUGIN.get_url( + 'url': common.PLUGIN.get_url( action='channel_entry', next='play_l', url=url_live, @@ -545,7 +573,8 @@ def list_live(params): ) ) -@common.PLUGIN.cached(common.CACHE_TIME) + +@common.PLUGIN.mem_cached(common.CACHE_TIME) def get_video_url(params): """Get video URL and start video player""" if params.next == 'play_r' or params.next == 'download_video': @@ -553,24 +582,28 @@ def get_video_url(params): url = '' html_video = utils.get_webcontent(params.url_video) - url_video_embed = re.compile(r'<iframe src="(.*?)"').findall(html_video)[0] + url_video_embed = re.compile( + r'<iframe src="(.*?)"').findall(html_video)[0] if 'dailymotion' in url_video_embed: - url_video_embed_http = 'http:%s' % url_video_embed + url_video_embed_http = 'http:%s' % url_video_embed if params.next == 'download_video': return url_video_embed_http html_video = utils.get_webcontent(url_video_embed_http) html_video = html_video.replace('\\', '') - all_url_video = re.compile(r'"type":"video/mp4","url":"(.*?)"').findall(html_video) + all_url_video = re.compile( + r'"type":"video/mp4","url":"(.*?)"').findall(html_video) for datas in all_url_video: url = datas else: # get videoId and accountId - videoId, accountId = re.compile(r'embed/(.*?)/(.*?)/').findall(url_video_embed)[0] + videoId, accountId = re.compile( + r'embed/(.*?)/(.*?)/').findall(url_video_embed)[0] - html_json = utils.get_webcontent(URL_VIDEO_REPLAY % (videoId, accountId)) + html_json = utils.get_webcontent( + URL_VIDEO_REPLAY % (videoId, accountId)) html_json_2 = re.compile(r'\((.*?)\);').findall(html_json)[0] json_parser = json.loads(html_json_2) @@ -587,8 +620,9 @@ def get_video_url(params): html_live = utils.get_webcontent(params.url) html_live = html_live.replace('\\', '') - url_live = re.compile(r'{"type":"application/x-mpegURL","url":"(.*?)"}]}').findall(html_live) + url_live = re.compile( + r'{"type":"application/x-mpegURL","url":"(.*?)"}]}' + ).findall(html_live) # Just one flux no quality to choose return url_live[0] - |