vlc | branch: master | Pierre Ynard <[email protected]> | Tue Nov 3 00:38:49 2020 +0100| [f3d206499bb45df4aef2f05770c8535e4cd8a4de] | committer: Pierre Ynard
youtube.lua: more robust meta tag metadata parsing Required for a new HTML code layout apparently getting phased in > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f3d206499bb45df4aef2f05770c8535e4cd8a4de --- share/lua/playlist/youtube.lua | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/share/lua/playlist/youtube.lua b/share/lua/playlist/youtube.lua index a34534d81c..965e17142b 100644 --- a/share/lua/playlist/youtube.lua +++ b/share/lua/playlist/youtube.lua @@ -335,10 +335,14 @@ function parse() line = vlc.read( eol or len ) end - -- Try to find the video's title - if string.match( line, "<meta property=\"og:title\"" ) then - _,_,name = string.find( line, "content=\"(.-)\"" ) - name = vlc.strings.resolve_xml_special_chars( name ) + if not title then + local meta = string.match( line, '<meta property="og:title"( .-)>' ) + if meta then + title = string.match( meta, ' content="(.-)"' ) + if title then + title = vlc.strings.resolve_xml_special_chars( title ) + end + end end if not description then @@ -361,9 +365,14 @@ function parse() end end - if string.match( line, "<meta property=\"og:image\"" ) then - _,_,arturl = string.find( line, "content=\"(.-)\"" ) - arturl = vlc.strings.resolve_xml_special_chars( arturl ) + if not arturl then + local meta = string.match( line, '<meta property="og:image"( .-)>' ) + if meta then + arturl = string.match( meta, ' content="(.-)"' ) + if arturl then + arturl = vlc.strings.resolve_xml_special_chars( arturl ) + end + end end if not artist then @@ -453,7 +462,7 @@ function parse() arturl = get_arturl() end - return { { path = path; name = name; description = description; artist = artist; arturl = arturl } } + return { { path = path; name = title; description = description; artist = artist; arturl = arturl } } elseif string.match( vlc.path, "/get_video_info%?" ) then -- video info API local line = vlc.read( 1024*1024 ) -- data is on one line only _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
