Skip to content

thomasravetto/Youtify---Final-Project-CS50

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Youtify

Description: My Final Project is called Youtify, it is a Flask based web application that allows users to transfer a Youtube playlist into Spotify, the main application build is contained in the app.py file while the functions that do the actual transfer are contained in two files called youtube.py and spotify.py, both contained in a directory called helpers. The first file, youtube.py, is used to first create a client library to interact with the Youtube API, then a function called initiate_youtube gets all the items in the playlist, for every item in the playlist the ID of every video is added to a list called videos_id with the append function. Subsequently a request is made to the API and in the response is contained the title of the video, a function called extract_title_and_artist extracts the title of the video and the name of the artist for every video in the playlist. Another function called get_spotify_uri queries the Spotify API and, from the response, it extracts the URI for every song, which is needed to add the songs to the playlist later, for the last step, every song detail (title, artist's name and URI) is added to a dictionary which is returned by the function. In the second file, spotify.py, a function called create_playlist queries the spotify API responsable of the creation of new playlists and returns a json response, the json file is passed into a function that gets the playlist id, another function called add_song_to_playlist queries the API responsable of the adding of the songs to the playlist. All of these functions are then imported in app.py.The app.py file is the one that creates the Flask application, the code at the beginning of the file configures Flask, the cookies and the SQL database, this file is formed by different app routes: The login route allows the user to login, it first prompt the user for username and password and then checks the SQL database, if the data is contained in the database then the user is redirected to the index page and the information are saved in the cookies, the app can not be used without being logged in, if the data does not correspond to the ones in the database the user is shown an error page. The index, about and news routes simply returns an html containing the respectively index, about and news page. The transfer route is the one responsable of the transfer of the songs, it contains a function that check the playlist URL and if there are no problems it uses all the function previously described and returns an html page that tells the user that the operation has been succesful. The logout route simply clears the session and redirect the user to the login page. The register route prompts the user for username, password and password confirmation, the function then checks if the username already exists in the database, if it does an error page is shown to the use, otherwise the function adds the username and the hashed password to the database and saves those information in the cookies. The website is created by using HTML and CSS, the buttons and inputs are connected to the main script thanks to Flask, a main layout.html file works as layout for the html navigation bar and footer (which are present in every html page) and all the other elements are build on that file using the Jinja template functions provided with Flask.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published