diff --git a/tests/test_api.py b/tests/test_api.py index 3496bbe..18e846a 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -24,7 +24,7 @@ logging.basicConfig(level=logging.DEBUG) -@pytest.fixture() +@pytest.fixture(scope='session') def session(): session = tidalapi.Session() username = os.getenv("TIDAL_USERNAME") @@ -108,17 +108,17 @@ def test_search(session): res = session.search('artist', 'lasgo') assert res.artists[0].name == "Lasgo" -def test_artist_image(session): +def test_artist_picture(session): artist = session.get_artist(16147) - assert requests.get(artist.image).status_code == 200 + assert requests.get(artist.picture(640,640)).status_code == 200 -def test_album_image(session): - artist = session.get_album(17925106) - assert requests.get(artist.image).status_code == 200 +def test_album_picture(session): + album = session.get_album(17925106) + assert requests.get(album.picture(640, 640)).status_code == 200 -def test_playlist_image(session): +def test_playlist_picture(session): playlist = session.get_playlist('33136f5a-d93a-4469-9353-8365897aaf94') - assert requests.get(playlist.image).status_code == 200 + assert requests.get(playlist.picture(750, 750)).status_code == 200 def test_get_track_url(session): track = session.get_track(108043415) diff --git a/tidalapi/__init__.py b/tidalapi/__init__.py index b83681d..fd9dc68 100644 --- a/tidalapi/__init__.py +++ b/tidalapi/__init__.py @@ -52,9 +52,7 @@ def __init__(self, quality=Quality.high, videoQuality=videoQuality.high): self.api_token = 'BI218mwp9ERZ3PFI' if self.quality == \ Quality.lossless else '4zx46pyr9o8qZNRw', - class Session(object): - def __init__(self, config=Config()): self.session_id = None self.country_code = None diff --git a/tidalapi/models.py b/tidalapi/models.py index 9029b22..9931687 100644 --- a/tidalapi/models.py +++ b/tidalapi/models.py @@ -38,7 +38,20 @@ class Album(Model): release_date = None @property - def image(self, width=512, height=512): + def image(self, width=1280, height=1280): + return IMG_URL.format(width=width, height=height, id=self.id, id_type='albumid') + + def picture(self, width, height): + """ + A url to an album picture + + :param width: pixel width, maximum 2000 + :type width: int + :param height: pixel height, maximum 2000 + :type height: int + + Original sizes: 80x80, 160x160, 320x320, 640x640 and 1280x1280 + """ return IMG_URL.format(width=width, height=height, id=self.id, id_type='albumid') @@ -47,7 +60,20 @@ class Artist(Model): role = None @property - def image(self, width=512, height=512): + def image(self, width=1280, height=1280): + return IMG_URL.format(width=height, height=height, id=self.id, id_type='artistid') + + def picture(self, width, height): + """ + A url to an artist picture + + :param width: pixel width, maximum 2000 + :type width: int + :param height: pixel height, maximum 2000 + :type height: int + + Original sizes: 80x80, 160x160, 320x320, 480x480, 640x640, 1280x1280 + """ return IMG_URL.format(width=width, height=height, id=self.id, id_type='artistid') @@ -62,9 +88,24 @@ class Playlist(Model): duration = -1 @property - def image(self, width=512, height=512): + def image(self, width=1080, height=1080): + return IMG_URL.format(width=width, height=height, id=self.id, id_type='uuid') + + def picture(self, width, height): + """ + A url to a playlist picture + + :param width: pixel width, maximum 2000 + :type width: int + :param height: pixel height, maximum 2000 + :type height: int + + Original sizes: 160x160, 320x320, 480x480, 640x640, 750x750, 1080x1080 + + """ return IMG_URL.format(width=width, height=height, id=self.id, id_type='uuid') + class Media(Model): duration = -1 track_num = -1 @@ -75,12 +116,15 @@ class Media(Model): album = None available = True + class Track(Media): pass + class Video(Media): type = None + class SearchResult(Model): artists = [] albums = []