My new widget automatically creates a Spotify playlist.
It shows the metadata and cover art of a radio station („Radio Retrowelle“) by using the Spotify Search API.
Upon tapping on the widget it opens and plays the song on Spotify. Furthermore it optionally saves every song in a Spotify playlist by using an IFTTT webhook.
Gist: https://gist.github.com/marco79cgn/75fea28bdb183f79592f2e1875dd5c95#gistcomment-3468007
Features used in this script (which of course can be copied/reused):
- gradient background
- background image transparency
- Spotify Search Web API (incl. authentication)
- IFTTT webhook trigger
- persist files in iCloud (for caching)
The widget caches every Spotify token in order to use it as long as possible (~1 hour). It also caches the album cover to reduce unneeded requests. Caching also avoids adding the same track twice to the playlist.