vlc/vlc-2.2 | branch: master | Jean-Baptiste Kempf <[email protected]> | Wed Feb 18 19:17:47 2015 +0100| [9b1e1db4c1a6c89ef9fc90f6ce9a78e128e10615] | committer: Felix Paul Kühne
Youtube: improve description parsing Close #13973 (cherry picked from commit f568fd431f42e1fd21bc6f55af93d119861c54bf) Signed-off-by: Felix Paul Kühne <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc/vlc-2.2.git/?a=commit;h=9b1e1db4c1a6c89ef9fc90f6ce9a78e128e10615 --- share/lua/playlist/youtube.lua | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/share/lua/playlist/youtube.lua b/share/lua/playlist/youtube.lua index 611543c..d1d9e07 100644 --- a/share/lua/playlist/youtube.lua +++ b/share/lua/playlist/youtube.lua @@ -256,24 +256,22 @@ function parse() name = vlc.strings.resolve_xml_special_chars( name ) name = vlc.strings.resolve_xml_special_chars( name ) end - if string.match( line, "<meta name=\"description\"" ) then - -- Don't ask me why they double encode ... - _,_,description = string.find( line, "content=\"(.-)\"" ) - description = vlc.strings.resolve_xml_special_chars( description ) + + if string.match( line, "<p id=\"eow[-]description\" >" ) then + _,_,description = string.find( line, "<p id=\"eow[-]description\" >(.-)<[/]p>" ) description = vlc.strings.resolve_xml_special_chars( description ) end + + if string.match( line, "<meta property=\"og:image\"" ) then _,_,arturl = string.find( line, "content=\"(.-)\"" ) arturl = vlc.strings.resolve_xml_special_chars( arturl ) end - -- This is not available in the video parameters (whereas it - -- is given by the get_video_info API as the "author" field) - if not artist then - artist = string.match( line, "yt%-uix%-sessionlink yt%-user%-name[^>]*>([^<]*)</" ) - if artist then - artist = vlc.strings.resolve_xml_special_chars( artist ) - end + + if string.match(line, "\"author\":\"(.-)\",") then + _,_,artist = string.find(line, "\"author\":\"(.-)\",") end + -- JSON parameters, also formerly known as "swfConfig", -- "SWF_ARGS", "swfArgs", "PLAYER_CONFIG", "playerConfig" ... if string.match( line, "ytplayer%.config" ) then @@ -301,7 +299,7 @@ function parse() if not path then -- If this is a live stream, the URL map will be empty - -- and we get the URL from this field instead + -- and we get the URL from this field instead local hlsvp = string.match( line, "\"hlsvp\": *\"(.-)\"" ) if hlsvp then hlsvp = string.gsub( hlsvp, "\\/", "/" ) @@ -321,7 +319,7 @@ function parse() format = "&fmt=" .. fmt else format = "" - end + end -- Without "el=detailpage", /get_video_info fails for many -- music videos with errors about copyrighted content being -- "restricted from playback on certain sites" @@ -361,7 +359,7 @@ function parse() if not path then -- If this is a live stream, the URL map will be empty - -- and we get the URL from this field instead + -- and we get the URL from this field instead local hlsvp = string.match( line, "&hlsvp=([^&]*)" ) if hlsvp then hlsvp = vlc.strings.decode_uri( hlsvp ) _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
