mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-11 14:18:18 +01:00
[ESPNCricInfo] Add extractor (#1652)
Closes: #1635 Authored by: Ashish0804
This commit is contained in:
parent
450bdf69bc
commit
266a1b5d52
@ -7,7 +7,9 @@
|
||||
from ..compat import compat_str
|
||||
from ..utils import (
|
||||
determine_ext,
|
||||
dict_get,
|
||||
int_or_none,
|
||||
unified_strdate,
|
||||
unified_timestamp,
|
||||
)
|
||||
|
||||
@ -236,3 +238,44 @@ def _real_extract(self, url):
|
||||
webpage, 'embed url')
|
||||
|
||||
return self.url_result(embed_url, 'AbcNewsVideo')
|
||||
|
||||
|
||||
class ESPNCricInfoIE(InfoExtractor):
|
||||
_VALID_URL = r'https?://(?:www\.)?espncricinfo\.com/video/[^#$&?/]+-(?P<id>\d+)'
|
||||
_TESTS = [{
|
||||
'url': 'https://www.espncricinfo.com/video/finch-chasing-comes-with-risks-despite-world-cup-trend-1289135',
|
||||
'info_dict': {
|
||||
'id': '1289135',
|
||||
'ext': 'mp4',
|
||||
'title': 'Finch: Chasing comes with \'risks\' despite World Cup trend',
|
||||
'description': 'md5:ea32373303e25efbb146efdfc8a37829',
|
||||
'upload_date': '20211113',
|
||||
'duration': 96,
|
||||
},
|
||||
'params': {'skip_download': True}
|
||||
}]
|
||||
|
||||
def _real_extract(self, url):
|
||||
id = self._match_id(url)
|
||||
data_json = self._download_json(f'https://hs-consumer-api.espncricinfo.com/v1/pages/video/video-details?videoId={id}', id)['video']
|
||||
formats, subtitles = [], {}
|
||||
for item in data_json.get('playbacks') or []:
|
||||
if item.get('type') == 'HLS' and item.get('url'):
|
||||
m3u8_frmts, m3u8_subs = self._extract_m3u8_formats_and_subtitles(item['url'], id)
|
||||
formats.extend(m3u8_frmts)
|
||||
subtitles = self._merge_subtitles(subtitles, m3u8_subs)
|
||||
elif item.get('type') == 'AUDIO' and item.get('url'):
|
||||
formats.append({
|
||||
'url': item['url'],
|
||||
'vcodec': 'none',
|
||||
})
|
||||
self._sort_formats(formats)
|
||||
return {
|
||||
'id': id,
|
||||
'title': data_json.get('title'),
|
||||
'description': data_json.get('summary'),
|
||||
'upload_date': unified_strdate(dict_get(data_json, ('publishedAt', 'recordedAt'))),
|
||||
'duration': data_json.get('duration'),
|
||||
'formats': formats,
|
||||
'subtitles': subtitles,
|
||||
}
|
||||
|
@ -418,6 +418,7 @@
|
||||
ESPNIE,
|
||||
ESPNArticleIE,
|
||||
FiveThirtyEightIE,
|
||||
ESPNCricInfoIE,
|
||||
)
|
||||
from .esri import EsriVideoIE
|
||||
from .europa import EuropaIE
|
||||
|
Loading…
Reference in New Issue
Block a user