summaryrefslogtreecommitdiff
path: root/rust/scripts/populate/main.py
diff options
context:
space:
mode:
authornil0j <nil.jimeno@estudiant.fjaverianas.com>2024-09-27 17:27:02 +0200
committernil0j <nil.jimeno@estudiant.fjaverianas.com>2024-09-27 17:27:02 +0200
commit4328dd17bfcd4c33a77c4405d52c3660a6c62bf5 (patch)
tree62b48c5088fac13b93a3bcdaa85f4594601cf3fe /rust/scripts/populate/main.py
parentdb58cb58b5d5612ec2aa347d0f8531b26ab2e7f3 (diff)
update
Diffstat (limited to 'rust/scripts/populate/main.py')
-rw-r--r--rust/scripts/populate/main.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/rust/scripts/populate/main.py b/rust/scripts/populate/main.py
new file mode 100644
index 0000000..ec0157c
--- /dev/null
+++ b/rust/scripts/populate/main.py
@@ -0,0 +1,46 @@
+from albums import album_data
+import api
+import parser
+import database
+
+
+def start():
+ print("downloading data...")
+ api.download_albums(album_data)
+
+ print("uploading data...")
+ upload_albums(
+ get_album_data(),
+ get_artist_names()
+ )
+ database.close()
+ print("upload finished!")
+ print("remember to move the covers directory once you're done")
+
+
+def upload_albums(album_data, artist_names):
+ database.process_artists(artist_names)
+ database.process_albums(album_data)
+
+
+def get_album_data():
+ result = []
+
+ for artist_id, artist in enumerate(album_data, 1):
+ album_list = artist[1]
+
+ for album_id, album in enumerate(album_list, 1):
+ result.append(parser.process_json_file(album, album_id, artist_id))
+
+ return result
+
+
+def get_artist_names():
+ artist_data = []
+ [artist_data.append(
+ artist[0]
+ ) for artist in album_data]
+ return artist_data
+
+
+start()