Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Update sources from command line?
#1
Hi there,

I automatically rip CD's when inserted with a script and copy the FLACs to my NAS. It would be nice to also be able to automatically update the Moode library from the script, since it's the only manual step I have to take now. Is there any way to do this from the shell? I've been looking at the forum and documentation and cannot find it.

If there is none, maybe you can point me to the correct files (php or otherwise) handling this? Maybe I can code a shell script for it and share it, if I find the time Smile

Thnx!
Reply
#2
If your rip and copy process is happening on a remote computer then:

1) update MPD database
telnet moode 6600
update

2) truncate library cache so Library panel reloads from scratch
ssh pi@moode
truncate /var/local/www/libcache.json --size 0

I'm not sure how to automate (2)

The other option is to create a bash script in /var/www which contains the cmds below then run it remotely via the following url: http://moode/command?cmd=test.sh

#!/bin/bash
#
# /var/www/test.sh
#
mpc update
truncate /var/local/www/libcache.json --size 0

-Tim
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#3
(05-01-2018, 11:26 PM)Tim Curtis Wrote: If your rip and copy process is happening on a remote computer then:

1) update MPD database
telnet moode 6600
update

2) truncate library cache so Library panel reloads from scratch
ssh pi@moode
truncate /var/local/www/libcache.json --size 0

I'm not sure how to automate (2)

...
-Tim

If you set up authentication keys on the two hosts, you can use password-less ssh login to execute the command


Code:
ssh pi@moode truncate /var/local/www/libcache.json --size 0
[edit] Sorry, hit <enter> too quickly.
Obviously this can be generalized. You could use this to execute both commands, one at a time, or you could put the script in pi's home directory and execute it using this same technique.
Reply
#4
Great, thnx for the pointers and necessary steps. Should be pretty easy.

It rips from a separate RPI3 OSMC setup as soon as the CD is inserted, then copies over NFS to a Rock64 NAS and then shares the FLACs to Moode (RPI2/Mamboberry/Kali). The ssh option seems the more secure, gonna figure this out. I will post the best solution when done for future reference Wink

Thnx again!
Reply
#5
Ok, it was rather easy:

Used https://www.tecmint.com/ssh-passwordless...asy-steps/ to set op the ssh.

The script:

Quote:osmc@osmc:~$ cat /usr/bin/cdtest
#!/bin/bash
LOGFILE=/var/log/cdrip.log
echo "$(date)" >> $LOGFILE

sleep 10

(
# Wait for lock on /var/lock/.audio-cd-rip.lock (fd 200) for two hours
flock -x -w 7200 200 || exit 1

abcde 2>&1 >> $LOGFILE
rc=$?
if [[ $rc != 0 ]] ; then
eject
exit $rc
fi
ssh pi@moode mpc update >> $LOGFILE
ssh pi@moode truncate /var/local/www/libcache.json --size 0
echo "LOG END" >> $LOGFILE
) 200>/var/lock/.audio-cd-rip.lock

If anybody wants to do something similar; make sure to use UDEV to trigger the ripping proces (other options won't work on the Pi).
Reply
#6
(05-02-2018, 09:50 AM)sjoerdju Wrote: Ok, it was rather easy:

Used https://www.tecmint.com/ssh-passwordless...asy-steps/ to set op the ssh.

The script:

Quote:osmc@osmc:~$ cat /usr/bin/cdtest
#!/bin/bash
LOGFILE=/var/log/cdrip.log
echo "$(date)" >> $LOGFILE

sleep 10

(
 # Wait for lock on /var/lock/.audio-cd-rip.lock (fd 200) for two hours
       flock -x -w 7200 200 || exit 1

       abcde 2>&1 >> $LOGFILE
       rc=$?
       if [[ $rc != 0 ]] ; then
               eject
               exit $rc
       fi
ssh pi@moode mpc update >> $LOGFILE
ssh pi@moode truncate /var/local/www/libcache.json --size 0
echo "LOG END" >> $LOGFILE
) 200>/var/lock/.audio-cd-rip.lock

If anybody wants to do something similar; make sure to use UDEV to trigger the ripping proces (other options won't work on the Pi).

Great!

By the way, this is a very cool automation. What ripping tool are you using? Are you satisfied with the track names and tags it assigns? I haven't found a tool yet I totally trust. Operas especially are a challenge and I have a bunch of classics on CD. 

Regards,
Kent
Reply
#7
(05-02-2018, 12:30 PM)TheOldPresbyope Wrote:
(05-02-2018, 09:50 AM)sjoerdju Wrote: Ok, it was rather easy:

Used https://www.tecmint.com/ssh-passwordless...asy-steps/ to set op the ssh.

The script:

Quote:osmc@osmc:~$ cat /usr/bin/cdtest
#!/bin/bash
LOGFILE=/var/log/cdrip.log
echo "$(date)" >> $LOGFILE

sleep 10

(
 # Wait for lock on /var/lock/.audio-cd-rip.lock (fd 200) for two hours
       flock -x -w 7200 200 || exit 1

       abcde 2>&1 >> $LOGFILE
       rc=$?
       if [[ $rc != 0 ]] ; then
               eject
               exit $rc
       fi
ssh pi@moode mpc update >> $LOGFILE
ssh pi@moode truncate /var/local/www/libcache.json --size 0
echo "LOG END" >> $LOGFILE
) 200>/var/lock/.audio-cd-rip.lock

If anybody wants to do something similar; make sure to use UDEV to trigger the ripping proces (other options won't work on the Pi).

Great!

By the way, this is a very cool automation. What ripping tool are you using? Are you satisfied with the track names and tags it assigns? I haven't found a tool yet I totally trust. Operas especially are a challenge and I have a bunch of classics on CD. 

Regards,
Kent

Thnx! I wanted to rip my whole collection, so now it's easy just to put in a CD and walk away and do the next one when I get back.

Currently I'm using abcde.
http://www.andrews-corner.org/linux/abcde/index.html

It works great, but indeed the way it identifies classical composers/performers/albums is quite bad, i'm not sure how to fix it yet (other then manual editing, which is a hassle). I suspect the only option is to help improve the databases recognising classical CDs, since most other albums are recognised correctly. 

The problem is not as much the ripping tool afaik, but the database which is used:

Code:
# Specify the method to use to retrieve the track information,
# the alternative is to specify 'musicbrainz':
CDDBMETHOD=cddb


But I haven't tried the other one yet. 

It makes you choose when there are more options detected albums (I defaulted it for now), but there is often not much difference between the options. B I did manage to make it download album art automatically, when it's available:

http://www.andrews-corner.org/linux/abcd...umart.html

I made the following UDEV rule:

Code:
osmc@osmc:~$ cat /etc/udev/rules.d/999-cdinster.rules
SUBSYSTEM=="block", KERNEL=="sr0", ENV{ID_CDROM_MEDIA_CD}=="1", TAG+="systemd", ENV{SYSTEMD_WANTS}="cdinsert.service", RUN+="/bin/systemctl start cdinsert.service"

and the following service:


Code:
osmc@osmc:~$ cat /etc/systemd/system/cdinsert.service
[Unit]
Description=Ripping CD
After=udisks-glue

[Service]
User=osmc
Group=osmc
Type=oneshot
ExecStart=/usr/bin/cdtest

Somehow it didn't work by pointing the UDEV rule to the script, so I had to do it by making a .service.
Reply
#8
Wink 
Code:
# Specify the method to use to retrieve the track information,
# the alternative is to specify 'musicbrainz':
CDDBMETHOD=cddb

You can try both for each lookup....
Code:
# Specify the method to use to retrieve the track information,
# the alternative is to specify 'musicbrainz':
CDDBMETHOD=cddb,musicbrainz

 if it is not found on the first it tries the second  and, yes, popular music is much better tagged and found as it is, surprise, popular (= more submitters and possibly listeners to classical are less inclined to rip ??  ripping for mobile environments being not so successful a use case  ;-)
----------
bob
Reply
#9
Ah, great tip, I'll try this in reverse order (musicbrainz first). Thnx!

The problem is not as much that the CDs are not recognised (at least in my case) but that the tags and metadata are incorrect or just plain weird. A classical pieces has for example a famous composer, choir, director, orchestra, etc. Sometimes the artist named is the composer or the orchestra instead of the composer for example. This makes it hard to identify the CD afterward.

This discussion reminded me I still had to work on this Smile I found a nifty tool called beets (http://beets.io) which can retag using the musicbrainz database. It seems better for classical music. Not 100% sure yet since my SD died in the proces so I need to do a reinstall. But it seems promising; it needed a lot of interaction with identifying the right CD, but it works for most immediately. It can even send pieces of the audiofiles to identify the correct piece.

I will be in Paris for a couple of weeks, so not sure wether I'll have time to work on it, but I'll post an update/config as soon as I figured it out.
Reply
#10
(05-04-2018, 11:08 AM)sjoerdju Wrote: ...

The problem is not as much that the CDs are not recognised (at least in my case) but that the tags and metadata are incorrect or just plain weird. A classical pieces has for example a famous composer, choir, director, orchestra, etc. Sometimes the artist named is the composer or the orchestra instead of the composer for example. This makes it hard to identify the CD afterward.
...

Yeah, that's my problem too, and I've tried just about every online database. I've ripped multi-CD operas where the metadata from online sources isn't consistent even among the constituent CDs.

Classical music is hard because there's much more musicological information which could be tagged and little agreement in the community about what should be tagged and how. No "one ring to rule them all". This surprises me a little given the passion of us classical enthusiasts but that's life. For a fun waste of an afternoon, try searching on phrases like "the best way to tag classical music".

The horribly minimalist title/artist/album straight-jacket of the original ID3 Tag schema didn't help either. People got really creative with their track titles and artist names. Later versions of ID3 are much better---closer to the way I might define a primitive database---but old habits die hard. 

Incidentally, Apple has published a nicely written style guide: https://help.apple.com/itc/musicstylegui...tatic.html

I've done most of my ripping in Windows because the tools available seemed more complete, I suppose because it's a bigger market, but that's just a matter of taste.

@DRONE7 - yes, a lot of classical fans rip CDs (even LPs!); there are just so few of us Tongue 

Regards,
Kent
Reply


Forum Jump: