diff --git a/src/glue/album.cr b/src/glue/album.cr index b9df693..98a080a 100755 --- a/src/glue/album.cr +++ b/src/glue/album.cr @@ -6,7 +6,7 @@ require "./list" class Album < SpotifyList - @music_directory = Config.music_directory + @home_music_directory = Config.music_directory # Uses the `spotify_searcher` defined in parent `SpotifyList` to find the # correct metadata of the list @@ -27,39 +27,39 @@ class Album < SpotifyList # of spotify's album json. Moves the title of the album and the album art # to the json of the single song def organize_song_metadata(list : JSON::Any, datum : JSON::Any) : JSON::Any - json_string = %( - { - "album": { - "name": "#{list["name"]}", - "images": [{"url": "#{list["images"][0]["url"]}"}] - }, - ) - datum.as_h.keys.each_with_index do |key, index| - value = datum[key] - if value.as_s? - json_string += %("#{key}": "#{datum[key]}") - else - json_string += %("#{key}": #{datum[key].to_s.gsub(" => ", ": ")}) - end - - if index != datum.as_h.keys.size - 1 - json_string += ",\n" - end + json_string = %( + { + "album": { + "name": "#{list["name"]}", + "images": [{"url": "#{list["images"][0]["url"]}"}] + }, + ) + datum.as_h.keys.each_with_index do |key, index| + value = datum[key] + if value.as_s? + json_string += %("#{key}": "#{datum[key]}") + else + json_string += %("#{key}": #{datum[key].to_s.gsub(" => ", ": ")}) end - json_string += %( - } - ) - json_string = json_string.gsub(" ", "") - json_string = json_string.gsub("\n", " ") - json_string = json_string.gsub("\t", "") + if index != datum.as_h.keys.size - 1 + json_string += ",\n" + end + end + json_string += %( + } + ) - data = JSON.parse(json_string) + json_string = json_string.gsub(" ", "") + json_string = json_string.gsub("\n", " ") + json_string = json_string.gsub("\t", "") - return data + data = JSON.parse(json_string) + + return data end private def organize(song : Song) - song.organize_it(@music_directory) + song.organize_it(@home_music_directory) end end