Feature #1632 ยป fixChannelNumbers.pl
1 |
#!/usr/bin/perl
|
---|---|
2 |
|
3 |
# read all mapped tvheadend channels
|
4 |
my @hts_channels = `grep '"name"' /home/xbmc/.hts/tvheadend/channels/* | sed 's/://g' | cut -d'"' -f1,4 | sort -k2 | sed 's/\t"/<->/g'`; |
5 |
$i=0; |
6 |
my $prevChannelName=''; |
7 |
foreach my $line (@hts_channels) { |
8 |
my ($fileid, $htsChannelName) = split("<->",$line); |
9 |
chomp($htsChannelName); |
10 |
if ($htsChannelName ne $prevChannelName) { |
11 |
$prevChannelName=$htsChannelName; |
12 |
$i++; |
13 |
}
|
14 |
# For each channel list all xmltv references
|
15 |
printf("\n$htsChannelName - $fileid" ); |
16 |
system("cat $fileid | grep -v '\"channel_number\"' > $fileid.tmp; rm $fileid"); |
17 |
open(IN, "<$fileid.tmp"); |
18 |
open(OUT, ">$fileid"); |
19 |
while(<IN>) { |
20 |
my($line) = $_; |
21 |
if ($line =~ m/"dvr_extra_time_post"/) { |
22 |
print OUT $line; |
23 |
print OUT "\t\"channel_number\": $i\n"; |
24 |
}
|
25 |
else { |
26 |
print OUT $line; |
27 |
}
|
28 |
}
|
29 |
close(IN); |
30 |
close(OUT); |
31 |
system("rm $fileid.*"); |
32 |
}
|