[ie/wistia] Support password-protected videos (#11100)
[yt-dlp3.git] / yt_dlp / extractor / fifa.py
blobae837f6a0203aeabbd53b949ee13615c952a426a
1 from .common import InfoExtractor
2 from ..utils import (
3 int_or_none,
4 traverse_obj,
5 unified_timestamp,
9 class FifaIE(InfoExtractor):
10 _VALID_URL = r'https?://www\.fifa\.com/fifaplus/(?P<locale>\w{2})/watch/([^#?]+/)?(?P<id>\w+)'
11 _TESTS = [{
12 'url': 'https://www.fifa.com/fifaplus/en/watch/7on10qPcnyLajDDU3ntg6y',
13 'info_dict': {
14 'id': '7on10qPcnyLajDDU3ntg6y',
15 'title': 'Italy v France | Final | 2006 FIFA World Cup Germany™ | Full Match Replay',
16 'description': 'md5:f4520d0ee80529c8ba4134a7d692ff8b',
17 'ext': 'mp4',
18 'categories': ['FIFA Tournaments'],
19 'thumbnail': 'https://digitalhub.fifa.com/transform/135e2656-3a51-407b-8810-6c34bec5b59b/FMR_2006_Italy_France_Final_Hero',
20 'duration': 8165,
21 'release_timestamp': 1152403200,
22 'release_date': '20060709',
24 'params': {'skip_download': 'm3u8'},
25 }, {
26 'url': 'https://www.fifa.com/fifaplus/pt/watch/1cg5r5Qt6Qt12ilkDgb1sV',
27 'info_dict': {
28 'id': '1cg5r5Qt6Qt12ilkDgb1sV',
29 'title': 'Brazil v Germany | Semi-finals | 2014 FIFA World Cup Brazil™ | Extended Highlights',
30 'description': 'md5:d908c74ee66322b804ae2e521b02a855',
31 'ext': 'mp4',
32 'categories': ['FIFA Tournaments', 'Highlights'],
33 'thumbnail': 'https://digitalhub.fifa.com/transform/d8fe6f61-276d-4a73-a7fe-6878a35fd082/FIFAPLS_100EXTHL_2014BRAvGER_TMB',
34 'duration': 902,
35 'release_timestamp': 1404777600,
36 'release_date': '20140708',
38 'params': {'skip_download': 'm3u8'},
39 }, {
40 'url': 'https://www.fifa.com/fifaplus/fr/watch/3C6gQH9C2DLwzNx7BMRQdp',
41 'info_dict': {
42 'id': '3C6gQH9C2DLwzNx7BMRQdp',
43 'title': 'Josimar goal against Northern Ireland | Classic Goals',
44 'description': 'md5:cbe7e7bb52f603c9f1fe9a4780fe983b',
45 'ext': 'mp4',
46 'categories': ['FIFA Tournaments', 'Goal'],
47 'duration': 28,
48 'thumbnail': 'https://digitalhub.fifa.com/transform/f9301391-f8d9-48b5-823e-c093ac5e3e11/CG_MEN_1986_JOSIMAR',
50 'params': {'skip_download': 'm3u8'},
53 def _real_extract(self, url):
54 video_id, locale = self._match_valid_url(url).group('id', 'locale')
55 webpage = self._download_webpage(url, video_id)
57 preconnect_link = self._search_regex(
58 r'<link\b[^>]+\brel\s*=\s*"preconnect"[^>]+href\s*=\s*"([^"]+)"', webpage, 'Preconnect Link')
60 video_details = self._download_json(
61 f'{preconnect_link}/sections/videoDetails/{video_id}', video_id, 'Downloading Video Details', fatal=False)
63 preplay_parameters = self._download_json(
64 f'{preconnect_link}/videoPlayerData/{video_id}', video_id, 'Downloading Preplay Parameters')['preplayParameters']
66 content_data = self._download_json(
67 'https://content.uplynk.com/preplay/{contentId}/multiple.json?{queryStr}&sig={signature}'.format(**preplay_parameters),
68 video_id, 'Downloading Content Data')
70 formats, subtitles = self._extract_m3u8_formats_and_subtitles(content_data['playURL'], video_id)
72 return {
73 'id': video_id,
74 'title': video_details.get('title'),
75 'description': video_details.get('description'),
76 'duration': int_or_none(video_details.get('duration')),
77 'release_timestamp': unified_timestamp(video_details.get('dateOfRelease')),
78 'categories': traverse_obj(video_details, (('videoCategory', 'videoSubcategory'),)),
79 'thumbnail': traverse_obj(video_details, ('backgroundImage', 'src')),
80 'formats': formats,
81 'subtitles': subtitles,