summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornil0j <nil.jimeno@estudiant.fjaverianas.com>2024-09-25 17:30:42 +0200
committernil0j <nil.jimeno@estudiant.fjaverianas.com>2024-09-25 17:30:42 +0200
commit14662002d50908f83342c44594b81a5a8833a286 (patch)
treea3fb23afd00cbd57164ac9ce5cead5202686b340
parent7db54932e3cc445985a6577f460b18154ea7e3b0 (diff)
fix covers
-rw-r--r--scrap/parser.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/scrap/parser.py b/scrap/parser.py
index 618f642..a191fa2 100644
--- a/scrap/parser.py
+++ b/scrap/parser.py
@@ -23,7 +23,7 @@ def process_json(album_json, artist_id):
name = data["name"].lower()
artist_name_api = data["artist"]["name"].lower()
- artist_name = artist_name_api.replace(" ", "")
+ artist_name = format_artist_name(artist_name_api)
off_cover = data["cover_art_thumbnail_url"]
new_cover = get_cover_link(artist_name, name)
@@ -33,6 +33,12 @@ def process_json(album_json, artist_id):
return structures.album(name, new_cover, songs, artist_id)
+def format_artist_name(name):
+ name = name.replace(" ", "")
+ name = re.sub(r'[\(\[].*?[\)\]]', '', name)
+ return name
+
+
def get_cover_link(artist_name, album_name):
album_name = album_name.replace(" ", "")
location = f"covers/{artist_name}/{album_name}.png"
@@ -41,10 +47,10 @@ def get_cover_link(artist_name, album_name):
def download_cover(off_cover, new_cover, artist_name):
- if not os.path.isfile("covers"):
+ if not os.path.isdir("covers"):
os.system("mkdir covers")
- if not os.path.isfile(f"covers/{artist_name}"):
+ if not os.path.isdir(f"covers/{artist_name}"):
os.system(f"mkdir 'covers/{artist_name}'")
if not os.path.isfile(new_cover):