]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/cozytv.py
[ie/youtube] Suppress "Unavailable videos are hidden" warning (#10159)
[yt-dlp.git] / yt_dlp / extractor / cozytv.py
CommitLineData
77fcc651
AG
1from .common import InfoExtractor
2from ..utils import unified_strdate
3
4
5class CozyTVIE(InfoExtractor):
73f035e1 6 _VALID_URL = r'https?://(?:www\.)?cozy\.tv/(?P<uploader>[^/]+)/replays/(?P<id>[^/$#&?]+)'
77fcc651
AG
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 },
add96eb9 19 'params': {'skip_download': True},
77fcc651
AG
20 }]
21
22 def _real_extract(self, url):
23 uploader, date = self._match_valid_url(url).groups()
add96eb9 24 video_id = f'{uploader}-{date}'
25 data_json = self._download_json(f'https://api.cozy.tv/cache/{uploader}/replay/{date}', video_id)
77fcc651 26 formats, subtitles = self._extract_m3u8_formats_and_subtitles(
add96eb9 27 f'https://cozycdn.foxtrotstream.xyz/replays/{uploader}/{date}/index.m3u8', video_id, ext='mp4')
77fcc651 28 return {
add96eb9 29 'id': video_id,
77fcc651
AG
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 }