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