def Execute(username=None): print("Executing login script") username = request.args["username"] username_detected = False if (username): username_detected = True if (username_detected): print("debug: " + username) print("username detected") # Delete user id from csv to maintain clean code clear_username_csv() write_username_to_csv(username) print("Saved username to CSV") print("Generating Spotify Token") authenication_token(username) return redirect("/activity") else: return render_template("no_token.html") app.run(debug=True)
def Execute(username=None): print("Executing login script") username = request.args["username"] username_detected = False if (username): username_detected = True if (username_detected): print("debug: " + username) print("username detected") # delete user id from csv to maintain clean code clear_username_csv() write_username_to_csv(username) print("Saved username to CSV") #auth_url = authenication_token(username).get_authorize_url()#> 'https://accounts.spotify.com/authorize?client_id=_____&response_type=code&redirect_uri=________&scope=playlist-modify-private+playlist-read-private' #return redirect(auth_url) print("Generating Spotify Token") authenication_token(username) return redirect("/activity") else: return render_template("no_token.html") app.run(debug=True)
def activity(): print("Visited Activity Page") # TODO: Build an if statement to read if a playlist called "Favorite Podcasts" already exists username = read_username_from_csv() token = authenication_token(username) print("Building you a Favorite Podcasts playlist") podcast_playlist_generator(username, token) print( "Adding new episodes for followed podcasts to Favorite Podcasts playlist" ) podcast_followed_new_eps(username, token) return render_template("activity.html")
def activity(): print("Visited Activity Page") username = read_username_from_csv() token = authenication_token(username) print("Building you a Podify playlist") podcast_playlist_generator(username, token) print("Adding new episodes for followed podcasts to Podify playlist") podcast_followed_new_eps(username, token) print("Emailing you a summary") send_episode_email(username, token) return render_template("activity.html")
from dotenv import load_dotenv from sendgrid import SendGridAPIClient import spotipy import spotipy.util as util from spotipy.oauth2 import SpotifyClientCredentials from sendgrid.helpers.mail import Mail #from functions_podcast_check import new_ep_descriptions_titles # import sys # sys.path.insert(0, Spotify-Podcast-Automation/web_app/spotify_auth.py) # from spotify_auth import authenication_token - TODO UPDATE FOR FILE BELOW load_dotenv() from web_app.spotify_auth import authenication_token token = authenication_token(username) sp = spotipy.Spotify(auth=token) #MUST REMOVE DUPLICATION # scopes = 'user-library-read playlist-modify-public' # username = os.environ.get("SPOTIFY_USER_NAME") # client_id_saved = os.environ.get("SPOTIFY_CLIENT_ID") # client_secret_saved = os.environ.get("SPOTIFY_CLIENT_SECRET") # redirect_uri_saved = os.environ.get("SPOTIFY_REDIRECT_URI") # token = util.prompt_for_user_token(username, # scopes, # client_id= client_id_saved, # client_secret= client_secret_saved, # redirect_uri= redirect_uri_saved)