#!/usr/bin/perl # Downloads RSS files and transforms them into BBXML format for # display on a Betabrite LED sign. # # Author: Darin Franklin # http://pobox.com/~dfranklin/bbxml/ use strict; use LWP::UserAgent; use FileHandle; use XML::LibXML; use XML::LibXSLT; #my $proxy = "http://kanga:3128/"; my $xslfn = "rss_alphasign.xsl"; my $color = ""; my $max = 10; use Getopt::Long; GetOptions( "color=s" => \$color, "max=i" => \$max, ); &main(@ARGV); sub main { print fetchnews(@_); } sub fetchnews { my ($url, $label) = @_; die &usage if not $label; my $parser = XML::LibXML->new(); my $xml = $parser->parse_string(readXML($url)); my $xsldoc = $parser->parse_file($xslfn); my $xslt = XML::LibXSLT->new(); my $xsl = $xslt->parse_stylesheet($xsldoc); my $result = $xsl->transform($xml, 'text-label' => "'$label'", 'color' => "'$color'", 'maxitems' => "'$max'", ); return $xsl->output_string($result); } sub readXML { my ($url) = @_; my $ua = LWP::UserAgent->new(); #$ua->proxy('http', $proxy); my $response = $ua->get($url); die $response->status_line unless $response->is_success; return $response->content; } sub usage { return<