2015-04-30 22:49:06 +02:00
|
|
|
from .common import InfoExtractor
|
2022-12-10 00:43:10 +01:00
|
|
|
from .uplynk import UplynkPreplayIE
|
2023-07-09 09:53:02 +02:00
|
|
|
from ..networking import HEADRequest
|
|
|
|
from ..utils import float_or_none, make_archive_id, smuggle_url
|
2015-04-30 22:49:06 +02:00
|
|
|
|
|
|
|
|
|
|
|
class FoxSportsIE(InfoExtractor):
|
2022-12-10 00:43:10 +01:00
|
|
|
_VALID_URL = r'https?://(?:www\.)?foxsports\.com/watch/(?P<id>[\w-]+)'
|
|
|
|
_TESTS = [{
|
|
|
|
'url': 'https://www.foxsports.com/watch/play-612168c6700004b',
|
2015-04-30 22:49:06 +02:00
|
|
|
'info_dict': {
|
2022-12-10 00:43:10 +01:00
|
|
|
'id': 'b72f5bd8658140baa5791bb676433733',
|
2016-06-19 06:45:48 +02:00
|
|
|
'ext': 'mp4',
|
2022-12-10 00:43:10 +01:00
|
|
|
'display_id': 'play-612168c6700004b',
|
|
|
|
'title': 'md5:e0c4ecac3a1f25295b4fae22fb5c126a',
|
|
|
|
'description': 'md5:371bc43609708ae2b9e1a939229762af',
|
|
|
|
'uploader_id': '06b4a36349624051a9ba52ac3a91d268',
|
|
|
|
'upload_date': '20221205',
|
|
|
|
'timestamp': 1670262586,
|
|
|
|
'duration': 31.7317,
|
|
|
|
'thumbnail': r're:^https?://.*\.jpg$',
|
|
|
|
'extra_param_to_segment_url': str,
|
2015-04-30 22:49:06 +02:00
|
|
|
},
|
2018-11-21 12:08:46 +01:00
|
|
|
'params': {
|
2022-12-10 00:43:10 +01:00
|
|
|
'skip_download': 'm3u8',
|
2018-11-21 12:08:46 +01:00
|
|
|
},
|
2022-12-10 00:43:10 +01:00
|
|
|
}]
|
2015-04-30 22:49:06 +02:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
video_id = self._match_id(url)
|
2022-12-10 00:43:10 +01:00
|
|
|
webpage = self._download_webpage(url, video_id)
|
|
|
|
json_ld = self._search_json_ld(webpage, video_id, expected_type='VideoObject', default={})
|
|
|
|
data = self._download_json(
|
|
|
|
f'https://api3.fox.com/v2.0/vodplayer/sportsclip/{video_id}',
|
|
|
|
video_id, note='Downloading API JSON', headers={
|
|
|
|
'x-api-key': 'cf289e299efdfa39fb6316f259d1de93',
|
|
|
|
})
|
|
|
|
preplay_url = self._request_webpage(
|
2023-07-09 09:53:02 +02:00
|
|
|
HEADRequest(data['url']), video_id, 'Fetching preplay URL').url
|
2015-04-30 22:49:06 +02:00
|
|
|
|
2022-12-10 00:43:10 +01:00
|
|
|
return {
|
|
|
|
'_type': 'url_transparent',
|
|
|
|
'ie_key': UplynkPreplayIE.ie_key(),
|
|
|
|
'url': smuggle_url(preplay_url, {'Origin': 'https://www.foxsports.com'}),
|
|
|
|
'display_id': video_id,
|
|
|
|
'title': data.get('name') or json_ld.get('title'),
|
|
|
|
'description': data.get('description') or json_ld.get('description'),
|
|
|
|
'duration': float_or_none(data.get('durationInSeconds')),
|
|
|
|
'timestamp': json_ld.get('timestamp'),
|
|
|
|
'thumbnails': json_ld.get('thumbnails'),
|
|
|
|
'_old_archive_ids': [make_archive_id(self, video_id)],
|
|
|
|
}
|