Fetch your friends' Spotify feed and add the songs they listen to a dedicated playlist.
This project is motivated by the spotify-buddylist project, which allows getting the listening information of your friends programmatically. From this idea on, I wanted to save what my friends are listening to in a playlist for me to check out later and discover new music. Therefore, I use the rest of the Spotify API to store those songs in a playlist.
The script will automatically check regularly if your friends are listening to a different song, and if it is not already in the playlist, it will add it.
Each friend gets a playlist called Feed_<username>
.
You could then create a Folder in Spotify with all of these playlists to keep things organized.
Additionally, you can also track repeatedly played songs or track your own listening history.
The first thing needed is the sp_dc
cookie, which you can get by using the Spotify web player.
A detailed description of getting the cookie can be found here.
After that, the script requires the SPOTIFY_COOKIE
environment variable to be set to the value of the sp_dc
cookie.
Alternatively, you can place the cookie in a file called cookie.txt
in the same directory as the script.
pip install -r requirements.txt
SPOTIFY_COOKIE=YOUR-SPOTIFY-COOKIE python3 get_buddies.py
docker pull s1e2b3i4/buddylist
docker run --env SPOTIFY_COOKIE=YOUR-SPOTIFY-COOKIE s1e2b3i4/buddylist
docker pull s1e2b3i4/buddylist
docker run --env SPOTIFY_COOKIE=YOUR-SPOTIFY-COOKIE --env TRACK_SELF=True s1e2b3i4/buddylist
docker build -t buddylist .
docker run --env SPOTIFY_COOKIE=YOUR-SPOTIFY-COOKIE buddylist
- Set the
LOGLEVEL
environment variable toDEBUG
to increase the log output (Default:INFO
). - Set the
SLEEP_MINUTES
environment variable to change the interval the script checks the buddylist. (Default:2
) - Set the
TRACK_REPLAY_PLAYLIST
environment variable to also track repeatedly played songs. (Default:False
) - Set the
TRACK_SELF
environment variable to track your own listening history. (Default:False
)
- The
sp_dc
cookie will be valid for 1 year. After that, you have to get a new cookie from the Spotify web player. - Playlists are limited to a maximum of 11,000 songs.
If a playlist exceeds this length, the current date is added to the playlist name (
Feed_<username>
->Feed_<username>_<YEAR-MONTH-DAY>
). This playlist will not be used further for new songs. New songs will be added to a new playlist with the same name as the original playlist from now on.