]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/gronkh.py
[ie/youtube] Suppress "Unavailable videos are hidden" warning (#10159)
[yt-dlp.git] / yt_dlp / extractor / gronkh.py
index b9370e36c11c82cc4850d156051c983d08d08de5..1668900378a0b15f3121e1ca5fbe63cc6f57dffa 100644 (file)
@@ -3,6 +3,7 @@
 from .common import InfoExtractor
 from ..utils import (
     OnDemandPagedList,
+    float_or_none,
     traverse_obj,
     unified_strdate,
 )
@@ -19,9 +20,11 @@ class GronkhIE(InfoExtractor):
             'title': 'H.O.R.D.E. - DAS ZWEiTE ZEiTALTER ðŸŽ² Session 1',
             'view_count': int,
             'thumbnail': 'https://01.cdn.vod.farm/preview/9e2555d3a23bf4e5c5b7c6b3b70a9d84.jpg',
-            'upload_date': '20221111'
+            'upload_date': '20221111',
+            'chapters': 'count:3',
+            'duration': 31463,
         },
-        'params': {'skip_download': True}
+        'params': {'skip_download': True},
     }, {
         'url': 'https://gronkh.tv/stream/536',
         'info_dict': {
@@ -30,32 +33,39 @@ class GronkhIE(InfoExtractor):
             'title': 'GTV0536, 2021-10-01 - MARTHA IS DEAD  #FREiAB1830  !FF7 !horde !archiv',
             'view_count': int,
             'thumbnail': 'https://01.cdn.vod.farm/preview/6436746cce14e25f751260a692872b9b.jpg',
-            'upload_date': '20211001'
+            'upload_date': '20211001',
+            'duration': 32058,
         },
-        'params': {'skip_download': True}
+        'params': {'skip_download': True},
     }, {
         'url': 'https://gronkh.tv/watch/stream/546',
         'only_matching': True,
     }]
 
     def _real_extract(self, url):
-        id = self._match_id(url)
-        data_json = self._download_json(f'https://api.gronkh.tv/v1/video/info?episode={id}', id)
-        m3u8_url = self._download_json(f'https://api.gronkh.tv/v1/video/playlist?episode={id}', id)['playlist_url']
-        formats, subtitles = self._extract_m3u8_formats_and_subtitles(m3u8_url, id)
+        video_id = self._match_id(url)
+        data_json = self._download_json(f'https://api.gronkh.tv/v1/video/info?episode={video_id}', video_id)
+        m3u8_url = self._download_json(f'https://api.gronkh.tv/v1/video/playlist?episode={video_id}', video_id)['playlist_url']
+        formats, subtitles = self._extract_m3u8_formats_and_subtitles(m3u8_url, video_id)
         if data_json.get('vtt_url'):
             subtitles.setdefault('en', []).append({
                 'url': data_json['vtt_url'],
                 'ext': 'vtt',
             })
         return {
-            'id': id,
+            'id': video_id,
             'title': data_json.get('title'),
             'view_count': data_json.get('views'),
             'thumbnail': data_json.get('preview_url'),
             'upload_date': unified_strdate(data_json.get('created_at')),
             'formats': formats,
             'subtitles': subtitles,
+            'duration': float_or_none(data_json.get('source_length')),
+            'chapters': traverse_obj(data_json, (
+                'chapters', lambda _, v: float_or_none(v['offset']) is not None, {
+                    'title': 'title',
+                    'start_time': ('offset', {float_or_none}),
+                })) or None,
         }