annotate src/epgdump_xml_parse.pl @ 158:6fab243c91ab

Fix problem BS-17 can not be recorded.
author Naoya OYAMA <naoya.oyama@gmail.com>
date Mon, 10 Sep 2012 20:32:20 +0900
parents 2c1cec3c5d64
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
1 #!/usr/bin/perl -w
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
2 # epgdmp_xml_parse.pl -- parse epgdump XML file.
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
3 #
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
4 # Copyright 2012 Naoya OYAMA <naoya.oyama@gmail.com>
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
5 #
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
6 # This program is free software: you can redistribute it and/or modify
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
7 # it under the terms of the GNU General Public License as published by
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
8 # the Free Software Foundation, either version 3 of the License, or
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
9 # (at your option) any later version.
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
10 #
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
11 # This program is distributed in the hope that it will be useful,
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
14 # GNU General Public License for more details.
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
15 #
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
16 # You should have received a copy of the GNU General Public License
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
18
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
19 use strict;
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
20 use XML::Simple;
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
21
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
22 my $simple = XML::Simple->new (ForceArray => 1, KeepRoot => 1);
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
23 my $data = $simple->XMLin($ARGV[0]);
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
24
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
25 my @base = @{$data->{tv}};
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
26 my %tv = %{$base[0]};
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
27 my %channels = %{$tv{channel}};
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
28 my %channel_info_list = ();
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
29 my @service_id_list = ();
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
30
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
31 while (my ($channelType, $channelRef) = each %channels) {
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
32 my %channel = %$channelRef;
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
33 my $service_id = $channel{service_id};
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
34 my @si = ();
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
35 my %sih = ();
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
36 my $tp = "";
157
2c1cec3c5d64 out put BS channel instead of SID and "transponder_slot(BS1_1)"
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 150
diff changeset
37 my $slot = "";
150
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
38
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
39 if (defined($channel{satelliteinfo})) {
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
40 @si = @{$channel{satelliteinfo}};
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
41 %sih = %{$si[0]};
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
42 $tp = $sih{TP}[0];
157
2c1cec3c5d64 out put BS channel instead of SID and "transponder_slot(BS1_1)"
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 150
diff changeset
43 if ($tp =~ /BS/) {
2c1cec3c5d64 out put BS channel instead of SID and "transponder_slot(BS1_1)"
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 150
diff changeset
44 $slot = $sih{SLOT}[0];
150
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
45 }
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
46 } else {
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
47 $tp = $ARGV[0];
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
48 $tp =~ s/^.*\/(\d+)\.xml$/$1/;
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
49 }
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
50 my @dpna = @{$channel{"display-name"}};
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
51 my %dpnh = %{$dpna[0]};
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
52
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
53 $channel_info_list{$service_id}{SID} = $service_id;
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
54 $channel_info_list{$service_id}{TP} = $tp;
157
2c1cec3c5d64 out put BS channel instead of SID and "transponder_slot(BS1_1)"
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 150
diff changeset
55 if ($slot =~ /\d/) {
2c1cec3c5d64 out put BS channel instead of SID and "transponder_slot(BS1_1)"
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 150
diff changeset
56 $channel_info_list{$service_id}{SLOT} = "_" . $slot;
2c1cec3c5d64 out put BS channel instead of SID and "transponder_slot(BS1_1)"
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 150
diff changeset
57 }
150
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
58 $channel_info_list{$service_id}{NAME} = $dpnh{content};
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
59 push(@service_id_list, $service_id);
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
60 }
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
61
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
62 foreach my $service_id (sort {$a <=> $b} @service_id_list) {
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
63 print $channel_info_list{$service_id}{SID} . ",";
157
2c1cec3c5d64 out put BS channel instead of SID and "transponder_slot(BS1_1)"
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 150
diff changeset
64 print $channel_info_list{$service_id}{TP} ;
2c1cec3c5d64 out put BS channel instead of SID and "transponder_slot(BS1_1)"
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 150
diff changeset
65 print $channel_info_list{$service_id}{SLOT} . ",";
150
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
66 print $channel_info_list{$service_id}{NAME} . "\n";
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
67 }
036ae90f1b01 EXPERIMENTAL: Add channel scan script.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff changeset
68 1;