]> git.sesse.net Git - vlc/commitdiff
Try a second musicbrainz query if the first one failed. This allows for fuzzier match...
authorAntoine Cellerier <dionoea@videolan.org>
Sat, 13 Feb 2010 21:28:29 +0000 (22:28 +0100)
committerAntoine Cellerier <dionoea@videolan.org>
Sat, 13 Feb 2010 21:30:03 +0000 (22:30 +0100)
share/lua/meta/art/01_musicbrainz.lua

index 5d2cfd0c096870a6b20caeb74e680bfd179271cf..be355abfbdd10e81142f31a67c755ad9bfdb8805 100644 (file)
@@ -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
  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