Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -42,6 +42,7 @@ def extract_track_id_from_url(url):
|
|
| 42 |
|
| 43 |
def app():
|
| 44 |
|
|
|
|
| 45 |
# Step 1: User Authorization
|
| 46 |
if st.session_state.get('code') is None or ('access_token' not in st.session_state or st.session_state['access_token'] is None):
|
| 47 |
auth_params = {
|
|
@@ -52,10 +53,7 @@ def app():
|
|
| 52 |
}
|
| 53 |
st.write('Please log in to Spotify')
|
| 54 |
st.markdown(f"[Log In]({AUTH_URL}?{urlencode(auth_params)})", unsafe_allow_html=True)
|
| 55 |
-
|
| 56 |
-
# Step 2: Request Access Token
|
| 57 |
-
if 'access_token' not in st.session_state or (st.session_state['access_token'] is None):
|
| 58 |
-
auth_code = st.session_state['code']
|
| 59 |
|
| 60 |
token_data = {
|
| 61 |
'grant_type': 'authorization_code',
|
|
@@ -67,7 +65,7 @@ def app():
|
|
| 67 |
token_r = requests.post(TOKEN_URL, data=token_data)
|
| 68 |
token_response = token_r.json()
|
| 69 |
st.session_state['access_token'] = token_response.get('access_token')
|
| 70 |
-
|
| 71 |
if 'access_token' in st.session_state:
|
| 72 |
st.write("Enter a Spotify Track URL or URI to get its audio features.")
|
| 73 |
track_input = st.text_input("Spotify Track URL/URI", "")
|
|
|
|
| 42 |
|
| 43 |
def app():
|
| 44 |
|
| 45 |
+
|
| 46 |
# Step 1: User Authorization
|
| 47 |
if st.session_state.get('code') is None or ('access_token' not in st.session_state or st.session_state['access_token'] is None):
|
| 48 |
auth_params = {
|
|
|
|
| 53 |
}
|
| 54 |
st.write('Please log in to Spotify')
|
| 55 |
st.markdown(f"[Log In]({AUTH_URL}?{urlencode(auth_params)})", unsafe_allow_html=True)
|
| 56 |
+
auth_code = st.session_state['code']
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
token_data = {
|
| 59 |
'grant_type': 'authorization_code',
|
|
|
|
| 65 |
token_r = requests.post(TOKEN_URL, data=token_data)
|
| 66 |
token_response = token_r.json()
|
| 67 |
st.session_state['access_token'] = token_response.get('access_token')
|
| 68 |
+
else:#
|
| 69 |
if 'access_token' in st.session_state:
|
| 70 |
st.write("Enter a Spotify Track URL or URI to get its audio features.")
|
| 71 |
track_input = st.text_input("Spotify Track URL/URI", "")
|