From f19bb2d06f5dadc50f490b2fe4f7f686ea0ac4a4 Mon Sep 17 00:00:00 2001 From: nathom Date: Wed, 12 May 2021 15:20:11 -0700 Subject: [PATCH] Fix soundcloud cover art --- .mypy.ini | 1 + streamrip/bases.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.mypy.ini b/.mypy.ini index 33356af..58be2fc 100644 --- a/.mypy.ini +++ b/.mypy.ini @@ -12,6 +12,7 @@ ignore_missing_imports = True [mypy-ruamel.yaml.*] ignore_missing_imports = True +follow_imports = skip [mypy-pick.*] ignore_missing_imports = True diff --git a/streamrip/bases.py b/streamrip/bases.py index ee37034..beccdbe 100644 --- a/streamrip/bases.py +++ b/streamrip/bases.py @@ -12,7 +12,7 @@ import re import shutil import subprocess from tempfile import gettempdir -from typing import Any, Union +from typing import Any, Union, Optional import click import tqdm @@ -386,15 +386,22 @@ class Track: :type client: Client """ meta = TrackMetadata(track=item, source=client.source) + cover_url: Optional[str] try: if client.source == "qobuz": cover_url = item["album"]["image"]["large"] elif client.source == "tidal": cover_url = tidal_cover_url(item["album"]["cover"], 640) elif client.source == "deezer": - cover_url = item["album"]["cover_large"] + cover_url = item["album"]["cover_big"] + elif client.source == "soundcloud": + if (small_url := item["artwork_url"]) is not None: + cover_url = small_url.replace("large", "t500x500") + else: + raise KeyError else: raise InvalidSourceError(client.source) + except KeyError: logger.debug("No cover found") cover_url = None