diff --git a/streamrip/clients.py b/streamrip/clients.py index 2f02440..33be378 100644 --- a/streamrip/clients.py +++ b/streamrip/clients.py @@ -1221,7 +1221,14 @@ class SoundCloudClient(Client): resp, _ = self._get(f"search/{media_type}s", params=params) return resp - def _get(self, path, params=None, no_base=False) -> Tuple[dict, int]: + def _get( + self, + path, + params=None, + no_base=False, + skip_decode=False, + headers=None, + ) -> Optional[Tuple[dict, int]]: """Send a request to the SoundCloud API. :param path: @@ -1246,6 +1253,11 @@ class SoundCloudClient(Client): url = f"{SOUNDCLOUD_BASE}/{path}" logger.debug("Fetching url %s with params %s", url, params) - r = self.session.get(url, params=params) + r = self.session.get(url, params=params, headers=headers) + + r.raise_for_status() + + if skip_decode: + return None return r.json(), r.status_code diff --git a/streamrip/constants.py b/streamrip/constants.py index afdb23a..e8eb3b0 100644 --- a/streamrip/constants.py +++ b/streamrip/constants.py @@ -7,9 +7,12 @@ AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 Firef TIDAL_COVER_URL = ( "https://resources.tidal.com/images/{uuid}/{width}x{height}.jpg" ) -SOUNDCLOUD_CLIENT_ID = "QFciLWLC1GS4P3EZvXIjA3jKhKO5pKB3" +# Get this from (base64encoded) +# aHR0cHM6Ly9hLXYyLnNuZGNkbi5jb20vYXNzZXRzLzItYWIxYjg1NjguanM= +# Don't know if this is a static url yet +SOUNDCLOUD_CLIENT_ID = "qHsjZaNbdTcABbiIQnVfW07cEPGLNjIh" SOUNDCLOUD_USER_ID = "672320-86895-162383-801513" -SOUNDCLOUD_APP_VERSION = "1626941202" +SOUNDCLOUD_APP_VERSION = "1630917744" QUALITY_DESC = { diff --git a/streamrip/metadata.py b/streamrip/metadata.py index bbd0cf4..900c3b0 100644 --- a/streamrip/metadata.py +++ b/streamrip/metadata.py @@ -270,6 +270,7 @@ class TrackMetadata: self.tracknumber = 0 self.tracktotal = 0 self.quality = 0 + self.cover_urls = get_cover_urls(track, "soundcloud") else: raise ValueError(self.__source) diff --git a/streamrip/utils.py b/streamrip/utils.py index 864aa66..2ccc2a7 100644 --- a/streamrip/utils.py +++ b/streamrip/utils.py @@ -462,7 +462,7 @@ def get_container(quality: int, source: str) -> str: return "MP3" -def get_cover_urls(resp: dict, source: str, is_track: bool = True) -> dict: +def get_cover_urls(resp: dict, source: str) -> dict: """Parse a response dict containing cover info according to the source. :param resp: