import requests from pathlib import Path class CoverDownloader: def __init__(self, outdir: str): self.outdir = outdir def download(self, url: str, artist: str, song: str, spotify_uri: str): Path(self.outdir).mkdir(parents=True, exist_ok=True) with open(Path(self.outdir) / f"{artist} - {song} - {spotify_uri}.jpg", "wb") as f: f.write(requests.get(url).content)