]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/rmcdecouverte.py
[test/download] Fallback test to `bv`
[yt-dlp.git] / yt_dlp / extractor / rmcdecouverte.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4
5 from .common import InfoExtractor
6 from .brightcove import BrightcoveLegacyIE
7 from ..compat import (
8 compat_parse_qs,
9 compat_urlparse,
10 )
11 from ..utils import smuggle_url
12
13
14 class RMCDecouverteIE(InfoExtractor):
15 _VALID_URL = r'https?://rmcdecouverte\.bfmtv\.com/(?:[^?#]*_(?P<id>\d+)|mediaplayer-direct)/?(?:[#?]|$)'
16
17 _TESTS = [{
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': {
29 'skip_download': True,
30 },
31 }, {
32 'url': 'https://rmcdecouverte.bfmtv.com/wheeler-dealers-occasions-a-saisir/program_2566/',
33 'info_dict': {
34 'id': '5983675500001',
35 'ext': 'mp4',
36 'title': 'CORVETTE',
37 'description': 'md5:c1e8295521e45ffebf635d6a7658f506',
38 'uploader_id': '1969646226001',
39 'upload_date': '20181226',
40 'timestamp': 1545861635,
41 },
42 'params': {
43 'skip_download': True,
44 },
45 'skip': 'only available for a week',
46 }, {
47 'url': 'https://rmcdecouverte.bfmtv.com/avions-furtifs-la-technologie-de-lextreme_10598',
48 'only_matching': True,
49 }, {
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,
53 }, {
54 # live, geo restricted, bypassable
55 'url': 'https://rmcdecouverte.bfmtv.com/mediaplayer-direct/',
56 'only_matching': True,
57 }]
58 BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/1969646226001/default_default/index.html?videoId=%s'
59
60 def _real_extract(self, url):
61 mobj = self._match_valid_url(url)
62 display_id = mobj.group('id') or 'direct'
63 webpage = self._download_webpage(url, display_id)
64 brightcove_legacy_url = BrightcoveLegacyIE._extract_brightcove_url(webpage)
65 if brightcove_legacy_url:
66 brightcove_id = compat_parse_qs(compat_urlparse.urlparse(
67 brightcove_legacy_url).query)['@videoPlayer'][0]
68 else:
69 brightcove_id = self._search_regex(
70 r'data-video-id=["\'](\d+)', webpage, 'brightcove id')
71 return self.url_result(
72 smuggle_url(
73 self.BRIGHTCOVE_URL_TEMPLATE % brightcove_id,
74 {'geo_countries': ['FR']}),
75 'BrightcoveNew', brightcove_id)