This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
def get_id(track_name: str, token: str) -> str: | |
headers = { | |
'Accept': 'application/json', | |
'Content-Type': 'application/json', | |
'Authorization': f'Bearer ' + token, | |
} | |
params = [ | |
('q', track_name), | |
('type', 'track'), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"access_token": some-string, | |
"token_type": "Bearer", | |
"expires_in": 3600, | |
"refresh_token": another-string, | |
"scope": "user-read-recently-played", | |
"expires_at": 1580462935} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print(token) | |
>> T2_wi8XsUpJrbD0BHQH4vX0BrSuYV0D88sVrQ_wMgApU9hP3g17MFIGBJwy6VJAB BwJKttS11Egej9RzGDuN4U4UUTLCECxVBWSrmrTT0iomaUtuapPkMgWa_uTjYijhnHI2czgPCZItzO4KAD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import spotipy.util as util | |
username = 'your-spotify-username' | |
client_id ='your-client-id' | |
client_secret = 'your-client-secret' | |
redirect_uri = 'http://localhost:7777/callback' | |
scope = 'user-read-recently-played' | |
token = util.prompt_for_user_token(username=username, | |
scope=scope, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ast | |
from typing import List | |
from os import listdir | |
def get_streamings(path: str = 'MyData') -> List[dict]: | |
files = ['MyData/' + x for x in listdir(path) | |
if x.split('.')[0][:-1] == 'StreamingHistory'] | |
all_streamings = [] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pip install spotipy | |
pip install requests | |
pip install pandas |
NewerOlder