[vlc-commits] commit: lua: fix fuzzy musicbrainz search and use " " around title/artists (Ilkka Ollakka )

git at videolan.org git at videolan.org
Wed Jun 30 19:49:36 CEST 2010


vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Wed Jun 30 20:49:15 2010 +0300| [5661954c35570f67148f096c209ac679f9742a1b] | committer: Ilkka Ollakka 

lua: fix fuzzy musicbrainz search and use " " around title/artists

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5661954c35570f67148f096c209ac679f9742a1b
---

 share/lua/meta/art/01_musicbrainz.lua |   15 +++++----------
 1 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/share/lua/meta/art/01_musicbrainz.lua b/share/lua/meta/art/01_musicbrainz.lua
index 934e9ad..e043151 100644
--- a/share/lua/meta/art/01_musicbrainz.lua
+++ b/share/lua/meta/art/01_musicbrainz.lua
@@ -38,20 +38,15 @@ function try_query(query)
     local page = s:read( 65653 )
 
     -- FIXME: multiple results may be available
-    _,_,asin = string.find( page, "<asin>(.-)</asin>" )
+    asin = string.find( page, "<asin>(%w+)</asin>" )
     if asin then
+        vlc.msg.dbg( asin )
         return "http://images.amazon.com/images/P/"..asin..".01._SCLZZZZZZZ_.jpg"
     else
         return nil
     end
 end
 
-function fuzzy(query)
-    -- http://musicbrainz.org/doc/TextSearchSyntax#Fuzzy_searches
-    -- we could even tweak the fuzziness
-    return string.gsub(query, "([^%s]+)", "%1~")
-end
-
 -- Return the artwork
 function fetch_art()
     local meta = vlc.item:metas()
@@ -59,8 +54,8 @@ 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"]))
+    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)
 end



More information about the vlc-commits mailing list