Skip to content

Commit

Permalink
Add selectable track radio limit default 100
Browse files Browse the repository at this point in the history
  • Loading branch information
jkruszynski committed Aug 17, 2023
1 parent ae20b7c commit 2fa9000
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
22 changes: 20 additions & 2 deletions tests/test_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_track(session):
)
assert track.isrc == "NOG841907010"
assert track.explicit is False
assert track.audio_quality == tidalapi.Quality.master
assert track.audio_quality == tidalapi.Quality.hi_res
assert track.album.name == "Alone, Pt. II"

assert track.artist.name == "Alan Walker"
Expand All @@ -59,7 +59,7 @@ def test_track(session):


def test_track_url(session):
session.config = tidalapi.Config(quality=tidalapi.Quality.master)
session.config = tidalapi.Config(quality=tidalapi.Quality.hi_res)
track = session.track(142278122)
assert "audio.tidal.com" in track.get_url()

Expand Down Expand Up @@ -212,3 +212,21 @@ def test_track_media_metadata_tags(session):
track = session.track(182912246)
assert track.name == "All You Ever Wanted"
assert track.media_metadata_tags == ["LOSSLESS", "HIRES_LOSSLESS", "MQA"]


def test_get_track_radio_limit_default(session):
track = session.track(182912246)
similar_tracks = track.get_track_radio()
assert len(similar_tracks) == 100


def test_get_track_radio_limit_25(session):
track = session.track(182912246)
similar_tracks = track.get_track_radio(limit=25)
assert len(similar_tracks) == 25


def test_get_track_radio_limit_100(session):
track = session.track(182912246)
similar_tracks = track.get_track_radio(limit=100)
assert len(similar_tracks) == 100
4 changes: 2 additions & 2 deletions tidalapi/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,13 @@ def lyrics(self) -> "Lyrics":
assert not isinstance(lyrics, list)
return cast("Lyrics", lyrics)

def get_track_radio(self) -> List["Track"]:
def get_track_radio(self, limit=100) -> List["Track"]:
"""Queries TIDAL for the track radio, which is a mix of tracks that are similar
to this track.
:return: A list of :class:`Tracks <tidalapi.media.Track>`
"""
params = {"limit": 100}
params = {"limit": limit}
tracks = self.requests.map_request(
"tracks/%s/radio" % self.id, params=params, parse=self.session.parse_track
)
Expand Down

0 comments on commit 2fa9000

Please sign in to comment.