Reply To: AudioScrobbler / last.fm support

#5265
pcace
Participant

Hey,

i just tried to install lastfm support in my mt-daapd server. BUT i get a strange error: i changed the path names according to my needs but it simply dont works. what i get is:

[: 33: -rw-r--r-- 1 mt-daapd nogroup 19552256 2010-04-14 14:48 /var/cache/mt-daapd/songs3.db: unexpected operator

I tried the script from here: http://www.themaelstrom.co.uk/node/10
I run ubuntu 9.04 Server (mt-daapd version svn-1696, sqlite3 version 3.6.16)

Hopefully someone can help me!

Thanks!

Thats the complete output:

user@mashine:~/scripts$ cat lastfmsubmit.sh
#!/bin/bash

# fetch newly played songs from fireflydb and write
# into lastfmsubmitd readable format

# config
SQLITE=/usr/bin/sqlite3
DATABASE=/var/cache/mt-daapd/songs3.db
LASTFILE=./lastfmsubmit.date
DBLSFILE=./lastfmsubmit.ls

# get last run time
if [ -e $LASTFILE ]
then
. $LASTFILE
else
LASTRUN=0
fi

# get last database file date
if [ -e $DBLSFILE ]
then
. $DBLSFILE
else
DBLSRUN=
fi

# exit when database file unchanged
DBLSNOW=`ls -l $DATABASE`
if [ “$DBLSRUN” == “$DBLSNOW” ]
then
exit
fi

# log file date
echo “DBLSRUN=”$DBLSNOW”” > $DBLSFILE

# query database
OUTFILE=$(mktemp /tmp/mt-daapd-XXXXXXXX)
$SQLITE $DATABASE ‘SELECT artist,album,title,track,song_length,time_played FROM songs where time_played > ‘$LASTRUN’ ORDER BY time_played ASC;’ | gawk -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

# Move the file to the daemon spool directory if it is not empty
if [ -s $OUTFILE ]
then
mv $OUTFILE /var/spool/lastfm
fi

# log query date
echo “LASTRUN=”`date +%s` > $LASTFILE

# make lastfmsubmitd files readable
chmod 664 /var/spool/lastfm/*

user@mashine:~/scripts$ sudo sh lastfmsubmit.sh
[: 33: -rw-r–r– 1 mt-daapd nogroup 19552256 2010-04-14 14:52 /var/cache/mt-daapd/songs3.db: unexpected operator
user@mashine:~/scripts$