fixed indentation

This commit is contained in:
Cooper Hammond 2020-03-28 01:23:41 -07:00
parent eb3f332521
commit 4e0ba7ec79

View file

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