summaryrefslogtreecommitdiff
path: root/scrap/main.py
diff options
context:
space:
mode:
authorniliara-edu <nil.jimeno@estudiant.fjaverianas.com>2024-09-24 12:21:40 +0200
committerniliara-edu <nil.jimeno@estudiant.fjaverianas.com>2024-09-24 12:21:40 +0200
commit2e8ddbf422a3a6d75b1e1f73cad089111f801c05 (patch)
treea3b2c7ea8560fcbc89fb9b3ee15933d434b1ff51 /scrap/main.py
parentfaa13839f898c60ff5618be6e916ad2e60958468 (diff)
finished web scrapper
Diffstat (limited to 'scrap/main.py')
-rw-r--r--scrap/main.py53
1 files changed, 42 insertions, 11 deletions
diff --git a/scrap/main.py b/scrap/main.py
index 80f4d24..72a9929 100644
--- a/scrap/main.py
+++ b/scrap/main.py
@@ -1,18 +1,49 @@
-import lyricsgenius
-import sys
+from albums import album_data
+import api
+import parser
+import database
-def getAlbum(artist_name, album_name):
- genius = lyricsgenius.Genius(
- "0uSA9UFGsiO2WozVmbWPhyhOoVmUNuM3PXRt9rvWhptHBMgSO5CZBxGUMkwet5mv"
+def start():
+ print("do you want to download the json data from genius? [y, n] ", end="")
+ if input().lower() == "y":
+ api.download_albums(album_data)
+ print("download finished!")
+
+ database.setup()
+ upload_albums(
+ get_album_data(),
+ get_artist_names()
)
- album = genius.search_album(artist_name, album_name)
- album.save_lyrics()
+ 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():
+ album_data = []
+ artist_id = 0
+
+ for artist in album_data:
+ artist_id += 1
+
+ for album in artist[1]:
+ album_data.append(parser.process_json_file(album, artist_id))
+
+ return album_data
-def getJsonLyrics(link):
- for key, value in data.items():
- print(key, value)
+def get_artist_names():
+ artist_data = []
+ [artist_data.append(
+ artist[0]
+ ) for artist in album_data]
+ return artist_data
-getJsonLyrics(sys.argv[1])
+start()