npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

spotify-smart-playlists

v3.0.0

Published

Generate smart playlists for Spotify

Downloads

28

Readme

Spotify Smart Playlist Generator

This package can be used to generate smart playlists for Spotify. It's inspired by the smart playlist feature you can find in iTunes.

Installation

This package is available at npmjs.com, so you can install it using npm, yarn, or other package managers that support npmjs.com.

$ yarn add spotify-smart-playlists

Example

const { SmartPlaylistsGenerator, PlaylistLoader } = require('spotify-smart-playlists')
const { compose, reverse, take, flatten } = require('ramda')

// Initiate a new SmartPlaylistsGenerator instance. Please take a look at
// Spotify's documentation to learn how to get the required params:
// https://developer.spotify.com/
const smartPlaylists = new SmartPlaylistsGenerator({
  clientId: 'your client id',
  clientSecret: 'your client secret',
  refreshToken: 'your refresh token'
})

// In this example we take one playlist as input, reverse the order, and take the
// first 20 tracks (which are actually the 20 last tracks, since the order is
// reversed)
const loader = new PlaylistLoader('4tWeRdIYH4ZPo5vvJIPJFm')
const outputPlaylistId = '7a81cTH5K8MUF6geWYZahA'
const generator = compose(take(20), reverse, flatten)

// Add the playlist generator to our instance
smartPlaylists.addPlaylist([loader], outputPlaylistId, generator)

// Run your playlist generator(s)
smartPlaylists.generatePlaylists()

Future plans

At the moment, this smart playlist generator isn't really that smart. I'd like to create some prebuilt 'ingredients' you can use when generating your playlists (for example something to filter out some tracks). Right now, almost anything is possible, but you have to write the code yourself.

Something that is not really possible at the moment, is merging several playlists. One of the first things I'm planning on working on is support for multiple input playlists.