-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
41 lines (34 loc) · 1.08 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import sys
import os
import numpy as np
import pandas as pd
import spotipy
import spotipy.util as util
from spotipy.oauth2 import SpotifyClientCredentials
from spotipy.oauth2 import SpotifyOAuth
import spotipy.oauth2 as oauth2
from recommend_tracks import RecommendTracks
import streamlit as st
import streamlit.components.v1 as components
import random
import time
from dotenv import load_dotenv
load_dotenv()
SPOTIPY_CLIENT_ID = os.environ.get("SPOTIPY_CLIENT_ID")
SPOTIPY_CLIENT_SECRET = os.environ.get("SPOTIPY_CLIENT_SECRET")
REDIRECT_URI = 'http://localhost:8500/'
SCOPE = 'user-top-read'
SHOW_DIALOG = True
st.title('Spotify Recommendation App')
'''
Powered by _NLP_.
'''
st.markdown('#')
p = st.button('Go')
if p:
recommend = RecommendTracks(SPOTIPY_CLIENT_ID, SPOTIPY_CLIENT_SECRET, REDIRECT_URI, SCOPE, SHOW_DIALOG)
track_ids = recommend.recommended_tracks()
st.balloons()
st.write('Our personialised recommendations for you...')
for track in random.sample(track_ids, 10):
components.iframe(f"https://open.spotify.com/embed/track/{track}", width=600, height=80)