Converts a text file of songs to a playlist on your Spotify account.

Overview

Playlist Converter

Python Tests License: MIT

Convert a text file of songs to a playlist on your Spotify account. Create your playlists faster instead of manually searching for songs.

Demo

Recorded using ScreenToGif.

Table of Contents

How It Works

  • This application reads the contents of every text file in a directory on your computer
  • You must provide details of how your files are structured in a configuration file
  • Getting a temporary access token from Spotify authorizes this app to access/change your account data
  • Using the Python requests library, this application sends the data to Spotify's web API to create the playlist

Credits

Getting Started

Before running this project locally, make sure you meet/install the prerequisites listed below. After meeting the prerequisites, follow the instructions in the Installation section.

Prerequisites

Spotify Account

If you don't already have a Spotify account, go to their sign up page and create one.

Python 3.6+

You must have Python version 3.6 or greater installed on your computer.

Once you've installed Python, open Git Bash or your preferred CLI on Windows, or Terminal on Linux/MAC. Run this command to verify you have the right version of Python:

python --version
# Python 3.*

Installation

1. Clone this repository on your machine.

git clone https://github.com/pa-aggarwal/playlist-converter.git

2. Create a python virtual environment, activate it, and install the packages in the requirements.txt file.

# Navigate to directory
cd playlist-converter

# Create virtual environment 'venv'
python -m venv venv

# Activate virtual environment
. venv/Scripts/activate

# Install packages from requirements.txt
python -m pip install -r requirements.txt

3. You must create your own configuration file called config.ini in the config directory, by copying the template config template.ini file.

# Copy the template config file
cp config/template.ini config/config.ini

Open the config.ini file in your preferred text editor and change the values of the config keys to match your file setup. See the Configuration section for what these keys are and how to fill them in.

4. Visit https://developer.spotify.com/console/get-search-item/ to get a temporary access token from Spotify. Check mark the following scopes to authenticate this application:

  • user-library-read
  • playlist-modify-public
  • playlist-modify-private

Copy and paste the access token into your configuration file under the access_token option.

Note: Spotify's access tokens expire after 1 hour, so you'll need to repeat this step if you're using this application again at a later time.

Configuration

What are the config keys and how do I fill them in?

  • directory_path: Absolute path to the directory containing the text file(s) you want to convert
  • data_order: track artist or artist track based on how songs are listed in your files.
  • data_delimiter: The characters separating track name from artist name(s), preferrably at least 3 chars long e.g. ---, ###
  • user_id: Your username on your spotify account
  • access_token: Token value from step 4 of Installation

Here is an example file setup (location and contents), along with a configuration file:

$ pwd
C:\Users\user\Desktop\playlists

$ ls
playlist-01.txt playlist-02.txt

$ cat playlist-01.txt
Name: My Playlist
3005---Childish Gambino
See You Again---Tyler, The Creator, Kali Uchis
...

config.ini

[FILE_INFO]
directory_path = C:\Users\user\Desktop\playlists
data_order = track artist
data_delimiter = ---

[API]
user_id = priyaaggarwal
access_token = long-key-from-spotify

Usage

Make sure you've completed steps from the Installation section before running this application. This includes making your configuration file and putting text files to convert in their own directory.

In the cloned repository with the venv activated, run this command to create your playlists:

python -m playlist_converter.app

This may take a couple of minutes depending on how large your files are.

You may see an error message if there was an issue trying to convert your files, like one of the following:

  • Missing configuration file or config keys
  • Invalid directory path
  • No text files found to convert
  • HTTP error from invalid access token or something else

If you received no errors, then open your spotify account to see your new playlists.

To check if tests are passing, run this command:

python -m unittest discover -s tests

Contributing

Contributions and feedback for improvements as well as new features are welcome!

  1. Fork this repository.
  2. Create a new branch for your contribution (git checkout -b new-feature).
  3. Add your contribution, and write tests if needed.
  4. Ensure the test suite passes.
  5. Commit your changes to the branch (git commit -m "My new feature does X").
  6. Push to the branch (git push origin new-feature).
  7. Open a pull request.

License

Distributed under the MIT License. See LICENSE.txt for more information.

You might also like...
Spotify playlist anonymizer.

Spotify heavily personalizes auto-generated playlists like Song Radio based on the music you've listened to in the past. But sometimes you want to listen to Song Radio precisely to hear some fresh songs outside of your habitual listening realm!

An interactive App to play with Spotify data, both from the Spotify Web API and from CSV datasets.

An interactive App to play with Spotify data, both from the Spotify Web API and from CSV datasets.

Spotify Top Lists - get the current top lists of a user from the Spotify API and display them in a Flask app
Spotify Top Lists - get the current top lists of a user from the Spotify API and display them in a Flask app

Spotify Top Lists This is a simple script that will get the current top lists of a user from the Spotify API and display them in a Flask app. Requirem

A script to generate the m3u playlist containing direct streamable file (.mpd or MPEG-DASH or DASH) based on the channels that the user has subscribed on the Tata Sky portal. You just have to login using your password or otp that's it . Python based Spotify account generator.
Python based Spotify account generator.

Spotify Account Generator Python based Spotify account generator. Installation Download the latest release, open command prompt in the folder, run pip

AHA is an incident management & communication framework to provide real-time alert customers when there are active AWS event(s). For customers with AWS Organizations, customers can get aggregated active account level events of all the accounts in the Organization. Customers not using AWS Organizations still benefit alerting at the account level. Check and write all account info + Check nitro on account
Check and write all account info + Check nitro on account

Discord-Token-Checker Check and write all account info + Check nitro on account Also check https://github.com/GuFFy12/Discord-Token-Parser (Parse disc

Unauthenticated enumeration of services, roles, and users in an AWS account or in every AWS account in existence.

Quiet Riot ๐ŸŽถ C'mon, Feel The Noise ๐ŸŽถ An enumeration tool for scalable, unauthenticated validation of AWS principals; including AWS Acccount IDs, roo

A discord account nuker with lots of tools that will destroy a discord account
A discord account nuker with lots of tools that will destroy a discord account

A discord account nuker with lots of tools that will destroy a discord account (token destroyer... and much more).

Comments
  • Failed due to an HTTP error

    Failed due to an HTTP error

    Thanks for creating this library! I just wanted to give you some feedback.

    Failed due to an HTTP error is a general error and I had to dive into the code to figure out. For example it is generated when the user ID is incorrect, token timed out, or insufficient permission. In my case playlist text file exceeds more than 100 songs which is confirmed here:

    • https://github.com/pa-aggarwal/playlist-converter/blob/e782cb2b9473c791265657c65338cc12c856b91f/playlist_converter/client.py#L68
    • API documentation: add-tracks-to-playlist

    A suggestion to document this limitation in the README.md, or add support to add songs in chunks of 100.

    I found a faster workaround: Simply by printing the ID's on the console, then copy and paste into an existing playlist in Spotify with CTRL+V (format like spotify:track:5txoZyuAmtCfmDjUCEphW with each track on a newline). This works on Windows, not on Linux.

    opened by Erriez 0
Owner
Priya Aggarwal
CS Student at Ryerson University.
Priya Aggarwal
Converts between Spotify's new lyrics (and their proprietary format) to an LRC file for local playback.

spotify-lyrics-to-lrc Converts between Spotify's new lyrics (and their proprietary format) to an LRC file for local playback. How to use: Open Spotify

~noah~ 6 Nov 19, 2022
A GUI Application that creates a Spotify Playlist from any year in the past, by just entering your preferred date

A GUI Application that creates a Spotify Playlist from any year in the past, by just entering your preferred date

David .K. Danso 1 Jan 17, 2022
An simple python script for remove rockstar account for fivem, very useful for cheating or change account for unban from an server, remember change steam account.

This tool is used for be unbanned from servers, u need disconnect the discord, use other steam account and uninstall xbox for be unbanned 100%, it only work for unban in server, not global

MiguDEV 4 Oct 10, 2022
Melissa Songs is a telegram bot to easily find songs sending music snippets and search tracks ๐Ÿ’ƒ๐Ÿฝ๐ŸŽต

Find songs on Telegram, like on Shazam... ?? Open on telegram ยท Report Bug ยท Request Feature โฌ‡๏ธ Installation To get a local copy installed and working

Joaquim Roque 21 Nov 10, 2022
You can share your Chegg account for answers using this bot with your friends without getting your account blocked/flagged

Chegg-Answer-Bot You can share your Chegg account for answers using this bot with your friends without getting your account blocked/flagged Reuirement

Ammey Saini 27 Dec 24, 2022
A really easy way to display your spotify listening status on spotify.

Spotify playing README A really easy way to display your spotify listening status on READMEs and Websites too! Demo Here's the embed from the site. Cu

Sunrit Jana 21 Nov 6, 2022
A Python script to create customised Spotify playlists using the JSON, Spotipy Library and Spotify Web API, based on seed tracks in your history.

A Python script to create customised Spotify playlists using the JSON, Spotipy Library and Spotify Web API, based on seed tracks in your history.

Youngseo Park 1 Feb 1, 2022
JAKYM, Just Another Konsole YouTube-Music. A command line based Youtube music player written in Python with spotify and youtube playlist support

Just Another Konsole YouTube-Music Overview I wanted to create this application so that I could use the command line to play music easily. I often pla

Mayank Jha 73 Jan 1, 2023
A Python script to update Spotify Playlist data every 5 minutes.

Spotify Playlist Updater A Python script to update Spotify Playlist data every 5 minutes. Description An automatic playlist updater using Spotify API

null 6 Nov 24, 2022
Web app for spotify playlist management with last.fm integration

Music Tools Set of utility tools for Spotify and Last.fm. Built on my other libraries for Spotify (spotframework), Last.fm (fmframework) and interfaci

andy 3 Dec 14, 2022