[ie/soundcloud] Various fixes (#11820)
[yt-dlp.git] / yt_dlp / extractor / rmcdecouverte.py
blobe7b1e22978f9826881479939119d594a460ce7a5
1 import urllib.parse
3 from .brightcove import BrightcoveLegacyIE
4 from .common import InfoExtractor
5 from ..utils import smuggle_url
8 class RMCDecouverteIE(InfoExtractor):
9 _VALID_URL = r'https?://rmcdecouverte\.bfmtv\.com/(?:[^?#]*_(?P<id>\d+)|mediaplayer-direct)/?(?:[#?]|$)'
11 _TESTS = [{
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',
22 'params': {
23 'skip_download': True,
25 }, {
26 'url': 'https://rmcdecouverte.bfmtv.com/wheeler-dealers-occasions-a-saisir/program_2566/',
27 'info_dict': {
28 'id': '5983675500001',
29 'ext': 'mp4',
30 'title': 'CORVETTE',
31 'description': 'md5:c1e8295521e45ffebf635d6a7658f506',
32 'uploader_id': '1969646226001',
33 'upload_date': '20181226',
34 'timestamp': 1545861635,
36 'params': {
37 'skip_download': True,
39 'skip': 'only available for a week',
40 }, {
41 'url': 'https://rmcdecouverte.bfmtv.com/avions-furtifs-la-technologie-de-lextreme_10598',
42 'only_matching': True,
43 }, {
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,
47 }, {
48 # live, geo restricted, bypassable
49 'url': 'https://rmcdecouverte.bfmtv.com/mediaplayer-direct/',
50 'only_matching': True,
52 BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/1969646226001/default_default/index.html?videoId=%s'
54 def _real_extract(self, url):
55 mobj = self._match_valid_url(url)
56 display_id = mobj.group('id') or 'direct'
57 webpage = self._download_webpage(url, display_id)
58 brightcove_legacy_url = BrightcoveLegacyIE._extract_brightcove_url(webpage)
59 if brightcove_legacy_url:
60 brightcove_id = urllib.parse.parse_qs(urllib.parse.urlparse(
61 brightcove_legacy_url).query)['@videoPlayer'][0]
62 else:
63 brightcove_id = self._search_regex(
64 r'data-video-id=["\'](\d+)', webpage, 'brightcove id')
65 return self.url_result(
66 smuggle_url(
67 self.BRIGHTCOVE_URL_TEMPLATE % brightcove_id,
68 {'geo_countries': ['FR']}),
69 'BrightcoveNew', brightcove_id)