Moode Forum
MPD auto update - Printable Version

+- Moode Forum (https://moodeaudio.org/forum)
+-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3)
+--- Forum: Support (https://moodeaudio.org/forum/forumdisplay.php?fid=7)
+--- Thread: MPD auto update (/showthread.php?tid=2327)

Pages: 1 2 3


MPD auto update - Coustard - 04-02-2020

Great software. Thanks for all the hard work.

I'm using rsync to transfer flacs from Mac to Moode (6.4.2). Is there any way that Moode can auto-update the MPD database, either periodically or on a 'folder watch' kind of basis rather than doing it manually every time I update the media folder contents?

It's no biggy - I know I can do it with mpc (and therefore could crontab it, I guess) ut I'm wondering if there is a more elegant way.

Cheers,

Roger


RE: MPD auto update - Tim Curtis - 04-02-2020

Theres an mpd setting that sets up inotify's on the folders but I recall that there were some issues with it so its set to "no" by default in moOde and there is no UI option for it.

I think if you update cfg_mpd SQL table and set the option to 'yes' it will persist.

Code:
sqlite3 /var/local/www/db/moode-sqlite3.db "update cfg_mpd set value='yes' where param='auto_update'"

After rebooting check mpd.conf to verify the option is still "yes"

Code:
cat /etc/mpd.conf



RE: MPD auto update - Coustard - 04-03-2020

Great. Thanks Tim, I'll give that a go and report back.


RE: MPD auto update - Coustard - 04-03-2020

It doesn't seem to work. Or at least not within 40 minutes or so. mpd.conf auto_update=yes is set, even after reboot.

'mpc udpate' over SSH doesn't seem to work either - the little spinning wheel in the top right corner of the browser page appears very briefly but not the "Database Update Started" message, and new files don't appear in the library tab. Updating using the browser Library Config tab Update button works, of course.

Not to worry, Tim - I'm grateful for your efforts but I wouldn't wish you to waste time on this. I'm sure you have more pressing issues at hand.

Cheers,

Roger


RE: MPD auto update - TheOldPresbyope - 04-03-2020

@Coustard

Hi, Roger.

I was going to suggest that a simple hack would be to create a script on your Mac to fire rsync and then mpc. Then I saw your comment "'mpc udpate[sic]' over SSH doesn't seem to work either".

I don't understand what you are seeing.

From my desktop I can either ssh into a moOde player and execute

Code:
mpc update

or I can execute mpc from my desktop
Code:
mpc -h <moode hostname> update

Either way I get the message "Updating DB (#1) ...", where the number increments each time I execute the command and AFAICT the spinner always actuates. I haven't been making changes to the database between each try so I can't confirm that the library is actually updated.

Regards,
Kent


RE: MPD auto update - Coustard - 04-03-2020

Hi Kent,

Thanks for your help.

I don't think that
Code:
mpc -h <moode hostname> update

will work for me because I'm on a Mac (no mpd/installed). Is that correct?

But yes, you correctly interpreted my imprecise prose.  From my Mac Terminal:


Code:
MacBook-Pro-6:~ rogerfking$ ssh pi@moode.local
[color=#44ce3b][size=x-small][font=Monaco]pi@moode.local's password: [/font][/size][/color]
Kernel 4.19.97-v7l+, Raspbian 10.2, moOde 6.4.2

[blah blah]

pi@moode:~ $ mpc update
[color=#44ce3b][size=x-small][font=Monaco]Updating DB (#19) ...[/font][/size][/color]
[color=#44ce3b][size=x-small][font=Monaco]volume:100%   repeat: off   random: off   single: off   consume: off[/font][/size][/color]
pi@moode:~ $ 

Which I think is what you are seeing. Checking with moodeutl -t in another ssh connection I see:


Code:
20200403 210329 enhanceMetadata(): coverurl: (/coverart.php/USB%2Fpimusic%2FAlfred%20Brendel%2FBach%20-%20Italian%20Concerto%20etc%2F02%20-%20Bach%2C%20J%20S%20-%20Italian%20Concerto%20in%20F%2C%20BWV%20971%20-%202.%20Andante.flac)
[color=#44ce3b][size=x-small][font=Monaco]20200403 210329 enhanceMetadata(): Song file[/font][/size][/color]
[color=#44ce3b][size=x-small][font=Monaco]20200403 210329 engine-mpd: Metadata returned to client: Size=(33)[/font][/size][/color]
[color=#44ce3b][size=x-small][font=Monaco]20200403 210329 enhanceMetadata(): coverurl: (/coverart.php/USB%2Fpimusic%2FAlfred%20Brendel%2FBach%20-%20Italian%20Concerto%20etc%2F02%20-%20Bach%2C%20J%20S%20-%20Italian%20Concerto%20in%20F%2C%20BWV%20971%20-%202.%20Andante.flac)[/font][/size][/color]
[color=#44ce3b][size=x-small][font=Monaco]20200403 210329 enhanceMetadata(): Song file[/font][/size][/color]
20200403 210329 engine-mpd: Metadata returned to client: Size=(32)


Whereas, clicking the update button in the browser library config tab I get:

Code:
20200403 210618 waitWorker(): Start (lib-config, w_active=1)
[color=#44ce3b][size=x-small][font=Monaco]20200403 210619 worker: Job updmpddb[/font][/size][/color]
[color=#44ce3b][size=x-small][font=Monaco]20200403 210619 enhanceMetadata(): coverurl: (/coverart.php/USB%2Fpimusic%2FAlfred%20Brendel%2FBach%20-%20Italian%20Concerto%20etc%2F02%20-%20Bach%2C%20J%20S%20-%20Italian%20Concerto%20in%20F%2C%20BWV%20971%20-%202.%20Andante.flac)[/font][/size][/color]
[color=#44ce3b][size=x-small][font=Monaco]20200403 210619 enhanceMetadata(): Song file[/font][/size][/color]
[color=#44ce3b][size=x-small][font=Monaco]20200403 210619 engine-mpd: Metadata returned to client: Size=(33)[/font][/size][/color]
[color=#44ce3b][size=x-small][font=Monaco]20200403 210619 waitWorker(): Wait  (1)[/font][/size][/color]
[color=#44ce3b][size=x-small][font=Monaco]20200403 210619 waitWorker(): End   (lib-config, w_active=0)[/font][/size][/color]
[color=#44ce3b][size=x-small][font=Monaco]20200403 210620 enhanceMetadata(): coverurl: (/coverart.php/USB%2Fpimusic%2FAlfred%20Brendel%2FBach%20-%20Italian%20Concerto%20etc%2F02%20-%20Bach%2C%20J%20S%20-%20Italian%20Concerto%20in%20F%2C%20BWV%20971%20-%202.%20Andante.flac)[/font][/size][/color]
[color=#44ce3b][size=x-small][font=Monaco]20200403 210620 enhanceMetadata(): Song file[/font][/size][/color]
20200403 210620 engine-mpd: Metadata returned to client: Size=(31)


Which is probably unhelpfully verbose. The difference that I see (not any kind of expert) is that the second code  shows two lines including waitWorker()  that don't appear in the first.

I don't know - I'm out of my depth here. All I can say is that it's not a life and death issue.

Cheers,

Roger


RE: MPD auto update - TheOldPresbyope - 04-03-2020

@Coustard

That worker task upmpddb essentially duplicates the "mpc update" command by an alternative method which would work for you on your mac if you don't want to try building mpc from source.

The alternative method is to use the MPD protocol via telnet. Here's an example on my Linux laptop:

Code:
kreed@T520 ~ $ telnet moode3a 6600
Trying 192.168.1.195...
Connected to moode3a.fios-router.home.
Escape character is '^]'.
OK MPD 0.21.11
update
updating_db: 8
OK
Connection closed by foreign host.

MPD is listening on port 6600, and the first line is just me invoking telnet to connect to that port on my moode player "moode3a".

The "OK MPD 0.21.11" response indicates I've successfully connected to MPD.

I entered "update" (and hit return) and the next two lines are the response. I then left telnet idle and MPD tore down the connection after it timed out.

I'm sure you have telnet. Sorry I didn't think of it before.   Blush

Regards,
Kent


RE: MPD auto update - Coustard - 04-03-2020

I do have Telnet, it seems. There is much that I didn't and don't know  Blush

So yes, I can Telnet in and issue the update command and get the same response as you. But still the newly added music doesn't appear.

Just to clarify, these are the steps I take:

1) Transfer new flacs to my media folder on Pi (using rsync).

2) In my web browser (Safari), go to moode.local and verify that the new flacs are there in moOde's file browser tab

3) From my Mac Terminal, ssh pi@moode.local and 'mpc update', or Telnet as you descibed and 'update'

4) See some activity in moodeutl -t, so I know something has happened.

5) In Safari, refresh the moOde Player page and check the library tab. No sign of the new flacs.

6) In Safari, select 'Configure' from the top right-hand corner menu, click on 'Library' to get the Library Config page, click the MPD Database 'Update' button.

7) Exit configuration (arrow top left-hand corner) and return to the library browse tab and the new flacs have apeared.

One quick thing, just in case it has a bearing - all my music is stored on a USB stick that mounts automatically in /media.

What this is all telling me, most of all, is that next time I have one of those "wouldn't it be nice if..." thoughts, I should keep it to myself and avoid bothering anyone else.

Thanks again,

Roger


RE: MPD auto update - TheOldPresbyope - 04-04-2020

Curious.

When I transferred a bunch of new music files to a subdirectory under /media/Test, where Test is the top level directory on a mounted USB thumbdrive, using either the mpc or the telnet methods causes them to show up under USB/Test in the folder list.

If I transfer a file directly to /media it gets scanned too, although that's not really supposed to be a location for music files. It's the mount point for USB drives.  I would use /mnt/SDCARD for storing files on the uSD card.

Regards,
Kent


RE: MPD auto update - the_bertrum - 04-04-2020

I've had a similar issue in the past which was caused by the number of files in my collection exceeding the space for inotify meaning only updates to those already with an inotify handle got updated. Could that be at play here?