last.fm shell based forum generator
Sun, 2006-07-09 00:03
this little script generates a forum signature based on your last.fm profile - one which actually looks like a forum signature, which last.fm's generated images have thus far failed to achieve. It assumes the user's avatar was uploaded as a PNG. it requires curl, imagemagick, a font file (in this case Ellipsoideogram.ttf, but you can use any font in theory) and an image like ~/1bg.png.
the subshell wrapper is there to prevent error messages when you haven't listened to music for a while and there is no data... (so that cron spits no mails)
#!/bin/sh
(
cd /tmp
name="$1"
md5=`echo -n $name | md5sum | cut -c -32`
convert -font ~/Ellipsoideogram.ttf -fill '#4d56ff' -pointsize 17 -draw "text 5,40 $name" ~/1bg.png 1.$name.png
curl http://ws.audioscrobbler.com/1.0/user/$name/recenttracks.txt 2>/dev/null | head -n3 | sed 's/^[0-9]*,//' | convert -background black -fill grey -pointsize 12 -border 1 -font ~/Vera.ttf -page 350x68+5+5 text:- 2.$name.png
curl http://static.last.fm/avatar_thumbnails/$md5.png 2>/dev/null | convert -bordercolor black -border 3 -scale x70 - 3.$name.png
convert 1.$name.png 2.$name.png 3.$name.png +append /somewhere/$name.last.fm.png
rm {1,2,3}.$name.png
) >/dev/null 2>&1
the output should look something like










Looks cool, though many forums including Nuxified don't allow images in signatures or at least images that big. The reason is that it could distract from reading and contribute to bloat.
But maybe it can be styled differently, to have only nicely styled text of latest played tracks in it?
A really nice idea though.
Thanks
I updated it a bit;
#!/bin/sh(
cd /tmp
name="$1"
md5=`echo -n $name | md5sum | cut -c -32`
~/imagemagick/bin/convert -font ~/SteveHand.ttf -fill '#000077' -pointsize 15 -draw "text 15,20 $name" ~/1bg2.png 1.$name.v2.png
curl http://ws.audioscrobbler.com/1.0/user/$name/recenttracks.txt 2>/dev/null | head -n2 | sed 's/^[0-9]*,//' | ~/imagemagick/bin/convert -fill black -pointsize 9 -border 1 -font ~/Vera.ttf -page 350x38+3+3 text:- 2.$name.v2.png
~/imagemagick/bin/convert 1.$name.v2.png 2.$name.v2.png ~/3bg2.png +append /home/www/zombiehq/$name.last.fm.v2.png
rm {1,2}.$name.v2.png
) >/dev/null 2>&1
~/1bg2.png
~/3bg2.png
I must say the updated one lookes better than the first - somewhat lighter and less imposing.
I published the above just because it was so funny!
For those that aren't mods, we have an automatic spam filter that sets caught spam to "unpublished" so only mods can see it.
I do quite like the second one.