09-25-2024, 11:06 AM
Hi, I've been using moode for a couple of years now and absolutely love it. I also like seeing album art and other metadata when I am listening to music, so I got a screen for my Raspberry Pi and it now sits comfortably on my desk displaying just that. I use Spotify's immense library to discover new music and this is when I think cover art and metadata are most useful, but unfortunately moode only shows a gray overlay with 'Spotify Active' on it.
After doing some research I found out that a common approach to the problem by other open source projects is using Spotify's Web API. Unfortunately it is limited, a bit clunky, the configuration process is not very user friendly and the end user has to agree to additional Terms of Service to use this API. Nevertheless I've created a very rough proof of concept and published it on github (https://github.com/sm00th/moode/tree/spotify) and asked if this approach can be considered to be used in moode. Tim suggested that I bring this up on the forum to discuss this feature with the broader community, see how much interest for the feature there is and how hard is the setup process.
Below are the instruction on how to set this up, but I must warn you that this is a very rough early prototype not designed for normal use, all it can do is show you some metadata for the currently playing track for authenticated user. It does not update automatically on track change and there is a high possibility of bugs. It is also possible that something goes wrong and breaks your installation so you'll have to install a fresh image, so before doing this doing at least a settings backup is recommended (Settings->System->Backup/Restore).
Install
This only works on moode9 installs.
Find out and note down the version of moode-player you are using:
Or, if you don't have apt installed:
Download and install the package:
Insert new fields into cfg database.
Reboot.
Configure
To use this feature you'll have to get access to Spotify API which comes with Terms of Service you'll personally have to agree to and comply with.
Go to the Spotify dashboard and click Create app. Fill in app name and description, under Redirect URIs add your moode's full address +
/spotify, so if you normally access moode at moode.test that would be http://moode.test/spotify, if you use an ip address instead of hostname: http://192.168.1.15/spotify. Select Web API in the list of APIs you are using and click Save.
On the app's page click Settings where you can find you Client ID and Client Secret (after you click View client secret link).
In moode go to Configure -> Renderers -> Spotify and fill in Client ID, Client Secret and Redirect URL with data from previous step.
Now go back to the main moode screen and start spotify playback. You will be redirected to a Spotify page where you'll need to login (if not logged in yet), give the app permissions to read your playback state. After that you'll be redirected back to moode where metadata about currently playing spotify song should be available.
Uninstall
To go back, downgrade the package (change the version after = to the version you were using):
Clean up database and session vars:
Reboot.
After doing some research I found out that a common approach to the problem by other open source projects is using Spotify's Web API. Unfortunately it is limited, a bit clunky, the configuration process is not very user friendly and the end user has to agree to additional Terms of Service to use this API. Nevertheless I've created a very rough proof of concept and published it on github (https://github.com/sm00th/moode/tree/spotify) and asked if this approach can be considered to be used in moode. Tim suggested that I bring this up on the forum to discuss this feature with the broader community, see how much interest for the feature there is and how hard is the setup process.
Below are the instruction on how to set this up, but I must warn you that this is a very rough early prototype not designed for normal use, all it can do is show you some metadata for the currently playing track for authenticated user. It does not update automatically on track change and there is a high possibility of bugs. It is also possible that something goes wrong and breaks your installation so you'll have to install a fresh image, so before doing this doing at least a settings backup is recommended (Settings->System->Backup/Restore).
Install
This only works on moode9 installs.
Find out and note down the version of moode-player you are using:
Code:
apt show moode-player | grep 'Version:'
Or, if you don't have apt installed:
Code:
dpkg -l moode-player
Download and install the package:
Code:
curl -O https://dump.trac3r.net/moode-player_9.1.3-1spotmeta1_all.deb
sudo apt-get install ./moode-player_9.1.3-1spotmeta1_all.deb
Insert new fields into cfg database.
Code:
sudo moodeutl -q "INSERT INTO cfg_system (id, param, value) VALUES (176, 'spotifyclientid', '');"
sudo moodeutl -q "INSERT INTO cfg_system (id, param, value) VALUES (177, 'spotifyclientsecret', '');"
sudo moodeutl -q "INSERT INTO cfg_system (id, param, value) VALUES (178, 'spotifyredirecturl', '');"
sudo moodeutl -q "INSERT INTO cfg_system (id, param, value) VALUES (179, 'spotifytoken', '');"
Reboot.
Configure
To use this feature you'll have to get access to Spotify API which comes with Terms of Service you'll personally have to agree to and comply with.
Go to the Spotify dashboard and click Create app. Fill in app name and description, under Redirect URIs add your moode's full address +
/spotify, so if you normally access moode at moode.test that would be http://moode.test/spotify, if you use an ip address instead of hostname: http://192.168.1.15/spotify. Select Web API in the list of APIs you are using and click Save.
On the app's page click Settings where you can find you Client ID and Client Secret (after you click View client secret link).
In moode go to Configure -> Renderers -> Spotify and fill in Client ID, Client Secret and Redirect URL with data from previous step.
Now go back to the main moode screen and start spotify playback. You will be redirected to a Spotify page where you'll need to login (if not logged in yet), give the app permissions to read your playback state. After that you'll be redirected back to moode where metadata about currently playing spotify song should be available.
Uninstall
To go back, downgrade the package (change the version after = to the version you were using):
Code:
sudo apt-get install moode-player=9.1.0-1moode1
Clean up database and session vars:
Code:
sudo moodeutl -q "DELETE FROM cfg_system WHERE param='spotifyclientid'
sudo moodeutl -q "DELETE FROM cfg_system WHERE param='spotifyclientsecret'"
sudo moodeutl -q "DELETE FROM cfg_system WHERE param='spotifyredirecturl'"
sudo moodeutl -q "DELETE FROM cfg_system WHERE param='spotifytoken'"
sudo moodeutl -D spotifyclientid
sudo moodeutl -D spotifyclientsecret
sudo moodeutl -D spotifyredirecturl
sudo moodeutl -D spotifytoken
Reboot.