diff --git a/streamrip/clients.py b/streamrip/clients.py index ea86b59..70b84de 100644 --- a/streamrip/clients.py +++ b/streamrip/clients.py @@ -660,14 +660,12 @@ class SoundCloudClient(ClientInterface): raise NotImplementedError def get(self, id=None, url=None, media_type="track"): - assert media_type in ("track", "playlist", "album"), f"{media_type} not supported" - if media_type == 'album': - media_type = 'playlist' + assert media_type in ("track", "playlist"), f"{media_type} not supported" if url is not None: resp, status = self._get(f"resolve?url={url}") elif id is not None: - resp, _ = self._get(f"tracks/{id}") + resp, _ = self._get(f"{media_type}s/{id}") else: raise Exception("Must provide id or url") diff --git a/streamrip/downloader.py b/streamrip/downloader.py index 5bff7c4..119b5f8 100644 --- a/streamrip/downloader.py +++ b/streamrip/downloader.py @@ -1,4 +1,5 @@ import logging +from pprint import pprint import sys import os import re @@ -752,25 +753,6 @@ class Album(Tracklist): "sampling_rate": 44100, "tracktotal": resp.get("track_total") or resp.get("nb_tracks"), } - elif client.source == 'soundcloud': - print(resp.keys()) - return { - "id": resp['id'], - "title": resp['title'], - "_artist": resp['user']['username'], - "albumartist": resp['user']['username'], - "year": resp['created_at'][:4], - "cover_urls": { - "small": resp['artwork_url'], - "large": resp['artwork_url'].replace('large', 't500x500') if resp['artwork_url'] is not None else None - }, - "url": resp['uri'], - "streamable": True, # assume to be true for convenience - "quality": 0, # always 128 kbps mp3 - # no bit depth - # no sampling rate - "tracktotal": resp['track_count'], - } raise InvalidSourceError(client.source) @@ -950,7 +932,7 @@ class Playlist(Tracklist): """Represents a downloadable playlist. Usage: - >>> resp = client.get('hip hop', 'playlist') + >>> resp = client.search('hip hop', 'playlist') >>> pl = Playlist.from_api(resp['items'][0], client) >>> pl.load_meta() >>> pl.download() @@ -993,7 +975,7 @@ class Playlist(Tracklist): :type new_tracknumbers: bool :param kwargs: """ - self.meta = self.client.get(self.id, "playlist") + self.meta = self.client.get(id=self.id, media_type="playlist") self._load_tracks(**kwargs) def _load_tracks(self, new_tracknumbers: bool = True): @@ -1036,6 +1018,10 @@ class Playlist(Tracklist): def meta_args(track): return {"track": track, "source": self.client.source} + elif self.client.source == 'soundcloud': + self.name = self.meta['title'] + tracklist = self.meta['tracks'] + else: raise NotImplementedError