diff --git a/tests/test_artist.py b/tests/test_artist.py index df2e6bc..361c292 100644 --- a/tests/test_artist.py +++ b/tests/test_artist.py @@ -140,6 +140,12 @@ def test_get_radio(session): assert radio[0].artist.name == artist.name +def test_get_radio_mix(session): + artist = session.artist(3514310) + radio = artist.get_radio_mix() + assert radio.id == "000038b3b74d5ce3a17b43a36d62bb" + + def test_artist_image(session): artist = session.artist(4822757) verify_image_cover(session, artist, [160, 320, 480, 750]) diff --git a/tests/test_media.py b/tests/test_media.py index 04f4be4..534f98a 100644 --- a/tests/test_media.py +++ b/tests/test_media.py @@ -448,6 +448,12 @@ def test_get_track_radio_limit_100(session): assert len(similar_tracks) == 100 +def test_get_radio_mix(session): + track = session.track(12445712) + radio = track.get_radio_mix() + assert radio.id == "001c2cbc32b5b7c17f8c0aa55d9541" + + def test_get_stream_bts(session): track = session.track(77646170) # Beck: Sea Change, Track: The Golden Age # Set session as BTS type (i.e. low_320k/HIGH Quality) diff --git a/tidalapi/artist.py b/tidalapi/artist.py index 23cdf6f..003ce25 100644 --- a/tidalapi/artist.py +++ b/tidalapi/artist.py @@ -28,6 +28,8 @@ from tidalapi.exceptions import ObjectNotFound, TooManyRequests from tidalapi.types import JsonObj +from . import mix + if TYPE_CHECKING: from tidalapi.album import Album from tidalapi.media import Track, Video @@ -242,6 +244,16 @@ def get_radio(self) -> List["Track"]: ), ) + def get_radio_mix(self) -> mix.Mix: + """Queries TIDAL for the artist radio, which is a mix of tracks that are similar + to what the artist makes. + + :return: A :class:`Mix ` + """ + json = self.request.request("GET", f"artists/{self.id}/mix").json() + + return self.session.mix(json.get("id")) + def items(self) -> List[NoReturn]: """The artist page does not supply any items. This only exists for symmetry with other model types. diff --git a/tidalapi/media.py b/tidalapi/media.py index 598a823..17a1038 100644 --- a/tidalapi/media.py +++ b/tidalapi/media.py @@ -51,6 +51,8 @@ ) from tidalapi.types import JsonObj +from . import mix + class Quality(str, Enum): low_96k: str = "LOW" @@ -407,6 +409,16 @@ def get_track_radio(self, limit: int = 100) -> List["Track"]: assert isinstance(tracks, list) return cast(List["Track"], tracks) + def get_radio_mix(self) -> mix.Mix: + """Queries TIDAL for the track radio, which is a mix of tracks that are similar + to this track. + + :return: A :class:`Mix ` + """ + json = self.request.request("GET", f"tracks/{self.id}/mix").json() + + return self.session.mix(json.get("id")) + def get_stream(self) -> "Stream": """Retrieves the track streaming object, allowing for audio transmission.