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