Skip to content

Commit

Permalink
Renamed the auth parameter of Spotify.__init__ to access_token
Browse files Browse the repository at this point in the history
…for better clarity.

Removed the `client_credentials_manager` and `oauth_manager` parameters because they are redundant.

Replaced the `set_auth` and `auth_manager` properties with standard attributes.

Removed the following deprecated methods from `Spotify`:
* `playlist_tracks`
* `user_playlist`
* `user_playlist_tracks`
* `user_playlist_change_details`
* `user_playlist_unfollow`
* `user_playlist_add_tracks`
* `user_playlist_replace_tracks`
* `user_playlist_reorder_tracks`
* `user_playlist_remove_all_occurrences_of_tracks`
* `user_playlist_remove_specific_occurrences_of_tracks`
* `user_playlist_follow_playlist`
* `user_playlist_is_following`

Removed the deprecated `as_dict` parameter from the `get_access_token` method of `SpotifyOAuth` and `SpotifyPKCE`.

Removed the deprecated `get_cached_token` and `_save_token_info` methods of `SpotifyOAuth` and `SpotifyPKCE`.

Removed `SpotifyImplicitGrant`.

Removed `prompt_for_user_token`.
  • Loading branch information
Peter-Schorn authored and dieser-niko committed Oct 8, 2024
1 parent 5c2f39d commit fb58b10
Show file tree
Hide file tree
Showing 34 changed files with 207 additions and 712 deletions.
2 changes: 1 addition & 1 deletion examples/artist_albums.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
logger = logging.getLogger('examples.artist_albums')
logging.basicConfig(level='INFO')

sp = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())
sp = spotipy.Spotify(auth_manager=SpotifyClientCredentials())


def get_args():
Expand Down
4 changes: 2 additions & 2 deletions examples/artist_discography.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ def main():


if __name__ == '__main__':
client_credentials_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
auth_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(auth_manager=auth_manager)
main()
4 changes: 2 additions & 2 deletions examples/artist_recommendations.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
logger = logging.getLogger('examples.artist_recommendations')
logging.basicConfig(level='INFO')

client_credentials_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
auth_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(auth_manager=auth_manager)


def get_args():
Expand Down
4 changes: 2 additions & 2 deletions examples/audio_analysis_for_track.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import sys


client_credentials_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
auth_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(auth_manager=auth_manager)

if len(sys.argv) > 1:
tid = sys.argv[1]
Expand Down
4 changes: 2 additions & 2 deletions examples/audio_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import sys


client_credentials_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
auth_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(auth_manager=auth_manager)
sp.trace = False

if len(sys.argv) > 1:
Expand Down
4 changes: 2 additions & 2 deletions examples/audio_features_for_track.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import sys


client_credentials_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
auth_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(auth_manager=auth_manager)
sp.trace = True

if len(sys.argv) > 1:
Expand Down
4 changes: 2 additions & 2 deletions examples/client_credentials_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import spotipy
from pprint import pprint

client_credentials_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
auth_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(auth_manager=auth_manager)

search_str = 'Muse'
result = sp.search(search_str)
Expand Down
10 changes: 0 additions & 10 deletions examples/multiple_accounts.py

This file was deleted.

2 changes: 1 addition & 1 deletion examples/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from time import sleep

scope = "user-read-playback-state,user-modify-playback-state"
sp = spotipy.Spotify(client_credentials_manager=SpotifyOAuth(scope=scope))
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=scope))

# Shows playing devices
res = sp.devices()
Expand Down
2 changes: 1 addition & 1 deletion examples/playlist_all_non_local_tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
PlaylistExample = '37i9dQZEVXbMDoHDwVN2tF'

# create spotipy client
sp = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())
sp = spotipy.Spotify(auth_manager=SpotifyClientCredentials())

# load the first 100 songs
tracks = []
Expand Down
2 changes: 1 addition & 1 deletion examples/playlist_tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import spotipy
from pprint import pprint

sp = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())
sp = spotipy.Spotify(auth_manager=SpotifyClientCredentials())

pl_id = 'spotify:playlist:5RIbzhG2QqdkaP24iXLnZX'
offset = 0
Expand Down
4 changes: 2 additions & 2 deletions examples/read_a_playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import spotipy
import json

client_credentials_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
auth_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(auth_manager=auth_manager)

playlist_id = 'spotify:user:spotifycharts:playlist:37i9dQZEVXbJiZcmkrIHGU'
results = sp.playlist(playlist_id)
Expand Down
2 changes: 1 addition & 1 deletion examples/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
else:
search_str = 'Radiohead'

sp = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())
sp = spotipy.Spotify(auth_manager=SpotifyClientCredentials())
result = sp.search(search_str)
pprint.pprint(result)
2 changes: 1 addition & 1 deletion examples/show_album.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
else:
urn = 'spotify:album:5yTx83u3qerZF7GRJu7eFk'

sp = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())
sp = spotipy.Spotify(auth_manager=SpotifyClientCredentials())
album = sp.album(urn)
pprint(album)
2 changes: 1 addition & 1 deletion examples/show_artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
else:
urn = 'spotify:artist:3jOstUTkEu2JkjvRdBA5Gu'

sp = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())
sp = spotipy.Spotify(auth_manager=SpotifyClientCredentials())

artist = sp.artist(urn)
pprint(artist)
2 changes: 1 addition & 1 deletion examples/show_artist_top_tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
else:
urn = 'spotify:artist:3jOstUTkEu2JkjvRdBA5Gu'

sp = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())
sp = spotipy.Spotify(auth_manager=SpotifyClientCredentials())
response = sp.artist_top_tracks(urn)

for track in response['tracks']:
Expand Down
4 changes: 2 additions & 2 deletions examples/show_related.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
else:
artist_name = 'weezer'

client_credentials_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
auth_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(auth_manager=auth_manager)
result = sp.search(q='artist:' + artist_name, type='artist')
try:
name = result['artists']['items'][0]['name']
Expand Down
2 changes: 1 addition & 1 deletion examples/show_track_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
else:
urn = 'spotify:track:0Svkvt5I79wficMFgaqEQJ'

sp = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())
sp = spotipy.Spotify(auth_manager=SpotifyClientCredentials())

track = sp.track(urn)
pprint(track)
4 changes: 2 additions & 2 deletions examples/show_tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
file = sys.stdin
tids = file.read().split()

client_credentials_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
auth_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(auth_manager=auth_manager)
for start in range(0, len(tids), max_tracks_per_call):
results = sp.tracks(tids[start: start + max_tracks_per_call])
for track in results['tracks']:
Expand Down
4 changes: 2 additions & 2 deletions examples/show_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
else:
username = 'plamere'

client_credentials_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
auth_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(auth_manager=auth_manager)
sp.trace = True
user = sp.user(username)
pprint.pprint(user)
4 changes: 2 additions & 2 deletions examples/simple_artist_albums.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

birdy_uri = 'spotify:artist:2WX2uTcsvV5OnS0inACecP'

client_credentials_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
auth_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(auth_manager=auth_manager)

results = sp.artist_albums(birdy_uri, album_type='album')
albums = results['items']
Expand Down
4 changes: 2 additions & 2 deletions examples/simple_artist_top_tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

lz_uri = 'spotify:artist:36QJpDe2go2KgaRleHCDTp'

client_credentials_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
auth_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(auth_manager=auth_manager)

results = sp.artist_top_tracks(lz_uri)

Expand Down
4 changes: 2 additions & 2 deletions examples/simple_search_artist.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from spotipy.oauth2 import SpotifyClientCredentials
import spotipy

client_credentials_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
auth_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(auth_manager=auth_manager)

results = sp.search(q='weezer', limit=20)
for i, t in enumerate(results['tracks']['items']):
Expand Down
2 changes: 1 addition & 1 deletion examples/simple_search_artist_image_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from spotipy.oauth2 import SpotifyClientCredentials
import spotipy

sp = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())
sp = spotipy.Spotify(auth_manager=SpotifyClientCredentials())

if len(sys.argv) > 1:
name = ' '.join(sys.argv[1:])
Expand Down
4 changes: 2 additions & 2 deletions examples/title_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
usage: python title_chain.py [song name]
'''

client_credentials_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
auth_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(auth_manager=auth_manager)


skiplist = {'dm', 'remix'}
Expand Down
4 changes: 2 additions & 2 deletions examples/tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import spotipy
import sys

client_credentials_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
auth_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(auth_manager=auth_manager)

if len(sys.argv) > 1:
artist_name = ' '.join(sys.argv[1:])
Expand Down
4 changes: 2 additions & 2 deletions examples/user_public_playlists.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import spotipy
from spotipy.oauth2 import SpotifyClientCredentials

client_credentials_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
auth_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(auth_manager=auth_manager)

user = 'spotify'

Expand Down
Loading

0 comments on commit fb58b10

Please sign in to comment.