]>
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): | |
11 | _VALID_URL = r'https?://www.fifa.com/fifaplus/(?P<locale>\w{2})/watch/(?P<id>\w+)/?' | |
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', | |
19 | 'categories': ['FIFA Tournaments', 'Replay'], | |
20 | 'thumbnail': 'https://digitalhub.fifa.com/transform/fa6f0b3e-a2e9-4cf7-9f32-53c57bcb7360/2006_Final_ITA_FRA', | |
21 | 'duration': 8164, | |
22 | }, | |
23 | 'params': {'skip_download': 'm3u8'}, | |
24 | }, { | |
25 | 'url': 'https://www.fifa.com/fifaplus/pt/watch/1cg5r5Qt6Qt12ilkDgb1sV', | |
26 | 'info_dict': { | |
27 | 'id': '1cg5r5Qt6Qt12ilkDgb1sV', | |
28 | 'title': 'Brasil x Alemanha | Semifinais | Copa do Mundo FIFA Brasil 2014 | Compacto', | |
29 | 'description': 'md5:ba4ffcc084802b062beffc3b4c4b19d6', | |
30 | 'ext': 'mp4', | |
31 | 'categories': ['FIFA Tournaments', 'Highlights'], | |
32 | 'thumbnail': 'https://digitalhub.fifa.com/transform/d8fe6f61-276d-4a73-a7fe-6878a35fd082/FIFAPLS_100EXTHL_2014BRAvGER_TMB', | |
33 | 'duration': 901, | |
34 | 'release_timestamp': 1404777600, | |
35 | 'release_date': '20140708', | |
36 | }, | |
37 | 'params': {'skip_download': 'm3u8'}, | |
38 | }, { | |
39 | 'url': 'https://www.fifa.com/fifaplus/fr/watch/3C6gQH9C2DLwzNx7BMRQdp', | |
40 | 'info_dict': { | |
41 | 'id': '3C6gQH9C2DLwzNx7BMRQdp', | |
42 | 'title': 'Le but de Josimar contre le Irlande du Nord | Buts classiques', | |
43 | 'description': 'md5:16f9f789f09960bfe7220fe67af31f34', | |
44 | 'ext': 'mp4', | |
45 | 'categories': ['FIFA Tournaments', 'Goal'], | |
46 | 'duration': 28, | |
47 | 'thumbnail': 'https://digitalhub.fifa.com/transform/f9301391-f8d9-48b5-823e-c093ac5e3e11/CG_MEN_1986_JOSIMAR', | |
48 | }, | |
49 | 'params': {'skip_download': 'm3u8'}, | |
50 | }] | |
51 | ||
52 | def _real_extract(self, url): | |
53 | video_id, locale = self._match_valid_url(url).group('id', 'locale') | |
54 | webpage = self._download_webpage(url, video_id) | |
55 | ||
56 | preconnect_link = self._search_regex( | |
57 | r'<link[^>]+rel\s*=\s*"preconnect"[^>]+href\s*=\s*"([^"]+)"', webpage, 'Preconnect Link') | |
58 | ||
59 | json_data = self._download_json( | |
60 | f'{preconnect_link}/video/GetVideoPlayerData/{video_id}', video_id, | |
61 | 'Downloading Video Player Data', query={'includeIdents': True, 'locale': locale}) | |
62 | ||
63 | video_details = self._download_json( | |
64 | f'{preconnect_link}/sections/videoDetails/{video_id}', video_id, 'Downloading Video Details', fatal=False) | |
65 | ||
66 | preplay_parameters = self._download_json( | |
67 | f'{preconnect_link}/video/GetVerizonPreplayParameters', video_id, 'Downloading Preplay Parameters', query={ | |
68 | 'entryId': video_id, | |
69 | 'assetId': json_data['verizonAssetId'], | |
70 | 'useExternalId': False, | |
71 | 'requiresToken': json_data['requiresToken'], | |
72 | 'adConfig': 'fifaplusvideo', | |
73 | 'prerollAds': True, | |
74 | 'adVideoId': json_data['externalVerizonAssetId'], | |
75 | 'preIdentId': json_data['preIdentId'], | |
76 | 'postIdentId': json_data['postIdentId'], | |
77 | }) | |
78 | ||
79 | cid = f'{json_data["preIdentId"]},{json_data["verizonAssetId"]},{json_data["postIdentId"]}' | |
80 | content_data = self._download_json( | |
81 | f'https://content.uplynk.com/preplay/{cid}/multiple.json', video_id, 'Downloading Content Data', query={ | |
82 | 'v': preplay_parameters['preplayAPIVersion'], | |
83 | 'tc': preplay_parameters['tokenCheckAlgorithmVersion'], | |
84 | 'rn': preplay_parameters['randomNumber'], | |
85 | 'exp': preplay_parameters['tokenExpirationDate'], | |
86 | 'ct': preplay_parameters['contentType'], | |
87 | 'cid': cid, | |
88 | 'mbtracks': preplay_parameters['tracksAssetNumber'], | |
89 | 'ad': preplay_parameters['adConfiguration'], | |
90 | 'ad.preroll': int(preplay_parameters['adPreroll']), | |
91 | 'ad.cmsid': preplay_parameters['adCMSSourceId'], | |
92 | 'ad.vid': preplay_parameters['adSourceVideoID'], | |
93 | 'sig': preplay_parameters['signature'], | |
94 | }) | |
95 | ||
96 | formats = self._extract_m3u8_formats( | |
97 | content_data['playURL'], video_id, note='Downloading m3u8 Information') | |
98 | ||
99 | return { | |
100 | 'id': video_id, | |
101 | 'title': json_data.get('title'), | |
102 | 'description': json_data.get('description'), | |
103 | 'duration': int_or_none(json_data.get('duration')), | |
104 | 'release_timestamp': unified_timestamp(video_details.get('dateOfRelease')), | |
105 | 'categories': traverse_obj(video_details, (('videoCategory', 'videoSubcategory'),)), | |
106 | 'thumbnail': traverse_obj(video_details, ('backgroundImage', 'src')), | |
107 | 'formats': formats, | |
108 | } |