[vlc-devel] commit: Try a second musicbrainz query if the first one failed. This allows for fuzzier matches ( like not taking spaces into account in 1980 - 1990 for example) but still doesn't fix issues with minor spelling errors. ( Antoine Cellerier )
git version control
git at videolan.org
Sat Feb 13 22:28:23 CET 2010
vlc | branch: master | Antoine Cellerier <dionoea at videolan.org> | Sat Feb 13 22:28:29 2010 +0100| [ffd70ceb68eb2146e939b4e4e3a15fa48bb12adc] | committer: Antoine Cellerier
Try a second musicbrainz query if the first one failed. This allows for fuzzier matches (like not taking spaces into account in 1980 - 1990 for example) but still doesn't fix issues with minor spelling errors.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ffd70ceb68eb2146e939b4e4e3a15fa48bb12adc
---
share/lua/meta/art/01_musicbrainz.lua | 25 ++++++++++++++-----------
1 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/share/lua/meta/art/01_musicbrainz.lua b/share/lua/meta/art/01_musicbrainz.lua
index 5d2cfd0..be355ab 100644
--- a/share/lua/meta/art/01_musicbrainz.lua
+++ b/share/lua/meta/art/01_musicbrainz.lua
@@ -2,7 +2,7 @@
Gets an artwork from amazon
$Id$
- Copyright © 2007 the VideoLAN team
+ Copyright © 2007-2010 the VideoLAN team
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,16 +19,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
--]]
--- Return the artwork
-function fetch_art()
- local query
- local meta = vlc.item:metas()
- if meta["artist"] and meta["album"] then
- query = "http://musicbrainz.org/ws/1/release/?type=xml&artist="..vlc.strings.encode_uri_component(meta["artist"]).."&title="..vlc.strings.encode_uri_component(meta["album"])
- else
- return nil
- end
-
+function try_query(query)
local l = vlc.object.libvlc()
local t = vlc.var.get( l, "musicbrainz-previousdate" )
if t ~= nil then
@@ -53,3 +44,15 @@ function fetch_art()
return nil
end
end
+
+-- Return the artwork
+function fetch_art()
+ local meta = vlc.item:metas()
+ if not (meta["artist"] and meta["album"]) then
+ 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=artist:"..vlc.strings.encode_uri_component(meta["artist"]).." AND "..vlc.strings.encode_uri_component(meta["album"])
+ return try_query(query1) or try_query(query2)
+end
More information about the vlc-devel
mailing list