From: Andrew Ruthven Date: Fri, 12 Oct 2007 01:34:59 +0000 (+1300) Subject: Add parameters, error checking and some (minor) comments. X-Git-Tag: 0.1~14 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=53754e52a43c1c3d7fc4b43df59a85a5e729d366;p=mythtv-status.git Add parameters, error checking and some (minor) comments. --- diff --git a/bin/status.pl b/bin/status.pl index 9d0c5fb..63a1959 100755 --- a/bin/status.pl +++ b/bin/status.pl @@ -3,11 +3,24 @@ use LWP::Simple; use XML::LibXML; use Date::Manip; +use Getopt::Long; my $host = "localhost"; my $port = "6544"; -my $status = get("http://$host:$port/xml"); +GetOptions( + 'h|host=s' => \$host, + 'p|port=s' => \$port +); + +die "Sorry, port isn't a number.\n" + if $port !~ /^\d+$/; + +my $url = "http://$host:$port/xml"; +my $status = get($url); + +die "Sorry, failed to fetch $url.\n" + unless defined $status; my $parser = XML::LibXML->new(); my $xml = eval { $parser->parse_string( $status ) }; @@ -40,6 +53,7 @@ my @blocks = ( 'attrs' => [ qw/title startTime/ ], 'template' => "__startTime__ - __title__", 'filter' => { + # Only show recordings for today and tomorrow. 'startTime' => sub { my $date = substr(ParseDate($_[0]), 0, 8); return ! (($date cmp $today) == 0