Skip to content

Commit 831d050

Browse files
authored
Merge pull request #228 from tamland/v0.7.4-prep
V0.7.4 prep
2 parents 4a08d05 + 5fc1747 commit 831d050

16 files changed

+147
-52
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,7 @@ prof/
8181
*tidal-oauth*
8282

8383
# Misc. csv. files that might be generated when executing examples
84-
*.csv
84+
*.csv
85+
86+
# Json session files
87+
tidal*.json

HISTORY.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
History
44
=======
55

6+
v0.7.4
7+
------
8+
* Load/store OAuth/PKCE session to file - tehkillerbee_
9+
* Add PKCE login for HiRes - exislow_, arnesongit_
10+
* Include request response on error. Print as warning - tehkillerbee_
11+
* Fix tests - tehkillerbee_
12+
* Bugfixes (artist.get_similar) - tehkillerbee_
13+
* Favourite mixes refactoring - jozefKruszynski_
14+
* Add typings for Playlist, UserPlaylist, Pages - arusahni_
15+
* Update favorites.tracks to accept order and orderDirection params - Jimmyscene_
16+
617
v0.7.3
718
------
819
* Official support for HI_RES FLAC quality - tehkillerbee_
@@ -138,6 +149,9 @@ v0.6.2
138149
.. _PretzelVector: https://github.com/PretzelVector
139150
.. _tehkillerbee: https://github.com/tehkillerbee
140151
.. _JoshMock: https://github.com/JoshMock
152+
.. _exislow: https://github.com/exislow
153+
.. _arnesongit: https://github.com/arnesongit
154+
.. _Jimmyscene: https://github.com/Jimmyscene
141155

142156

143157

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ Install from `PyPI <https://pypi.python.org/pypi/tidalapi/>`_ using ``pip``:
2222
2323
2424
25-
Example usage
25+
Usage
2626
-------------
2727

28-
For examples on how to use the api, see the `examples` directory.
28+
For examples on how to use the api, see the `examples <https://github.com/tamland/python-tidal/tree/master/examples>`_ directory.
2929

3030
Documentation
3131
-------------

examples/pkce_login.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# Copyright (C) 2023- The Tidalapi Developers
4+
#
5+
# This program is free software: you can redistribute it and/or modify
6+
# it under the terms of the GNU Lesser General Public License as published by
7+
# the Free Software Foundation, either version 3 of the License, or
8+
# (at your option) any later version.
9+
#
10+
# This program is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU Lesser General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU Lesser General Public License
16+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
#
18+
"""simple.py: A simple example script that describes how to get started using tidalapi"""
19+
20+
import tidalapi
21+
from tidalapi import Quality
22+
from pathlib import Path
23+
24+
session_file1 = Path("tidal-session-pkce.json")
25+
26+
session = tidalapi.Session()
27+
# Load session from file; create a new session if necessary
28+
session.login_session_file(session_file1, do_pkce=True)
29+
30+
# Override the required playback quality, if necessary
31+
# Note: Set the quality according to your subscription.
32+
# Low: Quality.low_96k
33+
# Normal: Quality.low_320k
34+
# HiFi: Quality.high_lossless
35+
# HiFi+ Quality.hi_res_lossless
36+
session.audio_quality = Quality.hi_res_lossless.value
37+
38+
album = session.album("110827651") # Let's Rock // The Black Keys
39+
tracks = album.tracks()
40+
# list album tracks
41+
for track in tracks:
42+
print(track.name)
43+
# MPEG-DASH Stream is only supported when HiRes mode is used!
44+
print(track.get_stream())
45+
for artist in track.artists:
46+
print(' by: ', artist.name)

examples/simple.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,27 @@
2121
from tidalapi import Quality
2222
from pathlib import Path
2323

24-
oauth_file1 = Path("tidal-oauth-user.json")
24+
session_file1 = Path("tidal-session-oauth.json")
2525

2626
session = tidalapi.Session()
27-
# Will run until you visit the printed url and link your account
28-
session.login_oauth_file(oauth_file1)
27+
# Load session from file; create a new session if necessary
28+
session.login_session_file(session_file1)
29+
2930
# Override the required playback quality, if necessary
3031
# Note: Set the quality according to your subscription.
32+
# Low: Quality.low_96k
3133
# Normal: Quality.low_320k
3234
# HiFi: Quality.high_lossless
3335
# HiFi+ Quality.hi_res_lossless
3436
session.audio_quality = Quality.low_320k
3537

36-
album = session.album(66236918) # Electric For Life Episode 099
38+
album = session.album("110827651") # Let's Rock // The Black Keys
3739
tracks = album.tracks()
3840
print(album.name)
3941
# list album tracks
4042
for track in tracks:
4143
print(track.name)
44+
print(track.get_url())
45+
# print(track.get_stream())
4246
for artist in track.artists:
4347
print(' by: ', artist.name)

examples/transfer_favorites.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
logger.setLevel(logging.INFO)
2929
logger.addHandler(logging.StreamHandler(sys.stdout))
3030

31-
oauth_file1 = Path("tidal-oauth-user.json")
32-
oauth_file2 = Path("tidal-oauth-userB.json")
31+
oauth_file1 = Path("tidal-session.json")
32+
oauth_file2 = Path("tidal-session-B.json")
3333

3434

3535
class TidalSession:
@@ -84,11 +84,11 @@ def do_transfer(self):
8484
session_src = self.session_src.get_session()
8585
session_dst = self.session_dst.get_session()
8686
logger.info("Login to user A (source)...")
87-
if not session_src.login_oauth_file(oauth_file1):
87+
if not session_src.login_session_file(oauth_file1):
8888
logger.error("Login to Tidal user...FAILED!")
8989
exit(1)
9090
logger.info("Login to user B (destination)...")
91-
if not session_dst.login_oauth_file(oauth_file2):
91+
if not session_dst.login_session_file(oauth_file2):
9292
logger.error("Login to Tidal user...FAILED!")
9393
exit(1)
9494

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "tidalapi"
3-
version = "0.7.3"
3+
version = "0.7.4"
44
description = "Unofficial API for TIDAL music streaming service."
55
authors = ["Thomas Amland <[email protected]>"]
66
maintainers = ["tehkillerbee <[email protected]>"]

tests/test_album.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,12 @@ def test_default_image_used_if_no_cover_art(mocker):
109109
def test_similar(session):
110110
album = session.album(108043414)
111111
for alb in album.similar():
112-
assert isinstance(alb.similar()[0], tidalapi.Album)
112+
if alb.id == 64522277:
113+
# Album with no similar albums should trigger AttributeError (response: 404)
114+
with pytest.raises(AttributeError):
115+
alb.similar()
116+
else:
117+
assert isinstance(alb.similar()[0], tidalapi.Album)
113118

114119

115120
def test_review(session):

tests/test_media.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,10 @@ def test_lyrics(session):
7474

7575
def test_no_lyrics(session):
7676
track = session.track(17626400)
77-
with pytest.raises(requests.HTTPError) as exception:
77+
# Tracks with no lyrics should trigger AttributeError (response: 404)
78+
with pytest.raises(AttributeError):
7879
track.lyrics()
7980

80-
assert exception.value.response.status_code == 404
81-
8281

8382
def test_right_to_left(session):
8483
lyrics = session.track(95948697).lyrics()
@@ -97,7 +96,7 @@ def test_track_with_album(session):
9796

9897
def test_track_streaming(session):
9998
track = session.track(62392768)
100-
stream = track.stream()
99+
stream = track.get_stream()
101100
assert stream.audio_mode == "STEREO"
102101
assert (
103102
stream.audio_quality == tidalapi.Quality.low_320k.value

tests/test_page.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ def test_explore(session):
2929
assert explore
3030

3131

32-
@pytest.mark.xfail
3332
def test_get_explore_items(session):
3433
explore = session.explore()
3534
iterator = iter(explore)
@@ -79,7 +78,7 @@ def test_page_iterator(session):
7978

8079
def test_get_video_items(session):
8180
videos = session.videos()
82-
mix = videos.categories[1].items[0].get()
81+
mix = videos.categories[1].items[0]
8382
for item in mix.items():
8483
assert isinstance(item, tidalapi.Video)
8584

@@ -110,7 +109,7 @@ def test_genres(session):
110109
def test_moods(session):
111110
moods = session.moods()
112111
first = next(iter(moods))
113-
assert first.title == "Collabs"
112+
assert first.title == "For DJs"
114113
assert isinstance(next(iter(first.get())), tidalapi.Playlist)
115114

116115

0 commit comments

Comments
 (0)