spotipy/tests/helpers.py
Dj 024a6c96d4
Retries For All Endpoints, fixes #347 (#457)
* test_improvements - Add __init__.py files to tests dirs so you can run all tests

* test_improvements - added helpers file, restructured tests to work without previous data and to be grouped with api type

* http_retries - Implement Retry for all requests

* Readme - Update README with contributing info

* PR Feedback - Added CONTRIBUTING.md, fixed README, fixed test
2020-03-29 17:18:23 +01:00

20 lines
582 B
Python

import base64
import requests
def get_spotify_playlist(spotify_object, playlist_name, username):
playlists = spotify_object.user_playlists(username)
while playlists:
for item in playlists['items']:
if item['name'] == playlist_name:
return item
playlists = spotify_object.next(playlists)
def create_spotify_playlist(spotify_object, playlist_name, username):
return spotify_object.user_playlist_create(username, playlist_name)
def get_as_base64(url):
return base64.b64encode(requests.get(url).content).decode("utf-8")