SkillAgentSearch skills...

Spotgen

Spotify Playlist Generator

Install / Use

/learn @epsil/Spotgen
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

spotgen

nodei.co

npm Build Status License: MIT

A tool for generating Spotify playlists programmatically. Convert websites to Spotify playlists, incorporate Last.fm listener data, and employ smart algorithms to reorder the tracks.

Web demo: https://epsil.github.io/spotgen/

Installation

Install Node and fetch the package with npm:

npm install -g spotgen

Note that on some systems, it might be necessary to prepend the npm command with sudo.

The generator can now be invoked from the command line as spotgen (see usage).

Usage

Web demo

Go to https://epsil.github.io/spotgen/, enter a generator string in the text field and press Create Playlist.

Command-line version

spotgen input.txt [output.txt]

input.txt is a text file containing a generator string, invoking any of the commands described below. output.txt will contain the generator's output, a list of Spotify URIs which can be imported into Spotify. If an output file is not specified, then the Spotify URIs are written to standard output, with an option to copy them to the clipboard.

Alternatively, one can pass a generator string as a single argument:

spotgen "#artist Bowery Electric"
spotgen "#similar Beach House\n#similar Hooverphonic"
spotgen http://www.last.fm/user/username/library

Make sure to surround the string with quotes (") if it contains spaces or special characters. Line breaks can be expressed as \n.

One can also run the generator with no arguments and enter commands interactively. This saves one the trouble of quoting strings and escaping newlines.

For more information, type spotgen --help.

Importing the playlist

To import the playlist into Spotify:

  1. Copy the output of the generator: Choose Edit -> Copy (<kbd>Ctrl</kbd> + <kbd>C</kbd>).
  2. Create a new playlist in Spotify: Choose File -> New Playlist (<kbd>Ctrl</kbd> + <kbd>N</kbd>).
  3. Paste into the playlist: Select the playlist and choose Edit -> Paste (<kbd>Ctrl</kbd> + <kbd>V</kbd>).

Commands

The generator effectively defines a "mini-language" for creating Spotify playlists. One can create a playlist in many ways: on the basis of track titles, album titles, artist names, similar artists, top tracks or webpages.

Below follows a list of generator commands.

Web scraping

The generator can scrape data from web pages. (Note that this functionality is only available in the command-line version.)

Last.fm

The generator can be instructed to fetch data from Last.fm's webpages simply by supplying the page's address. For example, to create a playlist of artists similar to an artist, add the line:

http://www.last.fm/music/Artist+Name/+similar

To create a playlist of a user's recently played tracks:

http://www.last.fm/user/username/library

To fetch multiple pages in succession, add a number parameter:

5 http://www.last.fm/user/username/library

This is functionally identical to:

http://www.last.fm/user/username/library
http://www.last.fm/user/username/library?page=2
http://www.last.fm/user/username/library?page=3
http://www.last.fm/user/username/library?page=4
http://www.last.fm/user/username/library?page=5

Note that Last.fm displays listening history in reverse chronological order. To create a chronological playlist, add the #reverse command.

More on Last.fm scraping.

Pitchfork

To scrape a Pitchfork list:

http://pitchfork.com/features/lists-and-guides/9980-the-50-best-albums-of-2016/

Rate Your Music

To scrape a Rate Your Music chart:

http://rateyourmusic.com/charts/top/album/2016

Reddit

To scrape a Reddit forum:

http://www.reddit.com/r/SoundsVintage/

To scrape a comments thread:

http://www.reddit.com/r/Music/comments/2zpfv7/whats_the_catchiest_song_you_know_that_just_makes/

When scraping threads, it can be a good idea to add the #order by lastfm command. This will order the results by Last.fm popularity, thereby filtering out noise.

YouTube

To convert a YouTube playlist:

http://www.youtube.com/watch?v=yWEK4v9AVKQ&list=PLChOO_ZAB22WuyDODJ3kjJiU0oQzWOTyb

Top tracks

To retrieve the top 10 tracks of an artist, pass the following to the generator:

#top Aphex Twin

The generator will output a playlist consisting of the ten most popular tracks of Aphex Twin, which can then be imported into Spotify.

All of the commands listed here can be used multiple times. For example:

#top Aphex Twin
#top Beach House

This will create a playlist consisting of the top tracks of Aphex Twin, followed by the top tracks of Beach House.

To retrieve only the top 5 tracks, use #top5.

To retrieve all tracks, use #artist.

Similar artists

To find similar artists:

#similar Aphex Twin

This will generate a 100-track playlist consisting of the 5 most popular tracks from the 20 most similar artists to Aphex Twin.

To retrieve more tracks, use #similar10.

Albums

To add an album:

#album Biosphere - Substrata

Alternatively, use the album's Spotify link or Spotify URI:

https://open.spotify.com/album/5QIf4hNIAksV1uMCXHVkAZ

Artists

To add all the albums of an artist:

#artist Beach House

Alternatively, use the artist's Spotify link or Spotify URI:

https://open.spotify.com/artist/56ZTgzPBDge0OvCGgMO3OY

Note that this command can be rather slow, as it attempts to retrieve every single track by the artist, including tracks from collaboration and compilation albums. A fast alternative is the #top command.

Playlist

To add all the tracks of a playlist:

#playlist username:playlistid

where username is the owner of the playlist and playlistid is the ID of the playlist.

Alternatively, use the playlist's Spotify link or Spotify URI:

https://open.spotify.com/user/redditlistentothis/playlist/6TMNC59e1TuFFE48tJ9V2D

Tracks

To add a single track to the playlist, add a line on the form ARTIST - TRACK:

Beach House - Walk in the Park
Beach House - Irene
Beach House - Other People
Beach House - Troublemaker
Beach House - Wishes

Alternatively, use the track's Spotify link or Spotify URI:

https://open.spotify.com/track/4oNXgGnumnu5oIXXyP8StH

More on single tracks.

Duplicates

By default, the generator automatically removes duplicate tracks. To allow duplicates, add the line:

#duplicates

Reverse

To reverse the order of the tracks, add the line:

#reverse

Shuffle

To shuffle the order of the tracks, add the line:

#shuffle

Order

One can reorder the tracks with the #order by command. One can order on any track attribute, such as name, artist, album, etc. For example, to order the tracks by Spotify popularity, use #order by popularity:

#order by popularity
#artist Beach House

One can also leverage Spotify's analytic algorithms and order on the basis of audio features such as danceability, energy, instrumentalness, speechiness, tempo, etc. For example, to screen for instrumental tracks:

#order by instrumentalness
#artist Beach House

This moves instrumental tracks towards the beginning of the playlist and vocal tracks towards the end. To do the opposite, add the #reverse command:

#order by instrumentalness
#reverse
#artist Beach House

The generator also provides Last.fm support. To order by Last.fm playcount, add the line #order by lastfm:

#order by lastfm
#artist Beach House

To order by Last.fm user playcount, add the Last.fm username at the end:

#order by lastfm:username
#artist Beach House

Group

To sort the ordered tracks into groups, use #group by:

#order by lastfm
#group by artist
#similar Beach House

This will create a Last.fm-ordered playlist of artists similar to Beach House, where tracks from the same artists are grouped together.

Alternate

To group the tracks and then interleave them, use #alternate by:

#order by popularity
#alternate by artist
#similar Beach House
#similar Hooverphonic

This will create a Last.fm-ordered playlist of artists similar to Beach House and Hooverphonic, with each track having a different artist from the previous track.

Supported formats

The generator can work with Spotify links, Spotify URIs, M3U playlists and CSV files. By default, the generator outputs a list of Spotify URIs.

Import existing Spotify playlists

The generator understands Spotify links and Spotify URIs. These are usually

View on GitHub
GitHub Stars145
CategoryDevelopment
Updated6d ago
Forks29

Languages

JavaScript

Security Score

80/100

Audited on Mar 31, 2026

No findings