Fix for Google metadata changes to find title
authorJames Bunton <jamesbunton@delx.net.au>
Mon, 5 Aug 2019 00:07:11 +0000 (10:07 +1000)
committerJames Bunton <jamesbunton@delx.net.au>
Mon, 5 Aug 2019 00:07:11 +0000 (10:07 +1000)
youtube.cgi

index 9e14fd1..ef7b608 100755 (executable)
@@ -292,8 +292,13 @@ def get_video_url(page):
     if not video_url:
         return None, None
 
-    filename = sanitize_filename(player_config["args"]["title"])
-    filename += "." + extension
+    title = player_config["args"].get("title", None)
+    if not title:
+        title = json.loads(player_config["args"]["player_response"])["videoDetails"]["title"]
+    if not title:
+        title = "Unknown title"
+
+    filename = sanitize_filename(title) + "." + extension
 
     return video_url, filename