Skip to content

Commit

Permalink
[FR - BFM] Add fallback for BFMs live
Browse files Browse the repository at this point in the history
  • Loading branch information
joaopa00 committed Nov 25, 2024
1 parent c808450 commit 9026e81
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 26 deletions.
53 changes: 32 additions & 21 deletions resources/lib/channels/fr/bfmtv.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from resources.lib.addon_utils import Quality
from resources.lib.menu_utils import item_post_treatment
from resources.lib.py_utils import old_div
from resources.lib.channels.fr import rmcbfmplay


# TO DO
Expand All @@ -42,10 +43,10 @@

# URL Live
# Channel BFMTV
URL_LIVE_BFMTV = 'http://www.bfmtv.com/mediaplayer/live-video/'
URL_LIVE_BFMTV = 'https://www.bfmtv.com/en-direct/'

# Channel BFM Business
URL_LIVE_BFMBUSINESS = 'http://bfmbusiness.bfmtv.com/mediaplayer/live-video/'
URL_LIVE_BFMBUSINESS = 'https://www.bfmtv.com/economie/en-direct/'

# Channel BFM Business
URL_LIVE_BFM2 = 'https://www.bfmtv.com/en-direct/bfm2/'
Expand All @@ -68,6 +69,16 @@ def get_token(item_id):
return json_parser['session']['token']


def BFM_brightcove(plugin, live_url):
resp = urlquick.get(live_url, headers=GENERIC_HEADERS, max_age=-1)
root = resp.parse()
live_datas = root.find(".//video-js")
account = live_datas.get('data-account')
video_id = live_datas.get('data-video-id')
player = live_datas.get('adjustplayer')
return resolver_proxy.get_brightcove_video_json(plugin, account, player, video_id)


@Route.register
def list_programs(plugin, item_id, **kwargs):

Expand Down Expand Up @@ -206,22 +217,22 @@ def get_video_url(plugin,
@Resolver.register
def get_live_url(plugin, item_id, **kwargs):

if item_id == 'bfmtv':
return resolver_proxy.get_stream_dailymotion(plugin, LIVE_DAILYMOTION_ID[item_id], False)

elif item_id == 'bfmbusiness':
resp = urlquick.get(URL_LIVE_BFMBUSINESS, headers=GENERIC_HEADERS, max_age=-1)
root = resp.parse()
live_datas = root.find(".//div[@class='video_block']")
account = live_datas.get('accountid')
video_id = live_datas.get('videoid')
player = live_datas.get('playerid')
else:
resp = urlquick.get(URL_LIVE_BFM2, headers=GENERIC_HEADERS, max_age=-1)
root = resp.parse()
live_datas = root.find(".//video-js")
account = live_datas.get('data-account')
video_id = live_datas.get('data-video-id')
player = live_datas.get('adjustplayer')

return resolver_proxy.get_brightcove_video_json(plugin, account, player, video_id)
if item_id == 'BFM TV':
try:
return resolver_proxy.get_stream_dailymotion(plugin, LIVE_DAILYMOTION_ID[item_id], False)
except Exception:
try:
return BFM_brightcove(plugin, URL_LIVE_BFMTV)
except Exception:
return rmcbfmplay.bfm_player(plugin, item_id)

try:
if item_id == 'BFM Business':
live_url = URL_LIVE_BFMBUSINESS
if item_id == 'BFM2':
live_url = URL_LIVE_BFM2

return BFM_brightcove(plugin, live_url)

except Exception:
return rmcbfmplay.bfm_player(plugin, item_id)
9 changes: 6 additions & 3 deletions resources/lib/channels/fr/rmcbfmplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,7 @@ def playpodcast(plugin, path, title, **kwargs):
return item


@Resolver.register
def get_live_url(plugin, item_id, **kwargs):

def bfm_player(plugin, item_id, **kwargs):
headers = {
'User-Agent': web_utils.get_random_windows_ua(),
'Content-type': 'application/json',
Expand Down Expand Up @@ -374,3 +372,8 @@ def get_live_url(plugin, item_id, **kwargs):
'Content-Type': ''
}
return resolver_proxy.get_stream_with_quality(plugin, video_url=video_url, license_url=LICENSE_URL, manifest_type='mpd', headers=headers)


@Resolver.register
def get_live_url(plugin, item_id, **kwargs):
return bfm_player(plugin, item_id, **kwargs)
4 changes: 2 additions & 2 deletions resources/lib/skeletons/fr_live.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
'order': 13
},
'BFM TV': {
'resolver': '/resources/lib/channels/fr/rmcbfmplay:get_live_url',
'resolver': '/resources/lib/channels/fr/bfmtv:get_live_url',
'label': 'BFM TV',
'thumb': 'channels/fr/bfmtv.png',
'fanart': 'channels/fr/bfmtv_fanart.jpg',
Expand Down Expand Up @@ -693,7 +693,7 @@
'order': 64
},
'BFM Business': {
'resolver': '/resources/lib/channels/fr/rmcbfmplay:get_live_url',
'resolver': '/resources/lib/channels/fr/bfmtv:get_live_url',
'label': 'BFM Business',
'thumb': 'channels/fr/bfmbusiness.png',
'fanart': 'channels/fr/bfmbusiness_fanart.jpg',
Expand Down

0 comments on commit 9026e81

Please sign in to comment.