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