mirror of
https://github.com/Xevion/spotify-explicit.git
synced 2025-12-06 01:16:25 -06:00
file saving additionsn
This commit is contained in:
8
process.py
Normal file
8
process.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import json
|
||||||
|
|
||||||
|
saved_response = json.load(open('saved_tracks.json', 'r'))
|
||||||
|
for track in saved_response['items']:
|
||||||
|
print('{} by {}'.format(
|
||||||
|
track['track']['name'],
|
||||||
|
' & '.join(artist['name'] for artist in track['track']['artists'])
|
||||||
|
))
|
||||||
26
pull.py
26
pull.py
@@ -1,3 +1,5 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
import auth
|
import auth
|
||||||
import json
|
import json
|
||||||
import pprint
|
import pprint
|
||||||
@@ -17,18 +19,14 @@ def main():
|
|||||||
sp = spotipy.Spotify(auth=token)
|
sp = spotipy.Spotify(auth=token)
|
||||||
print('Authorized')
|
print('Authorized')
|
||||||
|
|
||||||
curoffset = 0
|
curoffset, curlimit = 0, 50
|
||||||
curlimit = 50
|
|
||||||
while True:
|
|
||||||
|
|
||||||
# Start grabbing tracks (long running)
|
# Start grabbing tracks (long running)
|
||||||
saved_response = sp.current_user_saved_tracks(limit=50, offset=850)
|
while True:
|
||||||
# saved_response = json.load(open('saved_tracks.json', 'r'))
|
response = sp.current_user_saved_tracks(limit=curlimit, offset=curoffset)
|
||||||
# json.dump(saved_response, open('saved_tracks.json', 'w+'))
|
if response is not None:
|
||||||
pprint.pprint(saved_response)
|
print('Received ')
|
||||||
|
filename = f'saved-tracks-{curoffset}-{curoffset + curlimit}.json'
|
||||||
# for track in saved_response['items']:
|
filepath = os.path.join(root, 'tracks', filename)
|
||||||
# print('{} by {}'.format(
|
with open(filepath, 'w+') as file:
|
||||||
# track['track']['name'],
|
json.dump(response, file)
|
||||||
# ' & '.join(artist['name'] for artist in track['track']['artists'])
|
curoffset += curlimit
|
||||||
# ))
|
|
||||||
|
|||||||
Reference in New Issue
Block a user