Last active
August 29, 2015 14:11
-
-
Save alext/73a1e279fc133956d08f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
if( scalar @ARGV < 1) { | |
die "Usage $0 config_file\n"; | |
} | |
my $channels_map_file = "$ENV{'HOME'}/.xmltv/supplement/tv_grab_uk_atlas/tv_grab_uk_atlas.map.channels.conf"; | |
my %channels = (); | |
unless(open CHANNELS, "< $channels_map_file") { | |
print STDERR "Failed to open channels map - $channels_map_file : $!\n"; | |
print STDERR "\nRun the grabber at least once before running this script to download the map files.\n"; | |
exit 1; | |
} | |
foreach my $line (<CHANNELS>) { | |
chomp $line; | |
next if $line =~ /^\s*$/; | |
next if $line =~ /^\s*#/; | |
my ($id, $xmlid, $comment) = ($line =~ /^map==([^=]+)==(\S+)\s*(?:#\s*(.*)\s*)?$/ ); | |
unless($id) { | |
print STDERR "Warn: Failed to match channels line '$line'\n"; | |
next; | |
} | |
$channels{$id} = [$xmlid, $comment]; | |
} | |
close CHANNELS; | |
open CONFIG, "< $ARGV[0]" or die "Failed to open config $ARGV[0]: $!"; | |
foreach my $line (<CONFIG>) { | |
unless($line =~ /^channel[=!](\S+)/) { | |
print $line; | |
next; | |
} | |
my ($lead, $id) = ($line =~ /^(channel[=!])(\S+)/); | |
print "$lead$id # $channels{$id}[0] # $channels{$id}[1]\n" | |
} | |
close CONFIG; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment