Giter Site home page Giter Site logo

dakota's Introduction

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

dakota's People

Contributors

slevin48 avatar suryanewa avatar streamlit-badge-bot avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.