summaryrefslogtreecommitdiff
path: root/scripts/populate/parser.py
diff options
context:
space:
mode:
authorniliara-edu <nil.jimeno@estudiant.fjaverianas.com>2024-10-02 23:21:43 +0200
committerniliara-edu <nil.jimeno@estudiant.fjaverianas.com>2024-10-02 23:21:43 +0200
commit7df09f8b146ae7fb091787770fe5681381164f0e (patch)
tree0310d8dad1d0c6198d68d13b22030db3c5e8b28f /scripts/populate/parser.py
parent0972fa6eab8c9111311f082ba8abfdc6b4a40945 (diff)
fix database setup
Diffstat (limited to 'scripts/populate/parser.py')
-rw-r--r--scripts/populate/parser.py17
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)