Abdelrhman-Elruby commited on
Commit
1274d62
1 Parent(s): b996912

modified: model.py

Browse files
Files changed (1) hide show
  1. model.py +9 -4
model.py CHANGED
@@ -7,6 +7,7 @@ from sklearn.feature_extraction.text import TfidfVectorizer
7
  from sklearn.metrics.pairwise import cosine_similarity
8
  from sklearn.preprocessing import MinMaxScaler
9
  import pickle
 
10
 
11
  def playlist_model(url, model, max_gen=3, same_art=5):
12
  log = []
@@ -14,10 +15,14 @@ def playlist_model(url, model, max_gen=3, same_art=5):
14
  try:
15
  log.append('Start logging')
16
  uri = url.split('/')[-1].split('?')[0]
17
- stream = open("Spotify/Spotify.yaml")
18
- spotify_details = yaml.safe_load(stream)
19
- auth_manager = SpotifyClientCredentials(
20
- client_id=spotify_details['Client_id'], client_secret=spotify_details['client_secret'])
 
 
 
 
21
  sp = spotipy.client.Spotify(auth_manager=auth_manager)
22
 
23
  if model == 'Spotify Model':
 
7
  from sklearn.metrics.pairwise import cosine_similarity
8
  from sklearn.preprocessing import MinMaxScaler
9
  import pickle
10
+ import streamlit as st
11
 
12
  def playlist_model(url, model, max_gen=3, same_art=5):
13
  log = []
 
15
  try:
16
  log.append('Start logging')
17
  uri = url.split('/')[-1].split('?')[0]
18
+ try:
19
+ stream = open("Spotify/Spotify.yaml")
20
+ spotify_details = yaml.safe_load(stream)
21
+ auth_manager = SpotifyClientCredentials(client_id=spotify_details['Client_id'], client_secret=spotify_details['client_secret'])
22
+ except:
23
+ Client_id=st.secrets['Client ID']
24
+ client_secret=st.secrets['Client secret']
25
+ auth_manager = SpotifyClientCredentials(client_id=Client_id, client_secret=client_secret)
26
  sp = spotipy.client.Spotify(auth_manager=auth_manager)
27
 
28
  if model == 'Spotify Model':