#!/usr/bin/perl # # Minor script to catch HTTP updates from danny6869's Weblogger plugin # for the SlimServer (http://www.regoroad.com/blog/Coolness/Squeezebox). # The strategy is just to write the two files that Weblogger POSTs # into the Blosxom plugin/state directory, where a Blosxom plugin can # find them and make them available to blog templates. # # This 'push' model (the slimserver updates the page when the song changes) # seems better than a 'pull' model (page retrieves song information when # it loads) because there are strict upper bounds on the number of song # changes that could ever be triggered: no more than one every few minutes, # and only while the squeezebox is in use. On the other hand there could # possibly be hundreds or thousands of page loads in a few minutes time # if the web page is popular (yeah, yeah, I said "possible," not "likely"). # # Copyright (C) 2005 Michael A. Dickerson. Modification and redistribution # are permitted under the terms of the GNU General Public License, version # 2. # # Written 12 Nov 2005 by M. Dickerson use strict; use warnings; use CGI; my $STATE_DIR = '/home/mikey/www/blosxom/plugins/state'; my $q = new CGI; print "Content-type: text/plain\n\n"; #my $fh = $q->upload("songinfo.txt") or die("no parameter songinfo.txt"); my $si = $q->param("songinfo.txt"); open OUT, ">$STATE_DIR/songinfo.txt" or die("can't open songinfo.txt: $!"); print OUT $si; close OUT or warn("can't close songinfo.txt: $!"); open OUT, ">$STATE_DIR/albumart.jpg" or die("can't open albumart.jpg: $!"); print OUT $q->param("albumart.jpg"); close OUT or warn("can't close albumart.jpg: $!"); open OUT, ">>$STATE_DIR/songinfo.log" or die("can't open songinfo.log: $!"); foreach my $l (split(/\n/, $si)) { $l =~ /.*?<\/b> <\/td>