2007-11-28 Andrew Ruthven
Be more wary about processing what the backend has sent us.
+ Add support for reading XML from a file.
2007-11-23 Andrew Ruthven
Don't set the background when changing the colour.
my @email;
my $email_only_on_conflict = 0;
my $help = undef;
+my $xml_file = undef;
my $VERSION = '0.5.1';
'schedule-conflicts!' => \$display{'Schedule Conflicts'},
'next-recording!' => \$display{'Time till next recording'},
+ 'file=s' => \$xml_file,
+
'help|?' => \$help,
) || pod2usage("\nUse --help for help.\n");
# Fetch the XML status from the backend.
sub load_xml {
- my $url = "http://$host:$port/xml";
- my $status = get($url);
+ my $status = "";
+
+ if (defined $xml_file) {
+ open (IN, "< $xml_file")
+ || die "Failed to open $xml_file for reading: $!\n";
- die "Sorry, failed to fetch $url.\n"
- unless defined $status;
+ $status = join("", <IN>);
+
+ close IN;
+ } else {
+ my $url = "http://$host:$port/xml";
+ $status = get($url);
+
+ die "Sorry, failed to fetch $url.\n"
+ unless defined $status;
+ }
# Parse the XML
my $parser = XML::LibXML->new();
my $xml = eval { $parser->parse_string( $status ) };
if ($@) {
- die "Failed to parse XML from $url: $@\n";
+ die "Failed to parse XML: $@\n";
}
return $xml;
Display help.
+=item B<< --file <file> >>
+
+Load XML from the file specified instead of querying a MythTV backend.
+Handy for debugging things.
+
=item B<-h HOST, --host=HOST>
The host to check, defaults to localhost.