Class: MusicMetadataScore::Artist

Inherits:
Object
  • Object
show all
Defined in:
lib/music_metadata_score/artist.rb

Class Method Summary collapse

Class Method Details

.are_proper_artist_format?(artists, override, level) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
7
8
9
10
# File 'lib/music_metadata_score/artist.rb', line 4

def self.are_proper_artist_format?(artists, override, level)
	if artists && artists != []
		MusicMetadataScore::Artist.loop_artists(artists, override, level)
	else
		false
	end
end

.artist_fits_level?(artist, override, level) ⇒ Boolean

Returns:

  • (Boolean)


56
57
58
59
60
61
62
# File 'lib/music_metadata_score/artist.rb', line 56

def self.artist_fits_level?(artist, override, level)
	if override == false && level == :track && (artist.downcase == 'various artists' || artist.downcase == 'various artist' || artist.downcase == 'v/a' || artist.downcase == 'various')
		false
	else
		true
	end
end

.capitalize_the(string) ⇒ Object



81
82
83
84
85
86
87
88
89
# File 'lib/music_metadata_score/artist.rb', line 81

def self.capitalize_the(string)
	split = string.split(' ')
	split.each_with_index do |s, i|
		if s == 'the'
			split[i] = 'The'
		end
	end
	return split.join(' ')
end

.format_artists(artists, override, level) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
# File 'lib/music_metadata_score/artist.rb', line 64

def self.format_artists(artists, override, level)
	array = []
	artists.each do |a|
		new_artist = MusicMetadataScore::Artist.title_case(a)
		separated_artists = MusicMetadataScore::Artist.separate_compound_artists(new_artist)
		separated_artists.each do |sa|
			array << sa
		end
	end
	return array
end

.is_bad_various_artists?(artist) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
50
51
52
53
54
# File 'lib/music_metadata_score/artist.rb', line 47

def self.is_bad_various_artists?(artist)
	# various, va, v/a
	if artist.downcase == 'various' || artist.downcase == 'va' || artist.downcase == 'v/a' || artist.downcase == 'various artist'
		true
	else
		false
	end
end

.is_compound_artist?(artist, override) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
42
43
44
45
# File 'lib/music_metadata_score/artist.rb', line 39

def self.is_compound_artist?(artist, override)
	if override != true && (artist.downcase.include?('and') || artist.include?('&') || artist.downcase.include?('vs') || artist.downcase.include?('with') || artist.downcase.include?('feat') || artist.downcase.include?('present')) || artist.include?('/')
		true
	else
		false
	end
end

.is_proper_artist_format?(artist, override, level) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
27
28
29
# File 'lib/music_metadata_score/artist.rb', line 23

def self.is_proper_artist_format?(artist, override, level)
	if MusicMetadataScore::Artist.is_title_case?(artist, override) && !MusicMetadataScore::Artist.is_compound_artist?(artist, override) && !MusicMetadataScore::Artist.is_bad_various_artists?(artist) && MusicMetadataScore::Artist.artist_fits_level?(artist, override, level)
		true
	else
		false
	end
end

.is_title_case?(artist, override) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
34
35
36
37
# File 'lib/music_metadata_score/artist.rb', line 31

def self.is_title_case?(artist, override)
	if MusicMetadataScore.is_title_case?(artist) || override == true
		true
	else
		false
	end
end

.loop_artists(artists, override, level) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/music_metadata_score/artist.rb', line 12

def self.loop_artists(artists, override, level)
	value = true
	artists.each do |a|
		if !MusicMetadataScore::Artist.is_proper_artist_format?(a, override, level)
			value = false
			break
		end
	end
	value
end

.separate_compound_artists(artist) ⇒ Object



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/music_metadata_score/artist.rb', line 91

def self.separate_compound_artists(artist)
	if artist.downcase.include?('and')
		MusicMetadataScore::Artist.split_artists(artist, 'and')
	elsif artist.downcase.include?('&')
		MusicMetadataScore::Artist.split_artists(artist, '&')
	elsif artist.downcase.include?('vs.')
		MusicMetadataScore::Artist.split_artists(artist, 'vs.')
	elsif artist.downcase.include?('vs')
		MusicMetadataScore::Artist.split_artists(artist, 'vs')
	elsif artist.downcase.include?('with')
		MusicMetadataScore::Artist.split_artists(artist, 'with')
	elsif artist.downcase.include?('feat.')
		MusicMetadataScore::Artist.split_artists(artist, 'feat.')
	elsif artist.downcase.include?('featuring')
		MusicMetadataScore::Artist.split_artists(artist, 'featuring')
	elsif artist.downcase.include?('feat')
		MusicMetadataScore::Artist.split_artists(artist, 'feat')
	elsif artist.downcase.include?('presents')
		MusicMetadataScore::Artist.split_artists(artist 'presents')
	else
		[artist]
	end
end

.split_artists(string, separator) ⇒ Object



115
116
117
118
119
120
121
122
# File 'lib/music_metadata_score/artist.rb', line 115

def self.split_artists(string, separator)
	array = string.split(separator)
	new_array = []
	array.each_with_index do |a, i|
		new_array << a.strip
	end
	return new_array
end

.title_case(artist) ⇒ Object



76
77
78
79
# File 'lib/music_metadata_score/artist.rb', line 76

def self.title_case(artist)
	new_artist = MusicMetadataScore.title_case(artist)
	MusicMetadataScore::Artist.capitalize_the(new_artist)
end