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