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