]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/rmcdecouverte.py
422d47ae9f7f57b133679865ad00fb4f38902eca
[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 'format': 'bestvideo',
30 'skip_download': True,
31 },
32 }, {
33 'url': 'https://rmcdecouverte.bfmtv.com/wheeler-dealers-occasions-a-saisir/program_2566/',
34 'info_dict': {
35 'id': '5983675500001',
36 'ext': 'mp4',
37 'title': 'CORVETTE',
38 'description': 'md5:c1e8295521e45ffebf635d6a7658f506',
39 'uploader_id': '1969646226001',
40 'upload_date': '20181226',
41 'timestamp': 1545861635,
42 },
43 'params': {
44 'skip_download': True,
45 },
46 'skip': 'only available for a week',
47 }, {
48 'url': 'https://rmcdecouverte.bfmtv.com/avions-furtifs-la-technologie-de-lextreme_10598',
49 'only_matching': True,
50 }, {
51 # The website accepts any URL as long as it has _\d+ at the end
52 'url': 'https://rmcdecouverte.bfmtv.com/any/thing/can/go/here/_10598',
53 'only_matching': True,
54 }, {
55 # live, geo restricted, bypassable
56 'url': 'https://rmcdecouverte.bfmtv.com/mediaplayer-direct/',
57 'only_matching': True,
58 }]
59 BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/1969646226001/default_default/index.html?videoId=%s'
60
61 def _real_extract(self, url):
62 mobj = self._match_valid_url(url)
63 display_id = mobj.group('id') or 'direct'
64 webpage = self._download_webpage(url, display_id)
65 brightcove_legacy_url = BrightcoveLegacyIE._extract_brightcove_url(webpage)
66 if brightcove_legacy_url:
67 brightcove_id = compat_parse_qs(compat_urlparse.urlparse(
68 brightcove_legacy_url).query)['@videoPlayer'][0]
69 else:
70 brightcove_id = self._search_regex(
71 r'data-video-id=["\'](\d+)', webpage, 'brightcove id')
72 return self.url_result(
73 smuggle_url(
74 self.BRIGHTCOVE_URL_TEMPLATE % brightcove_id,
75 {'geo_countries': ['FR']}),
76 'BrightcoveNew', brightcove_id)