From 44d7f9da994ca311c6125664d9fcfe91f4971d72 Mon Sep 17 00:00:00 2001
From: James Taylor <user234683@users.noreply.github.com>
Date: Sun, 28 Jun 2020 18:20:47 -0700
Subject: Include livestream fmt urls for former livestream w/o static urls If
 none of the format urls for the former livestream are static, meaning they
 use a non-livestream format playable by the browser, then include the dialog
 for copying hte livestream format urls into external video player

---
 youtube/watch.py | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

(limited to 'youtube')

diff --git a/youtube/watch.py b/youtube/watch.py
index b5636b8..a3d8e24 100644
--- a/youtube/watch.py
+++ b/youtube/watch.py
@@ -242,9 +242,21 @@ def extract_info(video_id, use_invidious, playlist_id=None, index=None):
         decryption_error = 'Error decrypting url signatures: ' + decryption_error
         info['playability_error'] = decryption_error
 
+    # check if urls ready (non-live format) in former livestream
+    # urls not ready if all of them have no filesize
+    if info['was_live']:
+        info['urls_ready'] = False
+        for fmt in info['formats']:
+            if fmt['file_size'] is not None:
+                info['urls_ready'] = True
+    else:
+        info['urls_ready'] = True
+
     # livestream urls
     # sometimes only the livestream urls work soon after the livestream is over
-    if info['hls_manifest_url'] and (info['live'] or not info['formats']):
+    if (info['hls_manifest_url']
+        and (info['live'] or not info['formats'] or not info['urls_ready'])
+    ):
         manifest = util.fetch_url(info['hls_manifest_url'],
             debug_name='hls_manifest.m3u8',
             report_text='Fetched hls manifest'
-- 
cgit v1.2.3