AudioScrobbler / last.fm support

Viewing 10 posts - 31 through 40 (of 54 total)
  • Author
    Posts
  • #5244
    magnate
    Participant

    @magnate wrote:

    Hi Ron,

    Are you familiar with lastfmsubmitd? Here:

    http://www.red-bean.com/~decklin/software/lastfmsubmitd/

    It takes the pain out of writing lastfm plugins, because all you need to do is have the server output details of each song served to /var/spool/lastfm/

    Well, I finally managed to adapt the script posted by riro earlier in this thread, for use with lastfmsubmitd. Here it is, in case anyone else wants to use it:

    #!/bin/bash
    SQLITE="sqlite3"
    DATABASE="/var/cache/mt-daapd/songs3.db"
    LASTFILE=/var/cache/mt-daapd/lastfmsubmit.date
    OUTFILE=$(mktemp /var/spool/lastfm/mt-daapd-XXXXXXXX)

    if [ -e $LASTFILE ]
    then
    . $LASTFILE
    else
    LASTRUN=0
    fi

    $SQLITE $DATABASE 'SELECT artist,album,title,track,song_length,time_played FROM songs where time_played > '$LASTRUN' ORDER BY time_played ASC;' | awk -F '|' '{ printf "---nartist: "%s"nalbum: "%s"ntitle: "%s"ntrack: %snlength: %dntime: !timestamp %sn",$1,$2,$3,$4,$5/1000,strftime("%Y-%m-%d %T",$6) }' > $OUTFILE

    echo "LASTRUN="`date +%s` > $LASTFILE

    chmod 775 /var/spool/lastfm/*

    Run this script as a cron job and it automatically scrobbles your plays to lastFM. I run it daily, because I only listen for a couple of hours a day, but you can run it hourly or even more frequently if you want. It has a few limitations:

    1. It won’t scrobble partially-played tracks (this is also the behaviour of the default LastFM client, so fair enough)
    2. It won’t scrobble tracks which are paused and then restarted (because they count as partially played and are not recorded in songs3.db)
    3. It will only scrobble a given track once each time it is invoked (because songs3.db records only the last play of any track)

    N.B. If lastfmsubmitd is not packaged for your system, don’t forget to install Python along with it. Also note that lastfmsubmitd terminates itself on any error, so check /var/log/lastfm if you have any scrobbling probs.

    Obviously it’s not as good as having mt-daapd output the details of each song into /var/spool/lastfm play by play, but it’s a reasonable stopgap. I don’t tend to listen to any song more than once in a day, so it works for me.

    Cheers,

    CC

    #5245
    Anonymous
    Inactive

    @t0m wrote:

    I’ve modified the rockscrobbler perl script by noleti so you actually only need one script.

    this script supports compilations. You can download it from:

    http://rapidshare.com/files/31760952/firescrobbler.zip

    this is a sqlite3 version – for sqlite2 add use DBD::SQLite2;

    I’ve been testing this script for two weeks now (cronjob running every 5 minutes) – its working fine for me.
    /t0m

    Hello,

    I have tried unsuccessfully to use the above script, as I keep getting a “Can’t locate DBD/SQLite2” message. I can confirm through my ipkg list_installed command thast I am running both sqlite and sqlite2 packages.

    I have also tried to run perl -MCPAN -e ‘install DBD::SQLite2’ but it doesn’t recognise it!

    I have installed:
    ipkg install perl
    ipkg install perl-wwwlib

    I hope someone can help me with this, as I’ve tried everything I can think of, or seeminly find on Google searches.

    For info, I’m a complete Newbie at this sort of thing, so real basic instructions would be very welcome.

    I’m running last Friday’s nighly release on an unslung NSLU2.

    Many thanks if you can help, as this would complete my set-up.

    #5246
    rpedde
    Participant

    @OxonHammer wrote:

    @t0m wrote:

    I’ve modified the rockscrobbler perl script by noleti so you actually only need one script.

    this script supports compilations. You can download it from:

    http://rapidshare.com/files/31760952/firescrobbler.zip

    this is a sqlite3 version – for sqlite2 add use DBD::SQLite2;

    I’ve been testing this script for two weeks now (cronjob running every 5 minutes) – its working fine for me.
    /t0m

    Hello,

    I have tried unsuccessfully to use the above script, as I keep getting a “Can’t locate DBD/SQLite2” message. I can confirm through my ipkg list_installed command thast I am running both sqlite and sqlite2 packages.

    I have also tried to run perl -MCPAN -e ‘install DBD::SQLite2’ but it doesn’t recognise it!

    I have installed:
    ipkg install perl
    ipkg install perl-wwwlib

    I hope someone can help me with this, as I’ve tried everything I can think of, or seeminly find on Google searches.

    For info, I’m a complete Newbie at this sort of thing, so real basic instructions would be very welcome.

    I’m running last Friday’s nighly release on an unslung NSLU2.

    Many thanks if you can help, as this would complete my set-up.

    You are using sqlite3, so use the sqlite3 instructions.

    — Ron

    #5247
    Anonymous
    Inactive

    I am running what I thought was the latest stable nighly release, and this appears to have created a songs.db file in /opt/etc/mt-daapd/, and this is a sqlite2 file.

    Where is the nightly version that runs sqlite3?

    Thanks.

    #5248
    rpedde
    Participant

    @OxonHammer wrote:

    I am running what I thought was the latest stable nighly release, and this appears to have created a songs.db file in /opt/etc/mt-daapd/, and this is a sqlite2 file.

    Where is the nightly version that runs sqlite3?

    Thanks.

    Grumble.

    As was pointed out to me in another forum, I’ve somehow messed up my builds and and building versions that *don’t* support sqlite3. I’ll try and rectify this in upcoming nightlies.

    Sorry! I thought I had switched defaults on the packages all to sqlite3. Maybe I just dreamed it. 🙂

    — Ron

    #5249
    Anonymous
    Inactive

    It could have been me though. I followed the instructions inside http://wiki.fireflymediaserver.org/NSLU2_Installation which pointed me towards the http://ipkg.fireflymediaserver.org/armeb release?

    I’ve found instructions for editing the .conf file, and also some others to drop the songs.db file and replace with the songs3.db file, so I sould be OK now.

    For info, if someone else wants this stuff, the instructions I found are:

    sqlite /path/to/songs.db .dump | sqlite3 /path/to/songs3.db (upgrading to sqlite3 database)

    #5250
    Anonymous
    Inactive

    Well, getting somewhere, but now I’m seeing errors within the perl script, that don’t help me identify where my process is failing.

    I’m getting the following message, which hopefully someone will be able to identify what my problem is?

    OUCH! Could not complete the handshake: 500 server closed connection without sending any data back.

    Now I presume this must have something to do with the code inside the Audio::Scrobbler.handshake() method? But can’t tell if the problem is on my end or theirs?

    Hope you can help? I feel like I’m getting within touching distance, and don’t want to quit on this.

    #5251
    Anonymous
    Inactive

    Discovered the bad handshake is a last.fm problem. I get it about 25% of the time!

    But I now have this running, and seemingly sending data to post.audioscrobbler.com, but yet nothing is getting added to my profile. I believe I have tracked this down to bad data coming out of sqlite3. For some reason, when I try to send the length and last_played attribute, these are both 0 values.

    This is odd, as I have run the sql statement directly inside sqlite3, and the data is inside the database and is displayed on screen, but yet the line (and I’m doing this from memory, so it might be wrong) $_->[4] returns zero, as does $_->[5]. These are the length and last_played columns.

    I have tried adding a column alias to these columns, and I was going to play around with reordering these columns to see if this makes a difference, but can’t see why they are both returning zero values, when the data is in the database?

    I believe this is why the script is failing for me, as these must be required fields inside the scrobbler?

    Thanks.

    #5252
    Anonymous
    Inactive

    Must have been the DBI:Sqlite driver, as I had to fix this by using the following SQL:

    SELECT artist, track, album, cast(song_length as varchar) as song_length FROM songs

    as the int/double column was getting turned into a zero, and last.fm wasn’t liking this!

    #5253
    barefoot
    Participant

    @magnate wrote:

    Obviously it’s not as good as having mt-daapd output the details of each song into /var/spool/lastfm play by play, but it’s a reasonable stopgap. I don’t tend to listen to any song more than once in a day, so it works for me.

    Thanks for the script. However, does it really work for you every time? It does not for me, as from time to time lastfmsubmitdaemon ignores the written files and does not submit the information. What is submitted and what not is fairly random.

    I first suspected empty files, but that’s not the reason. No clue…

Viewing 10 posts - 31 through 40 (of 54 total)
  • The forum ‘Feature Requests’ is closed to new topics and replies.