2 from __future__ import unicode_literals
6 from .common import InfoExtractor
7 from .brightcove import BrightcoveLegacyIE
12 from ..utils import smuggle_url
15 class RMCDecouverteIE(InfoExtractor):
16 _VALID_URL = r'https?://rmcdecouverte\.bfmtv\.com/(?:(?:[^/]+/)*program_(?P<id>\d+)|(?P<live_id>mediaplayer-direct))'
19 'url': 'https://rmcdecouverte.bfmtv.com/wheeler-dealers-occasions-a-saisir/program_2566/',
21 'id': '5983675500001',
24 'description': 'md5:c1e8295521e45ffebf635d6a7658f506',
25 'uploader_id': '1969646226001',
26 'upload_date': '20181226',
27 'timestamp': 1545861635,
30 'skip_download': True,
32 'skip': 'only available for a week',
34 # live, geo restricted, bypassable
35 'url': 'https://rmcdecouverte.bfmtv.com/mediaplayer-direct/',
36 'only_matching': True,
38 BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/1969646226001/default_default/index.html?videoId=%s'
40 def _real_extract(self, url):
41 mobj = re.match(self._VALID_URL, url)
42 display_id = mobj.group('id') or mobj.group('live_id')
43 webpage = self._download_webpage(url, display_id)
44 brightcove_legacy_url = BrightcoveLegacyIE._extract_brightcove_url(webpage)
45 if brightcove_legacy_url:
46 brightcove_id = compat_parse_qs(compat_urlparse.urlparse(
47 brightcove_legacy_url).query)['@videoPlayer'][0]
49 brightcove_id = self._search_regex(
50 r'data-video-id=["\'](\d+)', webpage, 'brightcove id')
51 return self.url_result(
53 self.BRIGHTCOVE_URL_TEMPLATE % brightcove_id,
54 {'geo_countries': ['FR']}),
55 'BrightcoveNew', brightcove_id)