Skip to content

Instantly share code, notes, and snippets.

View healthiq-treyHolterman's full-sized avatar

healthiq-treyHolterman

View GitHub Profile
@healthiq-treyHolterman
healthiq-treyHolterman / script.py
Last active August 26, 2019 19:56
Full boar with prompting and searching
def findTopSong(sp, artist, allTargetSongs):
allTopTracks = sp.artist_top_tracks(artist['id'] , country='US')['tracks']
if len(allTopTracks) <= 3: return
singleTopTrack = allTopTracks[0] # Grabs top Track
allTargetSongs.append(singleTopTrack)
# Takes sp for auth, the current artist being looked at, the current threshold for popularity
# and how far removed (linkLevel) the current artist is from the original favorite artists.
# Ultimately the goal of this function is to take someone's top 10 favorite artists and return
# underground artists with on especially popular song relative to the average of their top 5 songs.
@healthiq-treyHolterman
healthiq-treyHolterman / script.py
Created August 26, 2019 17:57
Starting to use sp client
import spotipy
import spotipy.util as util
if __name__ == '__main__':
username = "<Your Username (or user number) here>"
token = util.prompt_for_user_token(username,scope = 'user-top-read',client_id='<Your client ID>',client_secret='<Your client Secret>',redirect_uri='http://localhost/')
if token:
sp = spotipy.Spotify(auth=token)
myTopArtists = sp.current_user_top_artists(5, 0, 'short_term')
@healthiq-treyHolterman
healthiq-treyHolterman / script.py
Last active August 26, 2019 19:55
Spotipy Main Setup
import spotipy
import spotipy.util as util
if __name__ == '__main__':
username = "<Your Username (or user number) here>"
token = util.prompt_for_user_token(username,scope = 'user-top-read',client_id='<Your client ID>',client_secret='<Your client Secret>',redirect_uri='http://localhost/')
if token:
print("Cool we authenticated")