Skip to content

suryanewa/dakota

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dakota 🎵Open in Streamlit

sergent-pepper

Started out as a Spotify music recommendation app

NEW: Added features from music-generator 🎹

Content:

  1. Parse Streaming History
  2. Music Taste Analysis
  3. Get Recommendation
  4. Spotify API

1. Parse Streaming History

Streaming history can be retrieved from the Spotify profile as JSON, or through the spotipy functions current_user_recently_played or current_user_saved_tracks

with open("recently_played_20210306.json","r"as f:
    results = json.load(f)

tracks = []
for idxitem in enumerate(results['items']):
    track = item['track']
    tracks.append([idxtrack['artists'][0]['name'], track['name']])

trackDict = {"id":[], "artist":[],"name":[]}
for idxitem in enumerate(results['items']):
    track = item['track']
    trackDict["id"].append(idx)
    trackDict["artist"].append(track['artists'][0]['name'])
    trackDict["name"].append(track['name'])
    
import pandas as pd
trackDf = pd.DataFrame.from_dict(trackDict)

2. Music Taste Analysis

Analysis of features to produce a polar plot

feature-plot

import spotifyAPI
from secret import clientId,clientSecret
token  = spotifyAPI.get_token(clientId,clientSecret)
lucy_id = spotifyAPI.get_track_id2('Lucy in the Sky'tokenartist = 'The Beatles')

url = "https://open.spotify.com/track/"+lucy_id
import webbrowser
webbrowser.open(url)

import pandas as pd

lucy_features = spotifyAPI.get_features(lucy_id,token)
df = pd.DataFrame(lucy_featuresindex=[0])
df_features = df.loc[: ,['acousticness''danceability''energy''instrumentalness''liveness''speechiness''valence']]

spotifyAPI.feature_plot(df_features)

3. Get Recommendation

json_response = spotifyAPI.get_track_reco(lucy_id,token)
uris =[]
for i in json_response['tracks']:
            uris.append(i)
            print(f"\"{i['name']}\" by {i['artists'][0]['name']}")

4. Spotify API

This notebook leverages the Spotipy module to access the Spotify API:

https://spotipy.readthedocs.io/

  • Basic auth
    • Search & Get track
    • Get features
    • Get recommendations
  • Spotipy auth
    • Artist albums
    • Artist top tracks
    • Advanced Search (help)
    • Current user
  • Access Scopes (detailed later)
    • Saved Tracks
    • Saved Albums (doc)
    • Playlist (doc)
    • Recently played (doc) )
    • Advanced recommendations based on seeds (doc)

spotifyNoneUserData

Scopes

Resources

About

Music App based on Spotify API and Streamlit framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 98.7%
  • Python 1.3%