mirror of
https://github.com/cooperhammond/irs.git
synced 2024-12-22 17:35:28 +00:00
Merge pull request #69 from Who23/bug-fix-68
Fix #68 Can't believe I didn't see this earlier. Thanks for the great work! I'll merge it now.
This commit is contained in:
commit
c20f4309d8
|
@ -134,9 +134,15 @@ class Song
|
|||
tagger.add_album_art(temp_albumart_filename)
|
||||
tagger.add_text_tag("title", data["name"].to_s)
|
||||
tagger.add_text_tag("artist", @artist)
|
||||
|
||||
if !@album.empty?
|
||||
tagger.add_text_tag("album", @album)
|
||||
tagger.add_text_tag("genre",
|
||||
@spotify_searcher.find_genre(data["artists"][0]["id"].to_s))
|
||||
end
|
||||
|
||||
if genre = @spotify_searcher.find_genre(data["artists"][0]["id"].to_s)
|
||||
tagger.add_text_tag("genre", genre)
|
||||
end
|
||||
|
||||
tagger.add_text_tag("track", data["track_number"].to_s)
|
||||
tagger.add_text_tag("disc", data["disc_number"].to_s)
|
||||
|
||||
|
|
|
@ -204,8 +204,14 @@ class SpotifySearcher
|
|||
# ```
|
||||
# SpotifySearcher.new.authorize(...).find_genre("1dfeR4HaWDbWqFHLkxsg1d")
|
||||
# ```
|
||||
def find_genre(id : String) : String
|
||||
genre = get_item("artist", id)["genres"][0].to_s
|
||||
def find_genre(id : String) : String | Nil
|
||||
genre = get_item("artist", id)["genres"]
|
||||
|
||||
if genre.as_a.empty?
|
||||
return nil
|
||||
end
|
||||
|
||||
genre = genre[0].to_s
|
||||
genre = genre.split(" ").map { |x| x.capitalize }.join(" ")
|
||||
|
||||
return genre
|
||||
|
|
Loading…
Reference in a new issue