tmp
This commit is contained in:
parent
366860a1ad
commit
22e19557d8
5 changed files with 162 additions and 7 deletions
|
|
@ -129,10 +129,36 @@ def get_user_data():
|
|||
return user_id
|
||||
|
||||
|
||||
def find_song(song_pattern):
|
||||
tracks = fetch(f"v1/search/?type=track&track=1&q={song_pattern}")['tracks']['items']
|
||||
return tracks
|
||||
|
||||
|
||||
def find_local_library():
|
||||
with open('prefetched/local_library.json', 'r') as file:
|
||||
local_library = json.load(file)
|
||||
|
||||
from tqdm import tqdm
|
||||
|
||||
pattern_map = {}
|
||||
|
||||
total = len(local_library)
|
||||
with tqdm(total=total, desc='Searching local songs on spotify') as pbar:
|
||||
found_tracks = {}
|
||||
for track, path in local_library.items():
|
||||
found_tracks[track] = find_song(track)
|
||||
pbar.update(1)
|
||||
|
||||
with open('prefetched/local_library_on_spotify.json', 'w') as file:
|
||||
json.dump(found_tracks, file, indent=2)
|
||||
|
||||
|
||||
def fetch_data():
|
||||
global token
|
||||
token = authenticate()
|
||||
|
||||
find_local_library()
|
||||
|
||||
user_id = get_user_data()
|
||||
|
||||
fetch_tracks(user_id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue