Update: people are having trouble with this now, I am unable to debug what is wrong, it seems like a problem with mocp.
When not using Amarok (e.g. if I'm low on memory due to using VMs or something), moc is very nice music player (Debian/Ubuntu package 'moc', but command 'mocp'). Here is how to get it to submit tracks to last.fm in a well behaved manner (that doesn't submit tracks if you are just skipping through a playlist):
- Install lastfmsubmitd:
sudo aptitude install lastfmsubmitd - Add yourself to lastfm group:
sudo adduser [yourusername] lastfm - Download and save my MOC - last.fm script, and make it executable.
- Alter your ~/.moc/config to set OnSongChange as per the instructions at the top of the script.
- Completely quit moc and restart it.
The advantage of the script I wrote over just using OnSongChange is that my script will wait for half the length of the song before submitting to last.fm. Every 5 seconds it will check you are still listening to that song, and if not, it will quit. This way it will behave much more like Amarok and other well behaved last.fm clients.
Comments §
I just started using MOC today
FATAL_ERROR: Error in config file, line 17.
Just update MOC
Ubuntu 9.04.
now I have 2.5.4 and this script doesn't work at all :(
I did exactly everything you've said and it's not working. The bottom of my config file looks like this:
OnSongChange = "~/.moc/moc_submit_lastfm --artist %a --title %t --length %d --album %r"
And it does nothing.
--- moc_submit_lastfm.orig 2008-06-27 00:40:38.000000000 +0200
+++ moc_submit_lastfm 2010-02-19 09:41:23.000000000 +0100
@@ -33,7 +33,7 @@
p = Popen(["mocp", "-i"], stdout=PIPE)
out, err = p.communicate()
lines = out.split("\n")
- for s in ["Artist: %s" % artist, "Album: %s" % album, "SongTitle: %s" % title]:
+ for s in ["State: PLAY", "Artist: %s" % artist, "Album: %s" % album, "SongTitle: %s" % title]:
if not s in lines:
return False
return True
The last thing I did before it started working was to switch the order of 2 lines in "/etc/lastfmsubmitd.conf".
In the INSTALL doc, it says the file should look like:
[account]
username = WaltKelly
password = amondayfriday13
Mine looked like:
[account]
password = amondayfriday13
username = WaltKelly
I don't know if switching it back to how INSTALL describes it fixed my problem or if it was that I gave myself ownership privileges to the files INSTALL lists. In any event, last.fm now reflects my recent moc plays.
After specifying the right config file, I saw a few other places things could go weird, not sure if they'll fix anything, but;
1. Like eleventhcrane said, check the order in /etc/lastfmsubmitd.conf
2. Make sure MOC is using the right MOCDir/config file
3. Make sure that OnSongChange doesn't have the default "/path/to/file" thing!
Not sure if it's working for me yet...
In most cases mentioned above that should be enaught to work.
nsanow at gmail dot com
I'm at a loss.
I changed permission in /var/spool/lastfm to 777 because none of the songs' info files appeared there otherwise. The current ownership of /var/spool/lastfm is lastfm:root. Shouldn't it be root:lastfm or lastfm:lastfm ?
I'm certain that my /etc/lastfmsubmitd.conf file is edited correctly.
Works perfectly now!