]>
Commit | Line | Data |
---|---|---|
dcdb292f | 1 | # coding: utf-8 |
6656a824 RA |
2 | from __future__ import unicode_literals |
3 | ||
d9f1123c S |
4 | import re |
5 | ||
6656a824 RA |
6 | from .common import InfoExtractor |
7 | from .brightcove import BrightcoveLegacyIE | |
8 | from ..compat import ( | |
9 | compat_parse_qs, | |
10 | compat_urlparse, | |
11 | ) | |
d9f1123c | 12 | from ..utils import smuggle_url |
6656a824 RA |
13 | |
14 | ||
15 | class RMCDecouverteIE(InfoExtractor): | |
d8ec40b3 | 16 | _VALID_URL = r'https?://rmcdecouverte\.bfmtv\.com/(?:[^?#]*_(?P<id>\d+)|mediaplayer-direct)/?(?:[#?]|$)' |
6656a824 | 17 | |
d9f1123c | 18 | _TESTS = [{ |
88f06afc | 19 | 'url': 'https://rmcdecouverte.bfmtv.com/vestiges-de-guerre_22240/les-bunkers-secrets-domaha-beach_25303/', |
20 | 'info_dict': { | |
21 | 'id': '6250879771001', | |
22 | 'ext': 'mp4', | |
23 | 'title': 'LES BUNKERS SECRETS D´OMAHA BEACH', | |
24 | 'uploader_id': '1969646226001', | |
25 | 'description': 'md5:aed573ca24abde62a148e0eba909657d', | |
26 | 'timestamp': 1619622984, | |
27 | 'upload_date': '20210428', | |
28 | }, | |
29 | 'params': { | |
30 | 'format': 'bestvideo', | |
31 | 'skip_download': True, | |
32 | }, | |
33 | }, { | |
3d8eb6be | 34 | 'url': 'https://rmcdecouverte.bfmtv.com/wheeler-dealers-occasions-a-saisir/program_2566/', |
6656a824 | 35 | 'info_dict': { |
3d8eb6be | 36 | 'id': '5983675500001', |
6656a824 | 37 | 'ext': 'mp4', |
3d8eb6be A |
38 | 'title': 'CORVETTE', |
39 | 'description': 'md5:c1e8295521e45ffebf635d6a7658f506', | |
6656a824 | 40 | 'uploader_id': '1969646226001', |
3d8eb6be A |
41 | 'upload_date': '20181226', |
42 | 'timestamp': 1545861635, | |
6656a824 RA |
43 | }, |
44 | 'params': { | |
6656a824 RA |
45 | 'skip_download': True, |
46 | }, | |
566fbbae | 47 | 'skip': 'only available for a week', |
d8ec40b3 | 48 | }, { |
49 | 'url': 'https://rmcdecouverte.bfmtv.com/avions-furtifs-la-technologie-de-lextreme_10598', | |
50 | 'only_matching': True, | |
d908aa63 | 51 | }, { |
d8ec40b3 | 52 | # The website accepts any URL as long as it has _\d+ at the end |
53 | 'url': 'https://rmcdecouverte.bfmtv.com/any/thing/can/go/here/_10598', | |
54 | 'only_matching': True, | |
d9f1123c S |
55 | }, { |
56 | # live, geo restricted, bypassable | |
57 | 'url': 'https://rmcdecouverte.bfmtv.com/mediaplayer-direct/', | |
58 | 'only_matching': True, | |
59 | }] | |
6656a824 RA |
60 | BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/1969646226001/default_default/index.html?videoId=%s' |
61 | ||
62 | def _real_extract(self, url): | |
d9f1123c | 63 | mobj = re.match(self._VALID_URL, url) |
d8ec40b3 | 64 | display_id = mobj.group('id') or 'direct' |
d9f1123c | 65 | webpage = self._download_webpage(url, display_id) |
6656a824 | 66 | brightcove_legacy_url = BrightcoveLegacyIE._extract_brightcove_url(webpage) |
74c09c85 | 67 | if brightcove_legacy_url: |
566fbbae S |
68 | brightcove_id = compat_parse_qs(compat_urlparse.urlparse( |
69 | brightcove_legacy_url).query)['@videoPlayer'][0] | |
74c09c85 | 70 | else: |
566fbbae S |
71 | brightcove_id = self._search_regex( |
72 | r'data-video-id=["\'](\d+)', webpage, 'brightcove id') | |
73 | return self.url_result( | |
d9f1123c S |
74 | smuggle_url( |
75 | self.BRIGHTCOVE_URL_TEMPLATE % brightcove_id, | |
76 | {'geo_countries': ['FR']}), | |
77 | 'BrightcoveNew', brightcove_id) |