]> git.sesse.net Git - vlc/blob - share/luameta/googleimage.lua
modules/meta_engine/luameta.c: Get meta (untested) and artwork using lua scripts.
[vlc] / share / luameta / googleimage.lua
1 -- Get's an artwork from images.google.com
2 -- $Id$
3
4 -- Replace non alphanumeric char by +
5 function get_query( )
6     if vlc.title then
7         title = vlc.title
8     else
9         title = vlc.name
10     end
11     vlc.msg_dbg( title )
12     return title:gsub( "[^(a-z|A-Z|0-9)]", "+" )
13 end
14
15 -- Return the artwork
16 function fetch_art()
17     fd = vlc.stream_new( "http://images.google.com/images?q=" .. get_query( ) )
18     page = vlc.stream_read( fd, 65653 )
19     vlc.stream_delete( fd )
20     _, _, arturl = string.find( page, "imgurl=([^&]+)" )
21     return arturl
22 end