Skip to content

marcus-castanho/spotify_playlist_guard

Repository files navigation

Guard Bot Logo

A guard bot for your collaborative playlists on Spotify.

Spotify Playlist Guard

This is a project of a bot guard for collaborative playlist on Spotify. Test the bot in action:

  • Use the Test playlist by adding a song to it and wait for it to be removed once every minute;
  • Check if the bot is up and running accessing its status webpage.

Also, please check the other apps related to this project:

Context

Spotify defines playlists as collaborative, private and public. The collaborative status is given to playlists which users want to share with friends or trusty people. However, once the playlists is set to collaborative, any user with access to the URL that leads to that playlist is able to edit it, adding or deleing tracks. At the day of the publication of this project - 07/03/2022 - there is no official available way of limiting access to collaborative playlists.

More discussions can be found in the official Spotify community forum:

The application

This is the codebase for the bot server which performs a guard routine removing, from selected playlists, tracks added by unauthorized users. Please check the other app related to this project:

Guard routine

The guard routine performed by the application consists of:

  1. Retrieving the active playlists registered in the service from the Spotify Playlist Guard API;
  2. Fetch the current state of the playlist from the Spotify Web API;
  3. Compare the two states of the playlists in terms of its snapshot_id and track's property 'added_by' which declares the related user;
  4. Once tracks added by unauthorized users are detected, the application:
    1. Removes these tracks from the Spotify playlist ;
    2. Updates it in the Spotify Playlist Guard API service.

Each guard routine performed for a playlist is published and consumed by a message queue.

Notes:

  • Ideally, taking into account the architecture of this application, the producer and consumer of the queues should be hosted in differente servers to avoid loops to block the server instance, but for the current size of the project, these two parts of the application are being exectued in the same server.

  • At the day of the publication of this project, the Spotify Web API does not provide a two-way communication protocol for access to state changes such as playlist update, player update, etc. Therefore, the alternative presented by this project, as described above, consists of periodic calls to the Spotify API in order to get changes in the state of the playlists. More discussions about this topic can be found in the resources:

Technologies and libraries

Also , the tools used in the development environment:

Usage - Run this app in your machine

Requirements:

  • Docker for deskop installed in your machine;
  • Docker Compose (The Windows and Mac versions of Docker Desktop include Docker Compose in their installation, so you only need to install it separately if you are using the Linux version);
  • NodeJS and npm installed in your machine;
  • Spotify Playlist Guard API runnind on your machine - see the project`s repo for instructions on how to run it and its dependencies services as containers on your machine;
  • A terminal of your choice.

Steps:

  1. Clone this repo on your local directory;
  2. In the terminal, enter the created directory and run the following command to install all the dependencies:
npm install -y

Run this app in your machine in a containerized environment in development mode:

  1. Create a .env file based on the .env.example in this project and insert the values of the vars based on your development environment.

Note: When running both the app and the message broker as a containers, the RABBITMQ_HOST env var must be set to 'rabbitmq';

  1. Initialize the Docker app in your machine and run the following command at the root of your directory to build the image of the app, start the containers and intialize the them:
docker-compose up --build -V -d

The application will then be available at 'http://localhost:3030'

  1. Once the containers and volumes are created in your machine, simply use the commands to start and stop them:
docker-compose start
docker-compose stop

Run this app in your machine locally using only the DB container:

  1. Create a .env file based on the .env.example in this project and insert the values of the vars based on your development environment.

Note: When running the the app locally, the RABBITMQ_HOST env var must be set to 'localhost';

  1. Remove the 'main' service of the docker-compose.yml file;

  2. Initialize the Docker app in your machine and run the following command at the root of your directory to intialize the containers of the external services:

docker-compose up -d
  1. Run the following command to run the app in development mode:
npm run dev
  1. For a production-like running app, run the following commands:
npm run build
npm run start

The application will then be available at 'http://localhost:3030'

Development and contributions

Commit Message Guidelines

This project uses Convention Commit with AngularJS's commit message convention specifications for standard commit messages.

License

Spotify Playlist Guard is published under MIT license

About

A guard bot for your collaborative playlist on Spotify

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published