Coder Social home page Coder Social logo

paulinakhew / playlist_generator Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 1.67 MB

🎵 Flask app that parses a list of songs and creates a new playlist on Spotify using OAuth2 and an implicit grant flow. Deployed on Heroku.

Home Page: https://create-spotify-playlist.herokuapp.com/

License: GNU General Public License v3.0

Python 52.05% HTML 47.77% Procfile 0.18%
spotify playlist-generator spotify-playlist python heroku flask implicit-flow oauth2

playlist_generator's Introduction

playlist_generator

This is a application that generates a Spotify playlist from text, deployed on Heroku.

How to Use

Walkthrough of the playlist generator app can be found in the following Youtube video: YouTube thumbnail

Tools and APIs

Nice to know

  • Learn about OAuth for free here. I've created a repo that implements a simple OAuth script using python and the GitHub API here.

Local Dev Setup

  1. Install dependencies:
pip3 install -r requirements.txt
  1. Create an .env file
  • copy the .env.template file into an .env file using the following command:
cp .env.template .env

Your .env file should be formatted as follows:

CLIENT_ID=
CLIENT_SECRET=
REDIRECT_URI=http://127.0.0.1:5000/callback
SECRET_KEY= #Use output of python -c 'import os; print(os.urandom(16))'
  • update the SECRET_KEY by pasting the output of
python -c 'import os; print(os.urandom(16))'
  1. Collect your Spotify client ID and client secret from Spotify and add it to the .env file
  • to get both the client ID and the client secret, you have to go to the Spotify Developer Dashboard. Create an application and then copy the client ID and client secret into the respective environment variables
  1. Run the create_playlist.py file
python3 flask_app.py

How it works

First page The first page has a button that triggers the Spotify authentication flow.

Second page If you're not logged in on the web browser, you'll be taken to the second page where you can log in through the method of your choice.

Third page Once you've been logged in, you'll need to copy the two fields at the top and paste them into the first two textboxes. Once that has been complete, you can paste a list of songs into the large textbox and paste the delimiters.

Example

List of Songs

The List of songs field would be populated by a list of songs. The following example is taken from a comment on a YouTube video.

0:02 - Butterfly by UMI
2:43 - Chateau by Djo
7:16 - Six AM by Inner Wave
9:23 - In a Mood by TheSecondSex
13:31 - Lavender Kiss by The Licks
17:35 - Gimme Love by Joji
21:11 - Sink Into the Floor by Feng Suave
25:49 - Somebody Else by The 1975
31:39 - Only in my Dreams by The Marías
34:30 - Love it if We Made it by The 1975
38:43 - Freakin' Out On the Interstate by Briston Maroney
42:56 - Midnight Blue by Puma Blue
47:36 - Loverboy by The Marías
51:26 - Soft Porn by Puma Blue

As you can see, the YouTube timestamps have been included. To get rid of these, you would fill out the first delimiter field.

First delimiter

This field is where you would place the symbol/text that separates the timestamps from the rest of the information. In this case, it is a dash.

-

The code will remove everything located up until the -, leaving the text on the right side.

Second delimiter

This field is where you would place the symbol/text that separates the artist name from the song name.

by

The code will separate the artist and songs by the second delimiter (which is by in this case). It will use the Spotify API to search up each song by artist and song name and add it to a public playlist.

Playlist name (optional)

If you want to create a custom playlist name, you would add that here. Otherwise, the default is New Playlist

Songs to listen to on a late night drive

Playlist description (optional)

If you want to add a custom playlist description, you would add that here. Otherwise, the default is New playlist for songs using https://create-spotify-playlist.herokuapp.com/

Playlist generated from a YouTube video

order: artist -> song

Check off this checkbox if the artist is placed before the song names. Otherwise, leave it blank.

Success!!

If the playlist was successfully created, you will see a green alert box pop up with the response from Spotify. This will contain a snapshot_id. Your new playlist should appear immediately on Spotify. Success

playlist_generator's People

Contributors

paulinakhew avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

playlist_generator's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.