Skip to content

Commit

Permalink
Fix: Logical loop of is_encrypted / encryption_key.
Browse files Browse the repository at this point in the history
  • Loading branch information
tehkillerbee committed Oct 14, 2024
1 parent 3ca065c commit d5df746
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
2 changes: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ History
=======
v0.7.7
------
* Bugfix: Logical loop of is_encrypted / encryption_key - TooYoungTooSimp_
* Tests: Added additional playlist, folder tests. - tehkillerbee_
* Feature: Add support for playlist merging. - tehkillerbee_
* Added trn to playlist object for convenience. - tehkillerbee_
Expand Down Expand Up @@ -215,6 +216,7 @@ v0.6.2
.. _quodrum-glas: https://github.com/quodrum-glas
.. _M4TH1EU: https://github.com/M4TH1EU
.. _GioF71: https://github.com/GioF71
.. _TooYoungTooSimp: https://github.com/TooYoungTooSimp



21 changes: 13 additions & 8 deletions examples/pkce_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
#
"""pkce_example.py: A simple example script that describes how to use PKCE login and MPEG-DASH streams"""

from pathlib import Path

import tidalapi
from tidalapi import Quality
from pathlib import Path

session_file1 = Path("tidal-session-pkce.json")

Expand Down Expand Up @@ -51,12 +52,16 @@
manifest = stream.get_stream_manifest()
audio_resolution = stream.get_audio_resolution()

print("track:{}, (quality:{}, codec:{}, {}bit/{}Hz)".format(track.id,
stream.audio_quality,
manifest.get_codecs(),
audio_resolution[0],
audio_resolution[1]))
if stream.is_MPD:
print(
"track:{}, (quality:{}, codec:{}, {}bit/{}Hz)".format(
track.id,
stream.audio_quality,
manifest.get_codecs(),
audio_resolution[0],
audio_resolution[1],
)
)
if stream.is_mpd:
# HI_RES_LOSSLESS quality supported when using MPEG-DASH stream (PKCE only!)
# 1. Export as MPD manifest
mpd = stream.get_manifest_data()
Expand All @@ -66,7 +71,7 @@
# my_file.write(mpd)
# with open("{}_{}.m3u8".format(album_id, track.id), "w") as my_file:
# my_file.write(hls)
elif stream.is_BTS:
elif stream.is_bts:
# Direct URL (m4a or flac) is available for Quality < HI_RES_LOSSLESS
url = manifest.get_urls()
break
2 changes: 1 addition & 1 deletion tidalapi/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ def __init__(self, stream: Stream):
self.mime_type = stream_manifest["mimeType"]
self.encryption_type = stream_manifest["encryptionType"]
self.encryption_key = (
stream_manifest["encryptionKey"] if self.is_encrypted else None
stream_manifest.get("keyId") if self.encryption_type else None
)
else:
raise UnknownManifestFormat
Expand Down

0 comments on commit d5df746

Please sign in to comment.