Gold radio spotify playlist.

I used to like listening to Gold radio, but they stopped broadcasting and switched to online only, and that's lame/no use for the car/there are ads. So I have written a script that adds their recently played tracks to a spotify playlist. I've set it to run every hour and it has a check for duplicates that mostly works.

It's written in PHP as that's my current language of choice, though I couldn't find many scripts for interacting with spotify when I did some googling. So I first wrote some handy functions for the actual scraper bit to use. The first:

spotify_trackid();

Fairly simple, gets the spotify track id for a track/artist name. It currently just grabs the top result from the array, as that seems to be track with the most popularity.

The second functions is:

spotify_addtrack();

This function passes the trackid to spotify-api-server which listens on localhost.

You need to specify the spotify uri for the playlist you want to add the track to.

The full script is fairly simple, it simply scrapes the recently played tracks list from the gold website. It creates two arrays, one for the artist and the other for the track name. It then combines them into a key => value array of artist => track.

It loops through the array, creating a space seperated string for each artist/track which is then passed to spotify_trackid. It then checks to see if the trackid already exists in the log and if it doesn't then passes the trackid to spotify_addtrack to be added to the playlist.

The playlist itself can be found here.

http://open.spotify.com/user/absw/playlist/0Ya2uK3J5YzCN5Uy23JD7f