Module:Release links

local p = {} local cargo = mw.ext.cargo

function p.main( frame ) local kind = frame.args[1] local title = frame.args[2]

if kind == 'song' then kind = 'songs' else kind = 'albums' end

local results = cargo.query( kind, kind .. '.discogs,' .. kind .. '.musicbrainz', {   	where = kind .. '.name="' .. title .. '"',    	limit = 1    } ) local discogs = '' local musicbrainz = ''

for r = 1, #results do       local result = results[r] discogs = result[kind .. '.discogs'] or '' musicbrainz = result[kind .. '.musicbrainz'] or '' end output = ''

if discogs ~=  or musicbrainz ~=  then output = 'More releases: ' if discogs ~= '' then output = output .. '[https://discogs.com/master/' .. discogs .. ' Discogs]' if musicbrainz ~= '' then output = output .. ' &bull; ' end end if musicbrainz ~= '' then output = output .. '[https://musicbrainz.org/release-group/' .. musicbrainz .. ' MusicBrainz]' end end return output end

return p