Commit 4d376677 authored by Antoine Cellerier's avatar Antoine Cellerier

* test.lua: Use spaces instead of tabs in lua code.

parent 02474925
...@@ -2,74 +2,74 @@ ...@@ -2,74 +2,74 @@
if vlc.access ~= "http" if vlc.access ~= "http"
then then
return false return false
end end
url = nil url = nil
title = nil title = nil
function get_url_param( url, name ) function get_url_param( url, name )
return string.gsub( vlc.path, "^.*"..name.."=([^&]*).*$", "%1" ) return string.gsub( vlc.path, "^.*"..name.."=([^&]*).*$", "%1" )
end end
if string.match( vlc.path, "youtube.com" ) if string.match( vlc.path, "youtube.com" )
then then
if string.match( vlc.path, "watch%?v=" ) if string.match( vlc.path, "watch%?v=" )
then then
url = string.gsub( vlc.path, "^(.*)watch%?v=([^&]*).*$", "http://%1v/%2" ) url = string.gsub( vlc.path, "^(.*)watch%?v=([^&]*).*$", "http://%1v/%2" )
while not title while not title
do do
line = vlc.readline() line = vlc.readline()
if not line if not line
then then
break break
end end
if string.match( line, "<meta name=\"title\"" ) if string.match( line, "<meta name=\"title\"" )
then then
title = string.gsub( line, "^.*content=\"([^\"]*).*$", "%1" ) title = string.gsub( line, "^.*content=\"([^\"]*).*$", "%1" )
end end
end end
elseif string.match( vlc.path, "watch_fullscreen%?video_id=" ) or string.match( vlc.path, "p.swf" ) or string.match( vlc.path, "player2.swf" ) elseif string.match( vlc.path, "watch_fullscreen%?video_id=" ) or string.match( vlc.path, "p.swf" ) or string.match( vlc.path, "player2.swf" )
then then
video_id = get_url_param( vlc.path, "video_id" ) video_id = get_url_param( vlc.path, "video_id" )
t = get_url_param( vlc.path, "t" ) t = get_url_param( vlc.path, "t" )
url = "http://www.youtube.com/get_video.php?video_id="..video_id.."&t="..t url = "http://www.youtube.com/get_video.php?video_id="..video_id.."&t="..t
if string.match( vlc.path, "title=" ) if string.match( vlc.path, "title=" )
then then
title = get_url_param( vlc.path, "title" ) title = get_url_param( vlc.path, "title" )
end end
end end
elseif string.match( vlc.path, "dailymotion.com" ) elseif string.match( vlc.path, "dailymotion.com" )
then then
len, str = vlc.peek( 9 ) len, str = vlc.peek( 9 )
if str == "<!DOCTYPE" if str == "<!DOCTYPE"
then then
while not url while not url
do do
line = vlc.readline() line = vlc.readline()
if string.match( line, "param name=\"flashvars\" value=\"url=" ) if string.match( line, "param name=\"flashvars\" value=\"url=" )
then then
url = vlc.decode_uri( string.gsub( line, "^.*param name=\"flashvars\" value=\"url=([^&]*).*$", "%1" ) ) url = vlc.decode_uri( string.gsub( line, "^.*param name=\"flashvars\" value=\"url=([^&]*).*$", "%1" ) )
end end
end end
end end
elseif string.match( vlc.path, "video.google.com" ) and string.match( vlc.path, "videoplay" ) elseif string.match( vlc.path, "video.google.com" ) and string.match( vlc.path, "videoplay" )
then then
url = string.gsub( vlc.path, "^.*(docid=[^&]*).*$", "http://video.google.com/videogvp?%1" ) url = string.gsub( vlc.path, "^.*(docid=[^&]*).*$", "http://video.google.com/videogvp?%1" )
elseif string.match( vlc.path, "metacafe.com" ) elseif string.match( vlc.path, "metacafe.com" )
then then
if string.match( vlc.path, "watch/" ) if string.match( vlc.path, "watch/" )
then then
url = string.gsub( vlc.path, "^.*watch/(.*[^/])/?$", "http://www.metacafe.com/fplayer/%1.swf" ) url = string.gsub( vlc.path, "^.*watch/(.*[^/])/?$", "http://www.metacafe.com/fplayer/%1.swf" )
elseif string.match( vlc.path, "mediaURL=" ) elseif string.match( vlc.path, "mediaURL=" )
then then
url = string.gsub( vlc.path, "^.*mediaURL=([^&]*).*$", "%1" ) url = string.gsub( vlc.path, "^.*mediaURL=([^&]*).*$", "%1" )
end end
end end
if url == nil if url == nil
then then
return false return false
else else
return true, url, title return true, url, title
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