]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/gronkh.py
[gronkh] Support new URL pattern (#2019)
[yt-dlp.git] / yt_dlp / extractor / gronkh.py
CommitLineData
920134b2
AG
1# coding: utf-8
2from __future__ import unicode_literals
3
4from .common import InfoExtractor
5from ..utils import unified_strdate
6
7
8class GronkhIE(InfoExtractor):
375d9360 9 _VALID_URL = r'https?://(?:www\.)?gronkh\.tv/(?:watch/)?stream/(?P<id>\d+)'
920134b2
AG
10
11 _TESTS = [{
12 'url': 'https://gronkh.tv/stream/536',
13 'info_dict': {
14 'id': '536',
15 'ext': 'mp4',
16 'title': 'GTV0536, 2021-10-01 - MARTHA IS DEAD #FREiAB1830 !FF7 !horde !archiv',
17 'view_count': 19491,
18 'thumbnail': 'https://01.cdn.vod.farm/preview/6436746cce14e25f751260a692872b9b.jpg',
19 'upload_date': '20211001'
20 },
21 'params': {'skip_download': True}
375d9360
S
22 }, {
23 'url': 'https://gronkh.tv/watch/stream/546',
24 'only_matching': True,
920134b2
AG
25 }]
26
27 def _real_extract(self, url):
28 id = self._match_id(url)
29 data_json = self._download_json(f'https://api.gronkh.tv/v1/video/info?episode={id}', id)
30 m3u8_url = self._download_json(f'https://api.gronkh.tv/v1/video/playlist?episode={id}', id)['playlist_url']
31 formats, subtitles = self._extract_m3u8_formats_and_subtitles(m3u8_url, id)
32 if data_json.get('vtt_url'):
33 subtitles.setdefault('en', []).append({
34 'url': data_json['vtt_url'],
35 'ext': 'vtt',
36 })
37 self._sort_formats(formats)
38 return {
39 'id': id,
40 'title': data_json.get('title'),
41 'view_count': data_json.get('views'),
42 'thumbnail': data_json.get('preview_url'),
43 'upload_date': unified_strdate(data_json.get('created_at')),
44 'formats': formats,
45 'subtitles': subtitles,
46 }