mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-06-19 01:03:53 +00:00
Fix playlist add items (#559)
* fixed uri issue in playlist_add_items All uris were being converted to track uris making it impossible to add episodes to playlists. * Added tests for episode adds also fixed creep uri so those tests no longer fail * Fixed creep_url to match creep_uri * revert pip version, added FIX to changelog Co-authored-by: Paul Lamere <paull@spotify.com>
This commit is contained in:
parent
3d48d77615
commit
651080e3da
@ -37,6 +37,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- `user_playlist_is_following` in favor of `playlist_is_following`
|
||||
- `playlist_tracks` in favor of `playlist_items`
|
||||
|
||||
### Fixed
|
||||
- fixed issue where episode URIs were being converted to track URIs in playlist calls
|
||||
|
||||
## [2.13.0] - 2020-06-25
|
||||
|
||||
### Added
|
||||
|
||||
@ -1824,8 +1824,14 @@ class Spotify(object):
|
||||
return id
|
||||
|
||||
def _get_uri(self, type, id):
|
||||
if self._is_uri(id):
|
||||
return id
|
||||
else:
|
||||
return "spotify:" + type + ":" + self._get_id(type, id)
|
||||
|
||||
def _is_uri(self, uri):
|
||||
return uri.startswith("spotify:") and len(uri.split(':')) == 3
|
||||
|
||||
def _search_multiple_markets(self, q, limit, offset, type, markets, total):
|
||||
if total and limit > total:
|
||||
limit = total
|
||||
|
||||
@ -36,9 +36,9 @@ class AuthTestSpotipy(unittest.TestCase):
|
||||
|
||||
bad_id = 'BAD_ID'
|
||||
|
||||
creep_urn = 'spotify:track:3HfB5hBU0dmBt8T0iCmH42'
|
||||
creep_id = '3HfB5hBU0dmBt8T0iCmH42'
|
||||
creep_url = 'http://open.spotify.com/track/3HfB5hBU0dmBt8T0iCmH42'
|
||||
creep_urn = 'spotify:track:6b2oQwSGFkzsMtQruIWm2p'
|
||||
creep_id = '6b2oQwSGFkzsMtQruIWm2p'
|
||||
creep_url = 'http://open.spotify.com/track/6b2oQwSGFkzsMtQruIWm2p'
|
||||
el_scorcho_urn = 'spotify:track:0Svkvt5I79wficMFgaqEQJ'
|
||||
el_scorcho_bad_urn = 'spotify:track:0Svkvt5I79wficMFgaqEQK'
|
||||
pinkerton_urn = 'spotify:album:04xe676vyiTeYNXw15o9jT'
|
||||
|
||||
@ -25,6 +25,17 @@ class SpotipyPlaylistApiTest(unittest.TestCase):
|
||||
"spotify:track:1PB7gRWcvefzu7t3LJLUlf"]
|
||||
cls.username = os.getenv(CCEV['client_username'])
|
||||
|
||||
# be wary here, episodes sometimes go away forever
|
||||
# which could cause tests that rely on four_episodes
|
||||
# to fail
|
||||
|
||||
cls.four_episodes = [
|
||||
"spotify:episode:7f9e73vfXKRqR6uCggK2Xy",
|
||||
"spotify:episode:4wA1RLFNOWCJ8iprngXmM0",
|
||||
"spotify:episode:32vhLjJjT7m3f9DFCJUCVZ",
|
||||
"spotify:episode:7cRcsGYYRUFo1OF3RgRzdx",
|
||||
]
|
||||
|
||||
scope = (
|
||||
'playlist-modify-public '
|
||||
'user-library-read '
|
||||
@ -125,6 +136,22 @@ class SpotipyPlaylistApiTest(unittest.TestCase):
|
||||
playlist = self.spotify.playlist_items(self.new_playlist['id'])
|
||||
self.assertEqual(playlist["total"], 0)
|
||||
|
||||
def test_playlist_add_episodes(self):
|
||||
# add episodes to playlist
|
||||
self.spotify.playlist_add_items(
|
||||
self.new_playlist['id'], self.four_episodes)
|
||||
playlist = self.spotify.playlist_items(self.new_playlist['id'])
|
||||
self.assertEqual(playlist['total'], 4)
|
||||
self.assertEqual(len(playlist['items']), 4)
|
||||
|
||||
pl = self.spotify.playlist_items(self.new_playlist['id'], limit=2)
|
||||
self.assertEqual(len(pl["items"]), 2)
|
||||
|
||||
self.spotify.playlist_remove_all_occurrences_of_items(
|
||||
self.new_playlist['id'], self.four_episodes)
|
||||
playlist = self.spotify.playlist_items(self.new_playlist['id'])
|
||||
self.assertEqual(playlist["total"], 0)
|
||||
|
||||
def test_playlist_cover_image(self):
|
||||
# Upload random dog image
|
||||
r = requests.get('https://dog.ceo/api/breeds/image/random')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user