#!/usr/bin/perl
use strict;
unless (@ARGV == 2) {
print <
new_shows.xml
usage
exit(0);
}
my %shows;
my $channel_list = shift @ARGV;
open (CHAN, "<$channel_list") or die "$! at $channel_list\n";
while () {
if (my ($chan,$station) = m/channel:\s+(\d+)\s+(.*)$/) {
$shows{$chan} = $station;
}
}
close CHAN;
my $show_list = shift @ARGV;
open (SHOWS, "<$show_list") or die "$! at $show_list\n";
while () {
if (m/channel="(\d+) (\w+)"/) {
if (exists $shows{$1}) {
my $new_station = $shows{$1};
s/channel="(\d+) (\w+)"/channel="$1 $new_station"/;
} else {
print STDERR "Channel unknown $1 $2\n";
}
}
print $_;
}
close SHOWS;
__END__
=head1 NAME sync_grab_check.pl
=head1 SYNOPSIS
Usage: sync_grab_check.pl grabber_config_file tv_check_show_file
Updates the channel names in the tv_check_show_file to
match those in the grabber_config_file.Outputs to STDOUT.
If a channel number is found in the tv_check_show_file that
does not exist in the grabber_config_file, a message is printed
to STDERR.
Example:
sync_grab_check.pl ~/.xmltv/tv_grab_na shows.xml >new_shows.xml
=head1 DESCRIPTION
Recently, every time I download my xmltv listings from Starchoice (a
Canadian satellite tv distributor), they've changed a bunch of the
channel names, and tv_check can't find anything anymore. Having
edited that file manually once, it totally lost it's charm the second
time, so I write a little perl script to do it for me.
So, the program reads your I xmltv config file, and remembers all
the channel numbers and channel names. Then it reads your tv_check
shows.xml file and modifies any data it finds in the B
element. It does not parse anything, it just uses regex's quick and
dirty, but it sure save me a lot of editing.
=head1 AUTHOR
Henry Laxen
http://www.maztravel.com/perl