Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tests/test_artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
6 changes: 6 additions & 0 deletions tests/test_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions tidalapi/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 <tidalapi.mix.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.
Expand Down
12 changes: 12 additions & 0 deletions tidalapi/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
)
from tidalapi.types import JsonObj

from . import mix


class Quality(str, Enum):
low_96k: str = "LOW"
Expand Down Expand Up @@ -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 <tidalapi.mix.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.

Expand Down