#!/usr/bin/perl -w # # =head1 NAME tv_grab_nz - Grab TV listings for New Zealand. =head1 SYNOPSIS tv_grab_nz [--help] [--output FILE] [--days N] [--channels ter/sky] =head1 DESCRIPTION Output TV listings for the nationwide channels available in New Zealand. The data comes from mr.geek.nz/epg and is not obtained via screen scraping. The default is to grab 7 days worth of programming B<--output FILE> write to FILE rather than standard output. B<--days N> grab N days starting from today, rather than the default of 7 B<--channels ter/sky> Grab Terrestrial or Sky TV channels, ter is the default. =head1 SEE ALSO L, L =head1 AUTHOR Drew Whittle, talk@mr.geek.nz =head1 BUGS UPDATE: I quickly butchered my old grabber to make this new one, it's lean, it's mean, and it's BAD(ly coded). =cut use strict; use LWP::Simple; use Getopt::Long; use XML::Writer; use IO::File; use XMLTV; use XMLTV::Memoize; use XMLTV::Usage < \$opt_days, 'help' => \$opt_help, 'output=s' => \$opt_output, 'channels=s' => \$opt_channels, 'configure' => \$opt_configure, 'config-file=s' => \$opt_configfile) or usage(0); usage(1) if $opt_help; if (defined $opt_output) { $fh = new IO::File (">$opt_output"); die "cannot write to $opt_output\n" if not $fh; }; if (defined $opt_configure) { $fh = new IO::File (">$opt_configfile"); print $fh "channel 1 TV 1\n"; undef $fh; } $document = get("http://mr.geek.nz/epg/getlist.html?channels=$opt_channels&days=$opt_days"); if (defined $opt_output) { print $fh $document; undef $fh; } else { print $document; };