Background
While using hightide, an application which relies on this project for it's API requests, I noticed that songs that are not "MAX" quality (hi-res lossless), started streamed with AAC (320 kbps). Confused, as I remember clearly that albums never streamed in AAC format and were always at least FLAC (16-bit, 44.1 kHz), I started investigating. I believe that the issue is with change in TIDAL API as it returns AAC instead of FLAC when using the older endpoint, it does not behave like that in the browser.
Issue
When calling get_stream() the URL being accessed is at tracks/%s/playbackinfopostpaywall and included parameters the max quality will be returned "HIGH". Using Postman and hitting endpoint on Hellfire by blackmidi that has max quality of FLAC (16-bit, 44.1 kHz) as reported by the TIDAL website:
We get max quality of HIGH instead of LOSSLESS:
"trackId": 234935929,
"assetPresentation": "FULL",
"audioMode": "STEREO",
"audioQuality": "HIGH",
Logging using Chrome and copying the request that is done in TIDAL website, using the URL of https://openapi.tidal.com/v2/trackManifests/{TRACKID}?adaptive=true&formats=HEAACV1&formats=AACLC&formats=FLAC&formats=FLAC_HIRES&manifestType=MPEG_DASH&uriScheme=DATA&usage=PLAYBACK for the same track we get FLAC included as the quality formats:
"formats": [
"HEAACV1",
"AACLC",
"FLAC"
],
To verify, I used the tests/test_media.py, but replaced the "D-A-D / A Prayer for the Loud" to "blackmidi / Hellfire" album because I got 404 on the former, the issue is confirmed (also included an extra track from Ok Computer):
alex@alex-pc:~/Projects/python-tidal$ poetry run python -m pytest tests/test_media.py::test_track_quality_lossless -v -s
==================================================================================================================================================================================== test session starts =====================================================================================================================================================================================
platform linux -- Python 3.13.3, pytest-7.4.4, pluggy-1.6.0 -- /home/alex/.cache/pypoetry/virtualenvs/tidalapi-MV8f72zH-py3.13/bin/python
cachedir: .pytest_cache
rootdir: /home/alex/Projects/python-tidal
plugins: mock-3.15.1
collected 1 item
tests/test_media.py::test_track_quality_lossless FAILED
========================================================================================================================================================================================== FAILURES ==========================================================================================================================================================================================
________________________________________________________________________________________________________________________________________________________________________________ test_track_quality_lossless _________________________________________________________________________________________________________________________________________________________________________________
session = <tidalapi.session.Session object at 0x7a392729d550>
def test_track_quality_lossless(session):
# Session should allow highest possible quality (but will fallback to highest available album quality)
session.audio_quality = Quality.hi_res_lossless
# WAS D-A-D / A Prayer for the Loud - changed to blackmidi / HELLFIRE (Max quality: LOSSLESS FLAC, 16bit/44.1kHz) because 404d for me :(
album = session.album("234935928")
track = album.tracks()[0]
assert track.audio_quality == "LOSSLESS"
assert track.audio_modes == ["STEREO"]
# Only LOSSLESS is available for this album
assert not track.is_hi_res_lossless
assert track.is_lossless
stream = track.get_stream()
assert (
not stream.is_mpd and stream.is_bts
) # LOW/HIGH/LOSSLESS streams will use BTS, if OAuth authentication is used.
> assert stream.audio_quality == "LOSSLESS"
E AssertionError: assert 'HIGH' == 'LOSSLESS'
E - LOSSLESS
E + HIGH
tests/test_media.py:326: AssertionError
================================================================================================================================================================================== short test summary info ===================================================================================================================================================================================
FAILED tests/test_media.py::test_track_quality_lossless - AssertionError: assert 'HIGH' == 'LOSSLESS'
===================================================================================================================================================================================== 1 failed in 0.60s ======================================================================================================================================================================================
alex@alex-pc:~/Projects/python-tidal$ poetry run python -m pytest tests/test_media.py::test_track_quality_lossless -v -s
==================================================================================================================================================================================== test session starts =====================================================================================================================================================================================
platform linux -- Python 3.13.3, pytest-7.4.4, pluggy-1.6.0 -- /home/alex/.cache/pypoetry/virtualenvs/tidalapi-MV8f72zH-py3.13/bin/python
cachedir: .pytest_cache
rootdir: /home/alex/Projects/python-tidal
plugins: mock-3.15.1
collected 1 item
tests/test_media.py::test_track_quality_lossless FAILED
========================================================================================================================================================================================== FAILURES ==========================================================================================================================================================================================
________________________________________________________________________________________________________________________________________________________________________________ test_track_quality_lossless _________________________________________________________________________________________________________________________________________________________________________________
session = <tidalapi.session.Session object at 0x797874fe1550>
def test_track_quality_lossless(session):
# Session should allow highest possible quality (but will fallback to highest available album quality)
session.audio_quality = Quality.hi_res_lossless
# WAS D-A-D / A Prayer for the Loud - changed to radiohead / ok computer (Max quality: LOSSLESS FLAC, 16bit/44.1kHz) because 404d for me :(
album = session.album("75144326")
track = album.tracks()[0]
assert track.audio_quality == "LOSSLESS"
assert track.audio_modes == ["STEREO"]
# Only LOSSLESS is available for this album
assert not track.is_hi_res_lossless
assert track.is_lossless
stream = track.get_stream()
assert (
not stream.is_mpd and stream.is_bts
) # LOW/HIGH/LOSSLESS streams will use BTS, if OAuth authentication is used.
> assert stream.audio_quality == "LOSSLESS"
E AssertionError: assert 'HIGH' == 'LOSSLESS'
E - LOSSLESS
E + HIGH
tests/test_media.py:326: AssertionError
================================================================================================================================================================================== short test summary info ===================================================================================================================================================================================
FAILED tests/test_media.py::test_track_quality_lossless - AssertionError: assert 'HIGH' == 'LOSSLESS'
===================================================================================================================================================================================== 1 failed in 0.63s ======================================================================================================================================================================================
alex@alex-pc:~/Projects/python-tidal$ git diff
diff --git a/tests/test_media.py b/tests/test_media.py
index c162da6..8e2c3f0 100644
--- a/tests/test_media.py
+++ b/tests/test_media.py
@@ -311,8 +311,8 @@ def test_track_quality_low320k(session):
def test_track_quality_lossless(session):
# Session should allow highest possible quality (but will fallback to highest available album quality)
session.audio_quality = Quality.hi_res_lossless
- # D-A-D / A Prayer for the Loud (Max quality: LOSSLESS FLAC, 16bit/44.1kHz)
- album = session.album("172358622")
+ # WAS D-A-D / A Prayer for the Loud - changed to radiohead / ok computer (Max quality: LOSSLESS FLAC, 16bit/44.1kHz) because 404d for me :(
+ album = session.album("75144326")
track = album.tracks()[0]
assert track.audio_quality == "LOSSLESS"
assert track.audio_modes == ["STEREO"]
alex@alex-pc:~/Projects/python-tidal$ git pull
Already up to date.
alex@alex-pc:~/Projects/python-tidal$ git branch
* main
alex@alex-pc:~/Projects/python-tidal$
Conclusion:
This affects streaming of non "MAX" quality songs as everything defaults to AAC. Choosing lower default profile of LOSSLESS starts streaming every album at AAC. I tried poking around at the code changing the endpoint, which was successful with FLAC being reported, but I figured really quickly that I do not understand enough to make this a permanent change (as it errored out and there was some weird behavior of not accepting 24-bit FLAC), nor I understand TIDAL API enough to be able to comfortably make this change. So I simply put my findings here to show that there is an issue and that using new endpoint should fix it.
Background
While using hightide, an application which relies on this project for it's API requests, I noticed that songs that are not "MAX" quality (hi-res lossless), started streamed with AAC (320 kbps). Confused, as I remember clearly that albums never streamed in AAC format and were always at least FLAC (16-bit, 44.1 kHz), I started investigating. I believe that the issue is with change in TIDAL API as it returns AAC instead of FLAC when using the older endpoint, it does not behave like that in the browser.
Issue
When calling
get_stream()the URL being accessed is attracks/%s/playbackinfopostpaywalland included parameters the max quality will be returned "HIGH". Using Postman and hitting endpoint on Hellfire by blackmidi that has max quality of FLAC (16-bit, 44.1 kHz) as reported by the TIDAL website:We get max quality of HIGH instead of LOSSLESS:
Logging using Chrome and copying the request that is done in TIDAL website, using the URL of
https://openapi.tidal.com/v2/trackManifests/{TRACKID}?adaptive=true&formats=HEAACV1&formats=AACLC&formats=FLAC&formats=FLAC_HIRES&manifestType=MPEG_DASH&uriScheme=DATA&usage=PLAYBACKfor the same track we get FLAC included as the quality formats:To verify, I used the tests/test_media.py, but replaced the "D-A-D / A Prayer for the Loud" to "blackmidi / Hellfire" album because I got 404 on the former, the issue is confirmed (also included an extra track from Ok Computer):
Conclusion:
This affects streaming of non "MAX" quality songs as everything defaults to AAC. Choosing lower default profile of LOSSLESS starts streaming every album at AAC. I tried poking around at the code changing the endpoint, which was successful with FLAC being reported, but I figured really quickly that I do not understand enough to make this a permanent change (as it errored out and there was some weird behavior of not accepting 24-bit FLAC), nor I understand TIDAL API enough to be able to comfortably make this change. So I simply put my findings here to show that there is an issue and that using new endpoint should fix it.