Top Level Namespace

Defined Under Namespace

Modules: MusicBrainz

Instance Method Summary collapse

Instance Method Details

#englify(name) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/englify.rb', line 23

def englify(name)
		filter = MusicBrainz::Webservice::ArtistFilter.new(
			:name => name,
			:limit => 1
		)
		query = MusicBrainz::Webservice::Query.new
		artists = query.get_artists(filter)
		# Can't find 'em?  Just assume they're alright.
		if artists[0].nil?
			return name
		end
		artist = artists[0].entity
		
		# This *should* work, but it gives us nothing.
		#return artist.aliases[0]

		id = artist.id
		artist_includes = MusicBrainz::Webservice::ArtistIncludes.new(
			:aliases => true
		)
		artist = query.get_artist_by_id(id, artist_includes)
		englifiedName = artist.aliases[0].to_s
		if englifiedName == ''
			englifiedName = name
		end
		
		return englifiedName
end