Commit f3df9185 authored by Antoine Cellerier's avatar Antoine Cellerier

* youtube.lua: fetch artist and description.

parent 98de4f40
...@@ -62,24 +62,28 @@ end ...@@ -62,24 +62,28 @@ end
-- Parse function. -- Parse function.
function parse() function parse()
local p = {}
if string.match( vlc.path, "watch%?v=" ) if string.match( vlc.path, "watch%?v=" )
then -- This is the HTML page's URL then -- This is the HTML page's URL
p[1] = { path = string.gsub( vlc.path, "^(.*)watch%?v=([^&]*).*$", "http://%1v/%2" ) }
while true do while true do
-- Try to find the video's title -- Try to find the video's title
line = vlc.readline() line = vlc.readline()
if not line then break end if not line then break end
if string.match( line, "<meta name=\"title\"" ) then if string.match( line, "<meta name=\"title\"" ) then
p[1].name = string.gsub( line, "^.*content=\"([^\"]*).*$", "%1" ) name = string.gsub( line, "^.*content=\"([^\"]*).*$", "%1" )
break
end end
if string.match( line, "<meta name=\"description\"" ) then
description = string.gsub( line, "^.*content=\"([^\"]*).*$", "%1" )
end
if string.match( line, "subscribe_to_user=" ) then
artist = string.gsub( line, ".*subscribe_to_user=([^&]*).*", "%1" )
end
if name and description and artist then break end
end end
return { { path = string.gsub( vlc.path, "^(.*)watch%?v=([^&]*).*$", "http://%1v/%2" ); name = name; description = description; artist = artist } }
else -- This is the flash player's URL else -- This is the flash player's URL
p[1] = { path = "http://www.youtube.com/get_video.php?video_id="..get_url_param( vlc.path, "video_id" ).."&t="..get_url_param( vlc.patch, "t" ) }
if string.match( vlc.path, "title=" ) then if string.match( vlc.path, "title=" ) then
p[1].name = get_url_param( vlc.path, "title" ) name = get_url_param( vlc.path, "title" )
end end
return { { path = "http://www.youtube.com/get_video.php?video_id="..get_url_param( vlc.path, "video_id" ).."&t="..get_url_param( vlc.patch, "t" ); name = name } }
end end
return p
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment