[vlc-commits] youtube.lua: retry alternate API fallback using either possible parameter

Pierre Ynard git at videolan.org
Thu Nov 12 07:28:24 CET 2020


vlc | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Thu Nov 12 06:33:25 2020 +0100| [6e0f4a28c6f82bef165473e2785ea2834f9f5563] | committer: Pierre Ynard

youtube.lua: retry alternate API fallback using either possible parameter

This improves the interoperability of the fallback mechanism and makes
the script more resilient as a whole.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6e0f4a28c6f82bef165473e2785ea2834f9f5563
---

 share/lua/playlist/youtube.lua | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/share/lua/playlist/youtube.lua b/share/lua/playlist/youtube.lua
index a94e6f881a..f8a8937387 100644
--- a/share/lua/playlist/youtube.lua
+++ b/share/lua/playlist/youtube.lua
@@ -561,6 +561,17 @@ function parse()
             end
         end
 
+        if not path and get_url_param( vlc.path, "el" ) ~= "detailpage" then
+            -- Retry with the other known value for the "el" parameter;
+            -- either value has historically been wrong and failed for
+            -- some videos but not others.
+            local video_id = get_url_param( vlc.path, "video_id" )
+            if video_id then
+                path = vlc.access.."://www.youtube.com/get_video_info?video_id="..video_id.."&el=detailpage"..copy_url_param( vlc.path, "fmt" )..copy_url_param( vlc.path, "jsurl" )
+                vlc.msg.warn( "Couldn't extract video URL, retrying with alternate YouTube API parameters" )
+            end
+        end
+
         if not path then
             vlc.msg.err( "Couldn't extract youtube video URL, please check for updates to this script" )
             return { }



More information about the vlc-commits mailing list