tamland / python-tidal

Python API for TIDAL music streaming service
GNU Lesser General Public License v3.0
402 stars 109 forks source link

Is BTS even possible with PKCE login? #258

Closed exislow closed 5 months ago

exislow commented 5 months ago

Currently I am a little bit confused: I thought, if I login with PKCE I am obligated to use MPD for each audio track, but I am allowed to get HIRES_LOSSLESS quality.

If I login with OAuth (no PKCE) I cannot get HIRES_LOSSLESS stream but I can use BTS, which can transfer files faster.

No I am checking the examples and this one suggests that even with PKCE login BTS mode could be possible: https://github.com/tamland/python-tidal/blob/master/examples/pkce_example.py

I have tried a lot of audio tracks but everytime is_BTS is False. Have you really found an audio track, which was available via BTS even if you have been logged in via PKCE?

tehkillerbee commented 5 months ago

The short answer is no, BTS is not possible, unless you use OAuth (do_pkce=False).

This was left in the pkce_example to illustrate how OAuth and PKCE sessions are handled differently. Perhaps a comment should be added to make sure confusion is avoided.

exislow commented 5 months ago

Thank you for clarification. A comment would be great. Also just general question: If you login with do_pkce=False and BTS is available, you can get the url using Track.get_url() or you will also get the same URL, if you use Track.get_stream().get_stream_manifest().urls.

So what's the difference here? Wouldn't it make more sense, to either a) remove Track.get_url() at all or b) make Track.get_url() available to MPD (if do_pkce=True) based streams and use it as a shortcut for Track.get_stream().get_stream_manifest().urls, the same it works for BTS based streams?

tehkillerbee commented 5 months ago

get_url() returns a single track url, while the parsed manifest urls contains a list of urls used for creating an m3u8 playlist. So they do not return the same thing and cannot be used interchangeably.

The urls from the stream manifest are meant to be used when creating an m3u8 hls so they should not be used / returned directly by get_url(). I think if we change this behaviour, it will create more confusion.

It is easier to use the MPD manifest directly, eg for track playback, so direct track url is rarely ever necessary (unless downloading tracks from tidal, of course).

exislow commented 5 months ago

get_url() returns a single track url, while the parsed manifest urls contains a list of urls used for creating an m3u8 playlist. So they do not return the same thing and cannot be used interchangeably.

This is the theory so far. But have you tried to retrieve track URLs, while logged in with do_pkce=False, with Track.get_url() and Track.get_stream().get_stream_manifest().urls and compared them? I cannot find a Track, where the results of these both methods differ. Please correct me if I am wrong.