diff options
Diffstat (limited to 'scripts/populate/parser.py')
-rw-r--r-- | scripts/populate/parser.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/scripts/populate/parser.py b/scripts/populate/parser.py index cbb51b5..fdce1c9 100644 --- a/scripts/populate/parser.py +++ b/scripts/populate/parser.py @@ -5,7 +5,7 @@ import os def process_json_file(name, album_id, artist_id): - link = getLink(name) + link = get_link(name) file_json = open(link, "r") album_json = file_json.read() @@ -14,8 +14,8 @@ def process_json_file(name, album_id, artist_id): return process_json(album_json, album_id, artist_id) -def getLink(name): - return "Lyrics_"+name.replace(" ", "")+".json" +def get_link(name): + return name.replace(" ", "")+".json" def process_json(album_json, album_id, artist_id): @@ -27,10 +27,13 @@ def process_json(album_json, album_id, artist_id): new_cover = get_cover_link(artist_id, album_id) download_cover(off_cover, new_cover, artist_id) - year = data["release_date_components"]["year"] - month = data["release_date_components"]["year"] - day = data["release_date_components"]["year"] - release = [year, month, day] + if data["release_date_components"]: + year = data["release_date_components"]["year"] + month = data["release_date_components"]["month"] + day = data["release_date_components"]["day"] + release = f"{year}-{month}-{day}" + else: + release = None songs = [analyze_song(song) for song in data["tracks"]] return structures.album(album_name, new_cover, songs, artist_id, release) |