EbbLabs/python-tidal

[Fix] potential logical loop of is_encrypted / encryption_key in StreamManifest

Closed this issue · 2 comments

from https://github.com/tamland/python-tidal/blob/d81b8342a65873dffe7d4940458c4f20e9bdf67d/tidalapi/media.py#L613-L615
we can find that encryption_key is only assigned when self.is_encrypted is True, but in
https://github.com/tamland/python-tidal/blob/d81b8342a65873dffe7d4940458c4f20e9bdf67d/tidalapi/media.py#L671-L673
is_encrypted is derived from encryption_key, which causes a logic loop: is_encrypted is always False and encryption_key is always None.

I suggest the following fix:
change L613-L615 into

            self.encryption_type = stream_manifest["encryptionType"]
            self.encryption_key = (
                stream_manifest["keyId"] if self.encryption_type else None
            )

which produces correct decrypted flac in my test env.
image

Good catch! Do you have an example track to test this?

Also, from your other comment, it looks like you also need to set access_token before BTS streaming will work.

In this case, I use https://tidal.com/browse/track/75364971 as the test case.
It is short but has high resolution.

Yes I do manually set the access_token to make it work