Spaces:
Sleeping
Sleeping
spotify integration
Browse files- app.py +24 -2
- requirements.txt +2 -0
app.py
CHANGED
|
@@ -1,4 +1,26 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import spotipy
|
| 3 |
+
from spotipy.oauth2 import SpotifyClientCredentials
|
| 4 |
|
| 5 |
+
SPOTIFY_SCOPE = "user-read-recently-played"
|
| 6 |
+
REDIRECT_URI = "https://huggingface.co/spaces/atepper/tracklist-analysis"
|
| 7 |
+
|
| 8 |
+
sp_oauth = SpotifyOAuth(client_id=st.secrets["SPOTIFY_CLIENT_ID"],
|
| 9 |
+
client_secret=st.secrets["SPOTIFY_CLIENT_SECRET"],
|
| 10 |
+
redirect_uri=REDIRECT_URI,
|
| 11 |
+
scope=SPOTIFY_SCOPE)
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=scope))
|
| 16 |
+
|
| 17 |
+
results = sp.current_user_recently_played()
|
| 18 |
+
for idx, item in enumerate(results['items']):
|
| 19 |
+
track = item['track']
|
| 20 |
+
print(idx, track['artists'][0]['name'], " – ", track['name'])
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
# x = st.slider('Select a value')
|
| 26 |
+
# st.write(x, 'squarfed is', x * x)
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
spotipy
|