File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,15 @@ def test_track_url(session):
5757 assert 'audio.tidal.com' in track .get_url ()
5858
5959
60+ def test_track_with_album (session ):
61+ track_id = 142278122
62+ track = session .track (track_id )
63+ print (track .album )
64+ assert track .album .duration is None
65+ track = session .track (track_id , True )
66+ assert track .album .duration == 221
67+
68+
6069def test_video (session ):
6170 video = session .video (125506698 )
6271
Original file line number Diff line number Diff line change @@ -484,16 +484,23 @@ def playlist(self, playlist_id=None):
484484
485485 return tidalapi .Playlist (session = self , playlist_id = playlist_id ).factory ()
486486
487- def track (self , track_id = None ):
487+ def track (self , track_id = None , with_album = False ):
488488 """
489489 Function to create a Track object with access to the session instance in a smoother way.
490490 Calls :class:`tidalapi.Track(session=session, track_id=track_id) <.Track>` internally
491491
492492 :param track_id: (Optional) The TIDAL id of the Track. You may want access to the methods without an id.
493+ :param with_album: (Optional) Whether to fetch the complete :class:`.Album` for the track or not
493494 :return: Returns a :class:`.Track` object that has access to the session instance used.
494495 """
495496
496- return tidalapi .Track (session = self , media_id = track_id )
497+ item = tidalapi .Track (session = self , media_id = track_id )
498+ if item .album and with_album :
499+ album = self .album (item .album .id )
500+ if album :
501+ item .album = album
502+
503+ return item
497504
498505 def video (self , video_id = None ):
499506 """
You can’t perform that action at this time.
0 commit comments