[vlc-commits] youtube.lua: detect and report very long line issue (#24957)

Pierre Ynard git at videolan.org
Mon Aug 17 18:53:59 CEST 2020


vlc | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Mon Aug 17 18:46:12 2020 +0200| [ca39a2a766cdf751b4a487f9ec3650846f1a0289] | committer: Pierre Ynard

youtube.lua: detect and report very long line issue (#24957)

This should save time for both users and maintainers by accurately
detecting and diagnosing the issue, and avoiding duplicate bug reports.

Refs #24957

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

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

diff --git a/share/lua/playlist/youtube.lua b/share/lua/playlist/youtube.lua
index fdc2baaeff..2b560ac9e1 100644
--- a/share/lua/playlist/youtube.lua
+++ b/share/lua/playlist/youtube.lua
@@ -314,9 +314,11 @@ function parse()
         -- fmt is the format of the video
         -- (cf. http://en.wikipedia.org/wiki/YouTube#Quality_and_formats)
         fmt = get_url_param( vlc.path, "fmt" )
+        local lastline
         while true do
             local line = vlc.readline()
             if not line then break end
+            lastline = line
 
             -- Try to find the video's title
             if string.match( line, "<meta property=\"og:title\"" ) then
@@ -409,6 +411,10 @@ function parse()
             end
         end
 
+        if not path and lastline and string.match( lastline, '<div id="player%-api">' ) then
+            vlc.msg.err( "YouTube web page truncated at very long line, please check https://trac.videolan.org/vlc/ticket/24957 for updates to this issue" )
+        end
+
         if not path then
             local video_id = get_url_param( vlc.path, "v" )
             if video_id then
@@ -434,6 +440,10 @@ function parse()
 
     elseif string.match( vlc.path, "/get_video_info%?" ) then -- video info API
         local line = vlc.readline() -- data is on one line only
+        if not line then
+            vlc.msg.err( "YouTube API output missing: probably rejected as very long line, please check https://trac.videolan.org/vlc/ticket/24957 for updates to this issue" )
+            return { }
+        end
 
         -- Classic parameters - out of use since early 2020
         local fmt = get_url_param( vlc.path, "fmt" )



More information about the vlc-commits mailing list