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