vlc/vlc-2.1 | branch: master | Wieland Hoffmann <themi...@gmail.com> | Sun Jan 12 23:04:07 2014 +0100| [b639c41868b55be7a0794b7d495cedc653fcb0cc] | committer: Jean-Baptiste Kempf
musicbrainz.lua: Use get_releaseid even if the album title is known This renames `try_release` to `get_releaseid` and uses it to find the MusicBrainz Identifier. That MBID is later used in the query passed to try_query. Not using the ASIN returned from the search server in the get_releaseid call means one additional request is performed in the case that both the artist and the album name are already known. Signed-off-by: Jean-Baptiste Kempf <j...@videolan.org> (cherry picked from commit f18236eee239fa8b57641ba82f20576ab244202f) Signed-off-by: Jean-Baptiste Kempf <j...@videolan.org> > http://git.videolan.org/gitweb.cgi/vlc/vlc-2.1.git/?a=commit;h=b639c41868b55be7a0794b7d495cedc653fcb0cc --- share/lua/meta/art/00_musicbrainz.lua | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/share/lua/meta/art/00_musicbrainz.lua b/share/lua/meta/art/00_musicbrainz.lua index 2e224f4..1e11cbd 100644 --- a/share/lua/meta/art/00_musicbrainz.lua +++ b/share/lua/meta/art/00_musicbrainz.lua @@ -33,15 +33,15 @@ function try_query(query) return nil end --- Return the mbid for first release -function try_release(query) +-- Return the mbid for the first release returned by the MusicBrainz search server for query +function get_releaseid(query) local s = vlc.stream( query ) if not s then return nil end local page = s:read( 65653 ) -- FIXME: multiple results may be available and the first one is not -- guaranteed to have asin, so if it doesnt, we wouldnt get any art - _, _, releaseid = string.find( page, "<release id=\"([%x%-]-)\">" ) + _, _, releaseid = string.find( page, "<release id=\"([%x%-]-)\"" ) if releaseid then return releaseid end @@ -56,19 +56,22 @@ function fetch_art() or meta["Listing Type"] == "tv" then return nil end + local releaseid = nil + if meta["artist"] and meta["album"] then query = "artist:\"" .. meta["artist"] .. "\" AND release:\"" .. meta["album"] .. "\"" relquery = "http://mb.videolan.org/ws/2/release/?query=" .. vlc.strings.encode_uri_component( query ) - return try_query( relquery ) - elseif meta["artist"] and meta["title"] then + releaseid = get_releaseid( relquery ) + end + if not releaseid and meta["artist"] and meta["title"] then query = "artist:\"" .. meta["artist"] .. "\" AND recording:\"" .. meta["title"] .. "\"" recquery = "http://mb.videolan.org/ws/2/recording/?query=" .. vlc.strings.encode_uri_component( query ) - releaseid = try_release( recquery ) - if releaseid then - relquery = "http://mb.videolan.org/ws/2/release/" .. releaseid - return try_query( relquery ) - else - return nil - end + releaseid = get_releaseid( recquery ) + end + if releaseid then + relquery = "http://mb.videolan.org/ws/2/release/" .. releaseid + return try_query( relquery ) + else + return nil end end _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org https://mailman.videolan.org/listinfo/vlc-commits