[vlc-commits] commit: lua art: don't try too much to find some art (Ilkka Ollakka )
git at videolan.org
git at videolan.org
Sat Jul 17 15:58:07 CEST 2010
vlc/vlc-1.1 | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Sat Jul 17 16:46:38 2010 +0300| [719633a36f88aae3be65bf9ae3ca3ef65e77d0b8] | committer: Ilkka Ollakka
lua art: don't try too much to find some art
Move googleimage search first, and enable it again but don't use eg filename in search query.
Move musicbrainz after last.fm, and don't try more than one way to find art, also do query once in 2 sec
If you get bad hits from googleimage album-art, please report them to me.
> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.1.git/?a=commit;h=719633a36f88aae3be65bf9ae3ca3ef65e77d0b8
---
share/Makefile.am | 8 +++---
.../art/{10_googleimage.lua => 01_googleimage.lua} | 25 +++----------------
.../art/{01_musicbrainz.lua => 04_musicbrainz.lua} | 12 ++++-----
3 files changed, 13 insertions(+), 32 deletions(-)
diff --git a/share/Makefile.am b/share/Makefile.am
index fbfc178..6d6d0fe 100644
--- a/share/Makefile.am
+++ b/share/Makefile.am
@@ -216,10 +216,10 @@ nobase_vlclib_DATA = \
lua/intf/modules/host.luac \
lua/intf/rc.luac \
lua/intf/telnet.luac \
- lua/meta/art/01_musicbrainz.luac \
+ lua/meta/art/04_musicbrainz.luac \
lua/meta/art/02_frenchtv.luac \
lua/meta/art/03_lastfm.luac \
- lua/meta/art/10_googleimage.luac \
+ lua/meta/art/01_googleimage.luac \
lua/meta/fetcher/tvrage.luac \
lua/meta/reader/filename.luac \
lua/modules/sandbox.luac \
@@ -276,10 +276,10 @@ EXTRA_DIST += \
lua/intf/rc.lua \
lua/intf/telnet.lua \
lua/meta/art/README.txt \
- lua/meta/art/01_musicbrainz.lua \
+ lua/meta/art/04_musicbrainz.lua \
lua/meta/art/02_frenchtv.lua \
lua/meta/art/03_lastfm.lua \
- lua/meta/art/10_googleimage.lua \
+ lua/meta/art/01_googleimage.lua \
lua/meta/fetcher/README.txt \
lua/meta/fetcher/tvrage.lua \
lua/meta/reader/README.txt \
diff --git a/share/lua/meta/art/10_googleimage.lua b/share/lua/meta/art/01_googleimage.lua
similarity index 57%
rename from share/lua/meta/art/10_googleimage.lua
rename to share/lua/meta/art/01_googleimage.lua
index a3cc35d..43012e0 100644
--- a/share/lua/meta/art/10_googleimage.lua
+++ b/share/lua/meta/art/01_googleimage.lua
@@ -19,40 +19,23 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
--]]
--- Replace non alphanumeric char by +
-function get_query( title )
- -- If we have a .EXT remove the extension.
- str = string.gsub( title, "(.*)%....$", "%1" )
- return string.gsub( str, "([^%w ])",
- function (c) return string.format ("%%%02X", string.byte(c)) end)
-end
-
-- Return the artwork
function fetch_art()
- -- This is disabled because we have too much false positive by the inherent nature of this script.
- if true then vlc.msg.dbg("10_googleimage.lua is disabled") return nil end
-
- if vlc.input == nil then return nil end
+ if vlc.item == nil then return nil end
- local item = vlc.input.item()
- local meta = item:metas()
+ local meta = vlc.item:metas()
if meta["artist"] and meta["album"] then
title = meta["artist"].." "..meta["album"]
elseif meta["artist"] and meta["title"] then
title = meta["artist"].." "..meta["title"]
- elseif meta["title"] then
- title = meta["title"]
- elseif meta["filename"] then
- title = meta["filename"]
else
- vlc.msg.err("No filename")
return nil
end
- fd = vlc.stream( "http://images.google.com/images?q=" .. get_query( title ) )
+ fd = vlc.stream( "http://images.google.com/images?q="..vlc.strings.encode_uri_component( title.." cover" ) )
if not fd then return nil end
page = fd:read( 65653 )
fd = nil
- _, _, arturl = string.find( page, "imgurl=([^&]+)" )
+ _, _, arturl = string.find( page, "imgurl=([^&]*)" )
return arturl
end
diff --git a/share/lua/meta/art/01_musicbrainz.lua b/share/lua/meta/art/04_musicbrainz.lua
similarity index 76%
rename from share/lua/meta/art/01_musicbrainz.lua
rename to share/lua/meta/art/04_musicbrainz.lua
index 934e9ad..a5f3188 100644
--- a/share/lua/meta/art/01_musicbrainz.lua
+++ b/share/lua/meta/art/04_musicbrainz.lua
@@ -23,9 +23,9 @@ function try_query(query)
local l = vlc.object.libvlc()
local t = vlc.var.get( l, "musicbrainz-previousdate" )
if t ~= nil then
- if t + 1000000. > vlc.misc.mdate() then
- vlc.msg.warn( "We must wait 1 second between requests unless we want to be blacklisted from the musicbrainz server." )
- vlc.misc.mwait( t + 1000000. )
+ if t + 2000000. > vlc.misc.mdate() then
+ vlc.msg.warn( "We must wait 2 second between requests unless we want to be blacklisted from the musicbrainz server." )
+ vlc.misc.mwait( t + 2000000. )
end
vlc.var.set( l, "musicbrainz-previousdate", vlc.misc.mdate() )
else
@@ -59,8 +59,6 @@ function fetch_art()
return nil
end
- local query1 = "http://musicbrainz.org/ws/1/release/?type=xml&artist="..vlc.strings.encode_uri_component(meta["artist"]).."&title="..vlc.strings.encode_uri_component(meta["album"])
- local query2 = "http://musicbrainz.org/ws/1/release/?type=xml&query="..vlc.strings.encode_uri_component(meta["album"].." AND ".."artist:"..meta["artist"])
- local query3 = "http://musicbrainz.org/ws/1/release/?type=xml&query="..vlc.strings.encode_uri_component(fuzzy(meta["album"]).." AND ".."artist:"..fuzzy(meta["artist"]))
- return try_query(query1) or try_query(query2) or try_query(query3)
+ local query1 = "http://musicbrainz.org/ws/1/release/?type=xml&artist="..vlc.strings.encode_uri_component(meta["artist"]).."&title=\""..vlc.strings.encode_uri_component(meta["album"].."\"")
+ return try_query(query1)
end
More information about the vlc-commits
mailing list