Commit 060d116f authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

share/luameta/googleimage.lua: Rework a bit to better handle meta going wrong.

parent 6e3ef03d
...@@ -2,19 +2,20 @@ ...@@ -2,19 +2,20 @@
-- $Id$ -- $Id$
-- Replace non alphanumeric char by + -- Replace non alphanumeric char by +
function get_query( ) function get_query( title )
if vlc.title then
title = vlc.title
else
title = vlc.name
end
vlc.msg_dbg( title )
return title:gsub( "[^(a-z|A-Z|0-9)]", "+" ) return title:gsub( "[^(a-z|A-Z|0-9)]", "+" )
end end
-- Return the artwork -- Return the artwork
function fetch_art() function fetch_art()
fd = vlc.stream_new( "http://images.google.com/images?q=" .. get_query( ) ) if vlc.title then
title = vlc.title
elseif vlc.name then
title = vlc.name
else
return nil
end
fd = vlc.stream_new( "http://images.google.com/images?q=" .. get_query( title ) )
page = vlc.stream_read( fd, 65653 ) page = vlc.stream_read( fd, 65653 )
vlc.stream_delete( fd ) vlc.stream_delete( fd )
_, _, arturl = string.find( page, "imgurl=([^&]+)" ) _, _, arturl = string.find( page, "imgurl=([^&]+)" )
......
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