[cleanup] Make more playlist entries lazy (#11763)
[yt-dlp.git] / yt_dlp / extractor / cozytv.py
blobb84dd2ad5e72773be7b0391239a474a9f3c36ca6
1 from .common import InfoExtractor
2 from ..utils import unified_strdate
5 class CozyTVIE(InfoExtractor):
6 _VALID_URL = r'https?://(?:www\.)?cozy\.tv/(?P<uploader>[^/]+)/replays/(?P<id>[^/$#&?]+)'
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,
19 'params': {'skip_download': True},
22 def _real_extract(self, url):
23 uploader, date = self._match_valid_url(url).groups()
24 video_id = f'{uploader}-{date}'
25 data_json = self._download_json(f'https://api.cozy.tv/cache/{uploader}/replay/{date}', video_id)
26 formats, subtitles = self._extract_m3u8_formats_and_subtitles(
27 f'https://cozycdn.foxtrotstream.xyz/replays/{uploader}/{date}/index.m3u8', video_id, ext='mp4')
28 return {
29 'id': video_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,