#!/usr/bin/perl
# Time-stamp: "2008-05-31 22:20:14 ADT"
# See http://www.interglacial.com/rss/ for info on RSS feeds

use strict;
use XML::RSS::SimpleGen 12;
use constant DEBUG => $ENV{'MAILTO'} ? 0 : 1;
  # to test whether we're under crontab

rss_new(
 'http://www.kchronicles.com/',
 "The K-Chronicles",
 'Bringing the "Funny" Back to the Funny Pages'
);
rss_daily();
rss_self_url(      "http://interglacial.com/rss/kchronicles.rss" );
rss_generator_url( "http://interglacial.com/rss/kchronicles.pl" );
rss_livejournal( 'kchronicles' );

get_url(my $inurl = 'http://www.buzzle.com/chapters/authors.asp?author=243');

if(time() < 1161931674) {
  rss_item('http://www.buzzle.com/authors.asp?author=243',
	   "Whoopsies",
	   "The RSS generator for the K Chronicles was on the blink for the past five weeks or so. It's fixed now, but you'll probably want to hit the link here and catch up on the past month or so of Keef's stuff that you missed.  Sorry for the inconvenience!"
	  );
  rss_item_limit(15);
} else {
  rss_item_limit(5);
}

DEBUG and print "Got $inurl : {{\n$_\n}}\n";
while(
	m{<a\s+class=\"nl\"\s+href=\"
	  (?: \.\./ | http://www\.buzzle\.com/ | )
	  (
           (?: editorials | articles )
	   /[^\"\\<>]+)\">([^\n\r]*?)</a>
	}gix
) {
  my($u, $t) = ( "http://www.buzzle.com/$1", $2 );
  $t =~ s{^&quot;(.*?)&quot;$}{$1}s;
  DEBUG and print "$u => $t\n";
  rss_item( $u,$t );
}

rss_item_count or die "$0: Nothing found in $inurl\n{{\n$_\n}}\nAborting";
rss_save("kchronicles.rss", 14);
DEBUG > 1 and print "\n", rss_as_string, "\n";
DEBUG and print "\nEnd.\n";
exit;
__END__
