mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-06-19 09:13:53 +00:00
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`.
37 lines
911 B
Python
37 lines
911 B
Python
|
|
# shows acoustic features for tracks for the given artist
|
|
|
|
from __future__ import print_function # (at top of module)
|
|
from spotipy.oauth2 import SpotifyClientCredentials
|
|
import json
|
|
import spotipy
|
|
import time
|
|
import sys
|
|
|
|
|
|
auth_manager = SpotifyClientCredentials()
|
|
sp = spotipy.Spotify(auth_manager=auth_manager)
|
|
sp.trace = False
|
|
|
|
if len(sys.argv) > 1:
|
|
artist_name = ' '.join(sys.argv[1:])
|
|
else:
|
|
artist_name = 'weezer'
|
|
|
|
results = sp.search(q=artist_name, limit=50)
|
|
tids = []
|
|
for i, t in enumerate(results['tracks']['items']):
|
|
print(' ', i, t['name'])
|
|
tids.append(t['uri'])
|
|
|
|
start = time.time()
|
|
features = sp.audio_features(tids)
|
|
delta = time.time() - start
|
|
for feature in features:
|
|
print(json.dumps(feature, indent=4))
|
|
print()
|
|
analysis = sp._get(feature['analysis_url'])
|
|
print(json.dumps(analysis, indent=4))
|
|
print()
|
|
print("features retrieved in %.2f seconds" % (delta,))
|