]>
Commit | Line | Data |
---|---|---|
6a8422b9 | 1 | from .common import InfoExtractor |
7c5e1701 | 2 | from .uplynk import UplynkPreplayIE |
3 | from ..utils import HEADRequest, float_or_none, make_archive_id, smuggle_url | |
6a8422b9 S |
4 | |
5 | ||
6 | class FoxSportsIE(InfoExtractor): | |
7c5e1701 | 7 | _VALID_URL = r'https?://(?:www\.)?foxsports\.com/watch/(?P<id>[\w-]+)' |
8 | _TESTS = [{ | |
9 | 'url': 'https://www.foxsports.com/watch/play-612168c6700004b', | |
6a8422b9 | 10 | 'info_dict': { |
7c5e1701 | 11 | 'id': 'b72f5bd8658140baa5791bb676433733', |
6cd64b68 | 12 | 'ext': 'mp4', |
7c5e1701 | 13 | 'display_id': 'play-612168c6700004b', |
14 | 'title': 'md5:e0c4ecac3a1f25295b4fae22fb5c126a', | |
15 | 'description': 'md5:371bc43609708ae2b9e1a939229762af', | |
16 | 'uploader_id': '06b4a36349624051a9ba52ac3a91d268', | |
17 | 'upload_date': '20221205', | |
18 | 'timestamp': 1670262586, | |
19 | 'duration': 31.7317, | |
20 | 'thumbnail': r're:^https?://.*\.jpg$', | |
21 | 'extra_param_to_segment_url': str, | |
6a8422b9 | 22 | }, |
6866f244 | 23 | 'params': { |
7c5e1701 | 24 | 'skip_download': 'm3u8', |
6866f244 | 25 | }, |
7c5e1701 | 26 | }] |
6a8422b9 S |
27 | |
28 | def _real_extract(self, url): | |
29 | video_id = self._match_id(url) | |
7c5e1701 | 30 | webpage = self._download_webpage(url, video_id) |
31 | json_ld = self._search_json_ld(webpage, video_id, expected_type='VideoObject', default={}) | |
32 | data = self._download_json( | |
33 | f'https://api3.fox.com/v2.0/vodplayer/sportsclip/{video_id}', | |
34 | video_id, note='Downloading API JSON', headers={ | |
35 | 'x-api-key': 'cf289e299efdfa39fb6316f259d1de93', | |
36 | }) | |
37 | preplay_url = self._request_webpage( | |
38 | HEADRequest(data['url']), video_id, 'Fetching preplay URL').geturl() | |
6a8422b9 | 39 | |
7c5e1701 | 40 | return { |
41 | '_type': 'url_transparent', | |
42 | 'ie_key': UplynkPreplayIE.ie_key(), | |
43 | 'url': smuggle_url(preplay_url, {'Origin': 'https://www.foxsports.com'}), | |
44 | 'display_id': video_id, | |
45 | 'title': data.get('name') or json_ld.get('title'), | |
46 | 'description': data.get('description') or json_ld.get('description'), | |
47 | 'duration': float_or_none(data.get('durationInSeconds')), | |
48 | 'timestamp': json_ld.get('timestamp'), | |
49 | 'thumbnails': json_ld.get('thumbnails'), | |
50 | '_old_archive_ids': [make_archive_id(self, video_id)], | |
51 | } |