Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

mpdev - mpd event monitoring daemon #31

Let me start by saying that I find RompR the best and the most feature rich player for mpd.

I have been using mpd for quite some time and my default player has been cantata on Linux and OSX. Before that I have been using Clementine. Over a period of few years, I had the rating and playcounts populated, which were useful in generating automatic playlists to listen to songs that I preferred. For almost two years, the quality of Clementine has been going down with crashes, high memory consumption, etc. So I overhauled my audio room with a SBC board from Allo and I started using mpd. But to record my listening habits, I had to enable the sticker command in mpd and import ratings, playcounts, Date added, Last Played, Playcount, Rating, etc in antoher sqlite database named stats.db. Along with a script, I am now able generate playlists on the fly based on certain conditions (rating, last played, playcount, etc). Since the past 2-3 days I have been reading rompr's documentation and I find rompr has something similar - personalized radio.

Thank you for respoding to my issue, which helped me in writing queries to look at rompr's playcounts and ratings. This along with another project named mpdcron, inspired me to do something with the ratings and playcount maintenance. I came up with mpdev, a daemon that uses mpd's idle mode to figure out events and run scripts specific for each event.

This was achieved by writing a generic C program to calls any user defined script in $HOME/.mpdev/player. The script is passed lot of environment variables and few arguments. Along with the C program, I wrote a shell script that keeps updating the rompr MySQL db, the stats db and mpd sitcker db. With this I am now able to generate history in rompr's MySQL database Playcounttable and also update (Ratingstable, Tracktable). This is done even when I don't have a browser running rompr. If I update the rating in cantata, the same gets updated in rompr. If I run rompr and update the rating in rompr, the same gets updated in mpd's sticker database. If mpd plays a track when a browser session is not running, the history will yet be available when the user opens RompR at any time later. The C program mpdev can in fact run any script based on known mpd events. e.g.

SONG_CHANGE             ~mpdev/player
PLAY/PAUSE              ~mpdev/playpause
STICKER_EVENT           ~mpdev/sticker
MIXER_EVENT             ~mpdev/mixer
OPTIONS_EVENT           ~mpdev/options
OUTPUT_EVENT            ~mpdev/output
UPDATE_EVENT            ~mpdev/update
DATABASE_EVENT          ~mpdev/database
PLAYLIST_EVENT          ~mpdev/playlist
STORED_PLAYLIST_EVENT   ~mpdev/stored_playlist
PARTITION_EVENT         ~mpdev/partition
SUBSCRIPTION_EVENT      ~mpdev/subscription
MESSAGE_EVENT           ~mpdev/message
MOUNT_EVENT             ~mpdev/mount  
NEIGHBOUR_EVENT         ~mpdev/neighbour
CUSTOM_EVENT            ~mpdev/custom (not a mpd event, but runs for few
                         custom cases)

Along with the mpdev, mpdplaylist I have another script named romprhist that shows the history along with the playcount, rating and last played timestamps. e.g.

$ romprhist
Index  End Time            Count Star Filename
151555 2020-07-20 21:54:30 01    3    Fats Domino/The Complete Imperial & ABC-Paramount Recordings (Bear Family, 2019)/CD1/02 - Detroit City Blues.flac
151556 2020-07-20 21:57:06 01    3    Fats Domino/The Complete Imperial & ABC-Paramount Recordings (Bear Family, 2019)/CD1/03 - Hide Away Blues.flac
151557 2020-07-20 21:58:56 01    4    Fats Domino/The Complete Imperial & ABC-Paramount Recordings (Bear Family, 2019)/CD1/04 - She's My Baby.flac
151558 2020-07-20 22:03:07 01    3    Fats Domino/The Complete Imperial & ABC-Paramount Recordings (Bear Family, 2019)/CD1/05 - Brand New Baby.flac
....
....

After reading rompr's documenation I came across this section

So the player script does pretty much the same I believe, but without using lastfm.

I have hosted the project here

The project is still WIP. It works for me, but I'm modifying it continuously for the past few days. You can write your own script if required. I thought of making it public so that someone else can find some use for it, especially the mpdev program which is quite generic. The installation and setup instructions are there on the project home page. I also need to work on the documentation.

I even have debian apt-get repo and RPM repo for raspberry pi and Fedora linux 64bit

The binary installation requires the daemontools package to run mpdev under supervise. The rpm or debian package for daemontools can be downloaded from here

for raspberry pi

for fedora linux

I can enable the respository for any other distro (debian, ubuntu, opensuse, centos) if required. Let me know

Ultimately I think I will drop mpdplaylist script and use rompr's personalized radio. Also I have to try the lastfm import at startup to see if that is the same as what the player script does and imports the full history, playcounts and timestamps. I may write a script to update the rompr datatabase when mpdev detects a DATABASE_EVENT event. The rompr document mentions running a curl script, but it seems to be doing nothing, with the following line in the apache logs

[Tue Jul 21 13:04:29.892938 2020] [php7:notice] [pid 1004] [client 192.168.2.124:54520] PHP Notice:  ob_flush(): failed to flush buffer. No buffer to flush in /var/www/html/rompr/albums.php on line 313

maybe I'm doing something wrong and I have to investigate.

Suggestions welcome, but I may take time to implement it. I have a full lockdown (covid19) in my city and it is driving me crazy.

  • replies 0
  • views 1.4K
  • likes 0