]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/cozytv.py
[ie/orf:on] Improve extraction (#9677)
[yt-dlp.git] / yt_dlp / extractor / cozytv.py
1 from .common import InfoExtractor
2 from ..utils import unified_strdate
3
4
5 class CozyTVIE(InfoExtractor):
6 _VALID_URL = r'https?://(?:www\.)?cozy\.tv/(?P<uploader>[^/]+)/replays/(?P<id>[^/$#&?]+)'
7
8 _TESTS = [{
9 'url': 'https://cozy.tv/beardson/replays/2021-11-19_1',
10 'info_dict': {
11 'id': 'beardson-2021-11-19_1',
12 'ext': 'mp4',
13 'title': 'pokemon pt2',
14 'uploader': 'beardson',
15 'upload_date': '20211119',
16 'was_live': True,
17 'duration': 7981,
18 },
19 'params': {'skip_download': True}
20 }]
21
22 def _real_extract(self, url):
23 uploader, date = self._match_valid_url(url).groups()
24 id = f'{uploader}-{date}'
25 data_json = self._download_json(f'https://api.cozy.tv/cache/{uploader}/replay/{date}', id)
26 formats, subtitles = self._extract_m3u8_formats_and_subtitles(
27 f'https://cozycdn.foxtrotstream.xyz/replays/{uploader}/{date}/index.m3u8', id, ext='mp4')
28 return {
29 'id': id,
30 'title': data_json.get('title'),
31 'uploader': data_json.get('user') or uploader,
32 'upload_date': unified_strdate(data_json.get('date')),
33 'was_live': True,
34 'duration': data_json.get('duration'),
35 'formats': formats,
36 'subtitles': subtitles,
37 }