3 from .common
import InfoExtractor
12 class GronkhIE(InfoExtractor
):
13 _VALID_URL
= r
'https?://(?:www\.)?gronkh\.tv/(?:watch/)?streams?/(?P<id>\d+)'
16 'url': 'https://gronkh.tv/streams/657',
20 'title': 'H.O.R.D.E. - DAS ZWEiTE ZEiTALTER 🎲 Session 1',
22 'thumbnail': 'https://01.cdn.vod.farm/preview/9e2555d3a23bf4e5c5b7c6b3b70a9d84.jpg',
23 'upload_date': '20221111',
24 'chapters': 'count:3',
27 'params': {'skip_download': True},
29 'url': 'https://gronkh.tv/stream/536',
33 'title': 'GTV0536, 2021-10-01 - MARTHA IS DEAD #FREiAB1830 !FF7 !horde !archiv',
35 'thumbnail': 'https://01.cdn.vod.farm/preview/6436746cce14e25f751260a692872b9b.jpg',
36 'upload_date': '20211001',
39 'params': {'skip_download': True},
41 'url': 'https://gronkh.tv/watch/stream/546',
42 'only_matching': True,
45 def _real_extract(self
, url
):
46 video_id
= self
._match
_id
(url
)
47 data_json
= self
._download
_json
(f
'https://api.gronkh.tv/v1/video/info?episode={video_id}', video_id
)
48 m3u8_url
= self
._download
_json
(f
'https://api.gronkh.tv/v1/video/playlist?episode={video_id}', video_id
)['playlist_url']
49 formats
, subtitles
= self
._extract
_m
3u8_formats
_and
_subtitles
(m3u8_url
, video_id
)
50 if data_json
.get('vtt_url'):
51 subtitles
.setdefault('en', []).append({
52 'url': data_json
['vtt_url'],
57 'title': data_json
.get('title'),
58 'view_count': data_json
.get('views'),
59 'thumbnail': data_json
.get('preview_url'),
60 'upload_date': unified_strdate(data_json
.get('created_at')),
62 'subtitles': subtitles
,
63 'duration': float_or_none(data_json
.get('source_length')),
64 'chapters': traverse_obj(data_json
, (
65 'chapters', lambda _
, v
: float_or_none(v
['offset']) is not None, {
67 'start_time': ('offset', {float_or_none}
),
72 class GronkhFeedIE(InfoExtractor
):
73 _VALID_URL
= r
'https?://(?:www\.)?gronkh\.tv(?:/feed)?/?(?:#|$)'
74 IE_NAME
= 'gronkh:feed'
77 'url': 'https://gronkh.tv/feed',
83 'url': 'https://gronkh.tv',
84 'only_matching': True,
88 for type_
in ('recent', 'views'):
89 info
= self
._download
_json
(
90 f
'https://api.gronkh.tv/v1/video/discovery/{type_}', 'feed', note
=f
'Downloading {type_} API JSON')
91 for item
in traverse_obj(info
, ('discovery', ...)) or []:
92 yield self
.url_result(f
'https://gronkh.tv/watch/stream/{item["episode"]}', GronkhIE
, item
.get('title'))
94 def _real_extract(self
, url
):
95 return self
.playlist_result(self
._entries
(), 'feed')
98 class GronkhVodsIE(InfoExtractor
):
99 _VALID_URL
= r
'https?://(?:www\.)?gronkh\.tv/vods/streams/?(?:#|$)'
100 IE_NAME
= 'gronkh:vods'
103 'url': 'https://gronkh.tv/vods/streams',
107 'playlist_mincount': 150,
111 def _fetch_page(self
, page
):
112 items
= traverse_obj(self
._download
_json
(
113 'https://api.gronkh.tv/v1/search', 'vods', query
={'offset': self
._PER
_PAGE
* page
, 'first': self
._PER
_PAGE
},
114 note
=f
'Downloading stream video page {page + 1}'), ('results', 'videos', ...))
115 for item
in items
or []:
116 yield self
.url_result(f
'https://gronkh.tv/watch/stream/{item["episode"]}', GronkhIE
, item
['episode'], item
.get('title'))
118 def _real_extract(self
, url
):
119 entries
= OnDemandPagedList(functools
.partial(self
._fetch
_page
), self
._PER
_PAGE
)
120 return self
.playlist_result(entries
, 'vods')