SpotifySpy

Ahmed RefaeyAhmed Refaey
2 min read

I love Spotify and share some playlists with family and friends where everyone can add new tracks to the playlists (same genre indeed ;D) and listen to the others’ picks.

So far this is lovely, except that no one ever gets notified when a new track is added to a shared playlist! I used to send my brother a link to the track again on Telegram -my favourite IM ;)- or text him to check my newly amazing-as-usual added tracks which was annoying!

I love Automation…who doesn’t?!

There was no Spotify built-in setting (AFAIK) that could solve this issue either in the iOS or the MacOS version and I decided to automate that!

Anatomy

  • Telegram Bot

  • Spotify API

  • Python Service (Dockerized)

  • Raspberry Pi

  • AWS S3 Bucket (Optional)

How it works

The SpotifySpy service running on my Raspberry Pi monitors a configured Spotify playlist via Spotify’s API on my behalf and sends a rich text message to the configured Telegram channel using the Telegram Bot which is added as a member to the Telegram group chat.

The idea is very basic, when it starts, it downloads the Spotify playlist JSON metadata and as it runs forever, it will periodically (for example, every 60 seconds) download the playlist metadata and compare it to the saved one, send a chat Telegram message per newly added track and replace the old version of the playlist JSON file.

Bonus
The storage backend (where the Spotify playlist JSON metadata file is stored) is configurable and it supports Local filesystem storage and AWS S3.
All the moving parts are configurable through Environment Variables and/or a .env file.

Cool Result!

A new notification is sent to the music lovers sharing this Spotify playlist in a cool formatted Telegram message with info about the track and links!

In this screenshot, one of my Telegram group chats with 2 friends and the Bot is the 4th member sending messages from SpotifySpy.

Screenshot of a Telegram channel with friends and SpotifySpy new playlist tracks updates messages

I shared the code with <3 on GitHub (link)

Happy music sharing!!

1
Subscribe to my newsletter

Read articles from Ahmed Refaey directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ahmed Refaey
Ahmed Refaey