mirror of
https://github.com/Xevion/spotify-explicit.git
synced 2025-12-09 00:08:33 -06:00
pull.py abstraction
This commit is contained in:
45
pull.py
45
pull.py
@@ -4,22 +4,31 @@ import pprint
|
|||||||
import spotipy
|
import spotipy
|
||||||
import spotipy.util as util
|
import spotipy.util as util
|
||||||
|
|
||||||
# Get Authorization
|
def main():
|
||||||
token = util.prompt_for_user_token(
|
# Get Authorization
|
||||||
username=auth.username,
|
print('Authorizing with Spotify')
|
||||||
scope=auth.scope,
|
token = util.prompt_for_user_token(
|
||||||
client_id=auth.client_id,
|
username=auth.username,
|
||||||
client_secret=auth.client_secret,
|
scope=auth.scope,
|
||||||
redirect_uri=auth.redirect_uri
|
client_id=auth.client_id,
|
||||||
)
|
client_secret=auth.client_secret,
|
||||||
sp = spotipy.Spotify(auth=token)
|
redirect_uri=auth.redirect_uri
|
||||||
saved_response = sp.current_user_saved_tracks(limit=50, offset=100000)
|
)
|
||||||
# saved_response = json.load(open('saved_tracks.json', 'r'))
|
sp = spotipy.Spotify(auth=token)
|
||||||
json.dump(saved_response, open('saved_tracks.json', 'w+'))
|
print('Authorized')
|
||||||
pprint.pprint(saved_response)
|
|
||||||
# for track in saved_response['items']:
|
|
||||||
# print('{} by {}'.format(
|
|
||||||
# track['track']['name'],
|
|
||||||
# ' & '.join(artist['name'] for artist in track['track']['artists'])
|
|
||||||
# ))
|
|
||||||
|
|
||||||
|
curoffset = 0
|
||||||
|
curlimit = 50
|
||||||
|
while True:
|
||||||
|
|
||||||
|
# Start grabbing tracks (long running)
|
||||||
|
saved_response = sp.current_user_saved_tracks(limit=50, offset=850)
|
||||||
|
# saved_response = json.load(open('saved_tracks.json', 'r'))
|
||||||
|
# json.dump(saved_response, open('saved_tracks.json', 'w+'))
|
||||||
|
pprint.pprint(saved_response)
|
||||||
|
|
||||||
|
# for track in saved_response['items']:
|
||||||
|
# print('{} by {}'.format(
|
||||||
|
# track['track']['name'],
|
||||||
|
# ' & '.join(artist['name'] for artist in track['track']['artists'])
|
||||||
|
# ))
|
||||||
Reference in New Issue
Block a user