03-24-2021, 04:38 PM
I have a preliminary ("beta") working version of the Spotify Now Playing feature. I've forked the moode repo and created a new branch (nowplaying) here.
When a song is launched from a Spotify app (PC, iPad, Android), moOde shows the currently playing song title/album/artist, just as if played from MPD/File system.
Summary of changes made:
- [/var/local/www/db/moode-sqlite3.db.sql] Added a new Table cfg_nowplaying to store the song metadata. Added new parameter 'vollibrespot' to existing Table cfg_spotify (Yes/No values).
- [/var/www//engine-mpd.php] Changes to "simulate" an MPD status info with the Spotify metadata stored in the database.
- [/var/www/spo-config.php] Changes to support the new cfg_spotify param
- [/var/www/command/sysinfo.sh] Changes to support the new cfg_spotify param
- [/var/www/inc/playerlib.php] Changes to optionally start vollibrespot instead of librespot from startSpotify
- [/var/www/command/worker.php] Kill vollibrespot as well for now
- [/var/www/templates/spo-config.html] Template to show new Spotify config option (vollibrespot) called "Show Metadata"
- [build_recipe.txt] TODO: Skipped for now.
- [snd-config.html] TODO: Skipped for now.
- New files:
- [/var/www/inc/udp_metadata.php] NEW FILE: php daemon that reads UDP metadata info and stores it in sqlib3 cfg_nowplaying table. chmod +x needed.
- [/var/local/www/commandw/install-vollibrespot.sh] NEW FILE: Copies changed files, creates cfg_nowplaying table and inserts default values. chmod +x needed.
- [/usr/local/bin/vollibrespot] NEW FILE: daemon that publishes Spotify connect song metadata. chmod +x needed.
NOTES:
- Why a new table? sqlib3 was used for other stuff, and it looked to cleanest way to communicate to moOde the metadata captured by vollibrespot.
- Now when playing a song from Spotify, the moOde web display is not covered with a "Playing from Spotify" message anymore. You just see the usual display with the now playing song, as if it was playing from MPD.
- Only title, album, artist (first one) and cover image are updated for now. The cover image doesn't automatically refresh. You have to refresh manually the page.
- To avoid constant info refreshes in the web browser, a 10seg sleep has been hardcoded in engine-mpd.php. There's for sure a better way to notify the web ui that new data is available for it to refresh, but I didn't find it.
TODO:
- Update additional info that is accesible: current song elapsed time, bitrate,...
- Backup MPD current track info before showing anything from Spotify and restore once Spotify is paused.
- Auto-restart vollibrespot / udp_metadata if they crash.
...
HOW TO INSTALL:
- Download vollibrespot from your Raspberry Pi:
wget https://github.com/ashthespy/Vollibrespo...v7l.tar.xz
tar -xf vollibrespot-armv7l.tar.xz
- Download all mentioned files from the nowplaying branch in my forked repo to a directory in your Raspberry Pi.
- chmod the specified files.
- Execute ./install-vollibrespot.sh (will copy the file to the right directories and create the new database table)
- Restart and configure the Spotify renderer to use vollibrespot instead of librespot. Restart again and try.
Finally, some questions: Is there a documented way to contribute to moOde? Are pull requests welcome?
When a song is launched from a Spotify app (PC, iPad, Android), moOde shows the currently playing song title/album/artist, just as if played from MPD/File system.
Summary of changes made:
- [/var/local/www/db/moode-sqlite3.db.sql] Added a new Table cfg_nowplaying to store the song metadata. Added new parameter 'vollibrespot' to existing Table cfg_spotify (Yes/No values).
- [/var/www//engine-mpd.php] Changes to "simulate" an MPD status info with the Spotify metadata stored in the database.
- [/var/www/spo-config.php] Changes to support the new cfg_spotify param
- [/var/www/command/sysinfo.sh] Changes to support the new cfg_spotify param
- [/var/www/inc/playerlib.php] Changes to optionally start vollibrespot instead of librespot from startSpotify
- [/var/www/command/worker.php] Kill vollibrespot as well for now
- [/var/www/templates/spo-config.html] Template to show new Spotify config option (vollibrespot) called "Show Metadata"
- [build_recipe.txt] TODO: Skipped for now.
- [snd-config.html] TODO: Skipped for now.
- New files:
- [/var/www/inc/udp_metadata.php] NEW FILE: php daemon that reads UDP metadata info and stores it in sqlib3 cfg_nowplaying table. chmod +x needed.
- [/var/local/www/commandw/install-vollibrespot.sh] NEW FILE: Copies changed files, creates cfg_nowplaying table and inserts default values. chmod +x needed.
- [/usr/local/bin/vollibrespot] NEW FILE: daemon that publishes Spotify connect song metadata. chmod +x needed.
NOTES:
- Why a new table? sqlib3 was used for other stuff, and it looked to cleanest way to communicate to moOde the metadata captured by vollibrespot.
- Now when playing a song from Spotify, the moOde web display is not covered with a "Playing from Spotify" message anymore. You just see the usual display with the now playing song, as if it was playing from MPD.
- Only title, album, artist (first one) and cover image are updated for now. The cover image doesn't automatically refresh. You have to refresh manually the page.
- To avoid constant info refreshes in the web browser, a 10seg sleep has been hardcoded in engine-mpd.php. There's for sure a better way to notify the web ui that new data is available for it to refresh, but I didn't find it.
TODO:
- Update additional info that is accesible: current song elapsed time, bitrate,...
- Backup MPD current track info before showing anything from Spotify and restore once Spotify is paused.
- Auto-restart vollibrespot / udp_metadata if they crash.
...
HOW TO INSTALL:
- Download vollibrespot from your Raspberry Pi:
wget https://github.com/ashthespy/Vollibrespo...v7l.tar.xz
tar -xf vollibrespot-armv7l.tar.xz
- Download all mentioned files from the nowplaying branch in my forked repo to a directory in your Raspberry Pi.
- chmod the specified files.
- Execute ./install-vollibrespot.sh (will copy the file to the right directories and create the new database table)
- Restart and configure the Spotify renderer to use vollibrespot instead of librespot. Restart again and try.
Finally, some questions: Is there a documented way to contribute to moOde? Are pull requests welcome?