[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:52:16 CEST 2010
vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Sat Jul 17 16:46:38 2010 +0300| [c559cc48cbd3410727f8d8034dd84dcf92a80603] | 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.git/?a=commit;h=c559cc48cbd3410727f8d8034dd84dcf92a80603
---
share/Makefile.am | 8 +++---
.../art/{10_googleimage.lua => 01_googleimage.lua} | 25 +++----------------
.../art/{01_musicbrainz.lua => 04_musicbrainz.lua} | 10 +++----
3 files changed, 12 insertions(+), 31 deletions(-)
diff --git a/share/Makefile.am b/share/Makefile.am
index 2cf1cb5..fe61d4b 100644
--- a/share/Makefile.am
+++ b/share/Makefile.am
@@ -217,10 +217,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 \
@@ -280,10 +280,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 77%
rename from share/lua/meta/art/01_musicbrainz.lua
rename to share/lua/meta/art/04_musicbrainz.lua
index e043151..1d3db64 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
@@ -55,7 +55,5 @@ function fetch_art()
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(meta["album"].."\"~ AND ".."artist:"..meta["artist"].."~")
- return try_query(query1) or try_query(query2) or try_query(query3)
+ return try_query(query1)
end
More information about the vlc-commits
mailing list