diff options
Diffstat (limited to 'scrap')
-rw-r--r-- | scrap/parser.py | 12 |
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): |