Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor image download logic to group images by artist name. fixes #55 #57

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
files are renamed during download.
  • Loading branch information
retardgerman committed Sep 27, 2024
commit 7fa0915766e2316e41471c65b1ae8358683f144f
12 changes: 6 additions & 6 deletions mkbsd.py
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
import aiohttp
import asyncio
from urllib.parse import urlparse

url = 'https://storage.googleapis.com/panels-api/data/20240916/media-1a-i-p~s'

async def delay(ms):
@@ -38,20 +39,19 @@ async def main():
os.makedirs(download_dir)
print(f"📁 Created directory: {download_dir}")

file_index = 1
for key, subproperty in data.items():
for file_index, (key, subproperty) in enumerate(data.items(), start=1):
if subproperty and subproperty.get('dhd'):
image_url = subproperty['dhd']
print(f"🔍 Found image URL!")
parsed_url = urlparse(image_url)
ext = os.path.splitext(parsed_url.path)[-1] or '.jpg'
filename = f"{file_index}{ext}"
file_path = os.path.join(download_dir, filename)

# Extrahiere den Dateinamen ohne .jpg
filename = os.path.basename(parsed_url.path).replace('.jpg', '') or f'image_{file_index}'
file_path = os.path.join(download_dir, f"{filename}.jpg")

await download_image(session, image_url, file_path)
print(f"🖼️ Saved image to {file_path}")

file_index += 1
await delay(250)

except Exception as e: