[vlc-devel] commit: Add a third query with fuzzy search enabled for every word. ( We could also add other searches with lower fuzzyness if the first try fails ) (Antoine Cellerier )
git version control
git at videolan.org
Sat Feb 13 22:46:06 CET 2010
vlc | branch: master | Antoine Cellerier <dionoea at videolan.org> | Sat Feb 13 22:45:38 2010 +0100| [62ce520665b8eec73a29791eefe86fb3eda4203e] | committer: Antoine Cellerier
Add a third query with fuzzy search enabled for every word. (We could also add other searches with lower fuzzyness if the first try fails)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=62ce520665b8eec73a29791eefe86fb3eda4203e
---
share/lua/meta/art/01_musicbrainz.lua | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/share/lua/meta/art/01_musicbrainz.lua b/share/lua/meta/art/01_musicbrainz.lua
index be355ab..d35d2b4 100644
--- a/share/lua/meta/art/01_musicbrainz.lua
+++ b/share/lua/meta/art/01_musicbrainz.lua
@@ -45,6 +45,12 @@ function try_query(query)
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()
@@ -53,6 +59,7 @@ 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=artist:"..vlc.strings.encode_uri_component(meta["artist"]).." AND "..vlc.strings.encode_uri_component(meta["album"])
- return try_query(query1) or try_query(query2)
+ 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)
end
More information about the vlc-devel
mailing list