]> jfr.im git - yt-dlp.git/commitdiff
[twitch:vod] Extract live status (#1722)
authorDEvmIb <redacted>
Sat, 27 Nov 2021 13:55:18 +0000 (19:25 +0530)
committerpukkandan <redacted>
Sat, 27 Nov 2021 13:55:24 +0000 (19:25 +0530)
Authored by: DEvmIb

yt_dlp/extractor/twitch.py

index c5b16f2b060dac0c5a0b0ecf26057b31369710f0..cd97f0a2456fc04933e847951171a054486302b2 100644 (file)
@@ -345,6 +345,7 @@ def _extract_info(self, info):
             'timestamp': parse_iso8601(info.get('recorded_at')),
             'view_count': int_or_none(info.get('views')),
             'is_live': is_live,
+            'was_live': True,
         }
 
     def _extract_moments(self, info, item_id):
@@ -368,9 +369,14 @@ def _extract_info_gql(self, info, item_id):
         if vod_id[0] != 'v':
             vod_id = 'v%s' % vod_id
         thumbnail = url_or_none(info.get('previewThumbnailURL'))
+        is_live = None
         if thumbnail:
-            for p in ('width', 'height'):
-                thumbnail = thumbnail.replace('{%s}' % p, '0')
+            if thumbnail.endswith('/404_processing_{width}x{height}.png'):
+                is_live, thumbnail = True, None
+            else:
+                is_live = False
+                for p in ('width', 'height'):
+                    thumbnail = thumbnail.replace('{%s}' % p, '0')
 
         return {
             'id': vod_id,
@@ -383,6 +389,8 @@ def _extract_info_gql(self, info, item_id):
             'timestamp': unified_timestamp(info.get('publishedAt')),
             'view_count': int_or_none(info.get('viewCount')),
             'chapters': list(self._extract_moments(info, item_id)),
+            'is_live': is_live,
+            'was_live': True,
         }
 
     def _real_extract(self, url):