mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-06-19 09:13:53 +00:00
Merge 0835b60486 into 351d4223d0
This commit is contained in:
commit
2e8f578653
@ -1654,6 +1654,37 @@ class Spotify:
|
|||||||
before=before,
|
before=before,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def current_user_saved_audiobooks(self, limit=20, offset=0):
|
||||||
|
""" Get the current user's saved audiobooks
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
- limit - the number of audibooks to return
|
||||||
|
- offset - the index of the first audibook to return
|
||||||
|
"""
|
||||||
|
return self._get("me/audiobooks", limit=limit, offset=offset)
|
||||||
|
|
||||||
|
def current_user_saved_audiobooks_add(self, audiobooks=None):
|
||||||
|
""" Add one or more audiobooks to the current user's library.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
- audiobooks - a list of audiobook URIs, URLs or IDs
|
||||||
|
"""
|
||||||
|
elist = []
|
||||||
|
if audiobooks is not None:
|
||||||
|
elist = [self._get_id("audiobook", e) for e in audiobooks]
|
||||||
|
return self._put("me/audiobooks/?ids=" + ",".join(elist))
|
||||||
|
|
||||||
|
def current_user_saved_audiobooks_delete(self, audiobooks=None):
|
||||||
|
""" Remove one or more audiobooks from the current user's library.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
- audiobooks - a list of audiobook URIs, URLs or IDs
|
||||||
|
"""
|
||||||
|
elist = []
|
||||||
|
if audiobooks is not None:
|
||||||
|
elist = [self._get_id("audiobook", e) for e in audiobooks]
|
||||||
|
return self._delete("me/audiobooks/?ids=" + ",".join(elist))
|
||||||
|
|
||||||
def user_follow_artists(self, ids=[]):
|
def user_follow_artists(self, ids=[]):
|
||||||
""" Follow one or more artists
|
""" Follow one or more artists
|
||||||
Parameters:
|
Parameters:
|
||||||
|
|||||||
@ -221,6 +221,11 @@ class SpotipyLibraryApiTests(unittest.TestCase):
|
|||||||
"spotify:episode:3OEdPEYB69pfXoBrhvQYeC",
|
"spotify:episode:3OEdPEYB69pfXoBrhvQYeC",
|
||||||
"spotify:episode:5LEFdZ9pYh99wSz7Go2D0g"
|
"spotify:episode:5LEFdZ9pYh99wSz7Go2D0g"
|
||||||
]
|
]
|
||||||
|
cls.audiobook_ids = [
|
||||||
|
"spotify:audiobook:7iHfbu1YPACw6oZPAFJtqe",
|
||||||
|
"spotify:audiobook:1HGw3J3NxZO1TP1BTtVhpZ",
|
||||||
|
"spotify:audiobook:7iHfbu1YPACw6oZPAFJtqe"
|
||||||
|
]
|
||||||
cls.username = os.getenv(CCEV['client_username'])
|
cls.username = os.getenv(CCEV['client_username'])
|
||||||
|
|
||||||
scope = (
|
scope = (
|
||||||
@ -248,6 +253,19 @@ class SpotipyLibraryApiTests(unittest.TestCase):
|
|||||||
tracks = self.spotify.current_user_saved_tracks()
|
tracks = self.spotify.current_user_saved_tracks()
|
||||||
self.assertGreaterEqual(len(tracks['items']), 0)
|
self.assertGreaterEqual(len(tracks['items']), 0)
|
||||||
|
|
||||||
|
def test_current_user_saved_audiobooks(self):
|
||||||
|
audiobooks = self.spotify.current_user_saved_audiobooks()
|
||||||
|
total = audiobooks['total']
|
||||||
|
self.spotify.current_user_saved_audiobooks_add(self.audiobook_ids)
|
||||||
|
|
||||||
|
new_audiobooks = self.spotify.current_user_saved_audiobooks()
|
||||||
|
new_total = new_audiobooks['total']
|
||||||
|
self.assertEqual(new_total - total, len(self.audiobook_ids))
|
||||||
|
|
||||||
|
self.spotify.current_user_saved_audiobooks_delete(self.audiobook_ids)
|
||||||
|
new_audiobooks = self.spotify.current_user_saved_audiobooks()
|
||||||
|
new_total = new_audiobooks['total']
|
||||||
|
|
||||||
def test_current_user_save_tracks(self):
|
def test_current_user_save_tracks(self):
|
||||||
tracks = self.spotify.current_user_saved_tracks()
|
tracks = self.spotify.current_user_saved_tracks()
|
||||||
total = tracks['total']
|
total = tracks['total']
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user