mirror of
https://github.com/nadimkobeissi/mkbsd.git
synced 2025-01-11 12:35:31 +00:00
minor change for file extension
This commit is contained in:
parent
9dc407d510
commit
d11996f24d
9
mkbsd.py
9
mkbsd.py
|
@ -53,11 +53,14 @@ async def main():
|
|||
os.makedirs(artist_dir)
|
||||
print(f"📁 Created artist directory: {artist_dir}")
|
||||
|
||||
file_name_match = re.search(r'/([^/]+)\.(jpg|png)', image_url) # Extract file name from URL
|
||||
file_name_match = re.search(r'/([^/]+)\?', image_url) # Extract file name from URL
|
||||
if file_name_match:
|
||||
raw_file_name = file_name_match.group(1)
|
||||
sanitized_file_name = re.sub(r'[^a-zA-Z0-9 ]', '', raw_file_name).replace('~', ' ')
|
||||
file_path = os.path.join(artist_dir, f"{sanitized_file_name}.jpg")
|
||||
file_name = raw_file_name.split('.')[0]
|
||||
file_extension = raw_file_name.split('.')[-1]
|
||||
sanitized_file_name = file_name.replace('~', ' ')
|
||||
file_path = os.path.join(artist_dir, f"{sanitized_file_name}." + file_extension)
|
||||
print(f"📄 File path: {file_path}")
|
||||
|
||||
await download_image(session, image_url, file_path)
|
||||
print(f"🖼️ Saved image to {file_path}")
|
||||
|
|
Loading…
Reference in a new issue