# HG changeset patch # User Naoya OYAMA # Date 1346357564 -32400 # Node ID 036ae90f1b010090f55bf5379ba548132abd0383 # Parent a9f60d56d673f285156632da2d2c075fc25745a4 EXPERIMENTAL: Add channel scan script. require: epgdump, XML::Simple diff -r a9f60d56d673 -r 036ae90f1b01 src/Makefile --- a/src/Makefile Sat Aug 25 11:10:24 2012 +0900 +++ b/src/Makefile Fri Aug 31 05:12:44 2012 +0900 @@ -98,6 +98,8 @@ $(INSTALL) $(PROG) $(bindir) $(INSTALL) $(PROG2) $(bindir) $(INSTALL) $(PROG3) $(bindir) + $(INSTALL) channelscan_pt1.sh $(bindir) + $(INSTALL) epgdump_xml_parse.pl $(bindir) $(STRIP) $(INSTALLSTRIP) $(bindir)/$(PROG) $(STRIP) $(INSTALLSTRIP) $(bindir)/$(PROG2) $(STRIP) $(INSTALLSTRIP) $(bindir)/$(PROG3) diff -r a9f60d56d673 -r 036ae90f1b01 src/channelscan_pt1.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/channelscan_pt1.sh Fri Aug 31 05:12:44 2012 +0900 @@ -0,0 +1,92 @@ +#!/bin/bash +# channelscan_pt1.sh -- Scan channel info by TS. +# +# Copyright 2012 Naoya OYAMA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +TMP="/var/tmp" +ISDBT_Time="16" +BS_Time="60" +CS_Time="60" + +ISDBT_Info=~/.recpt1_ISDB +BS_Info=~/.recpt1_BS +CS_Info=~/.recpt1_CS + +for i in ${ISDBT_Info} ${BS_Info} ${CS_Info}; do + test -e "${i}" && rm -f "${i}" +done + +echo "Start ISDB-T scan." +for i in `seq 13 62` ; do + TSFILE="${TMP}/$i.ts" + XMLFILE="${TMP}/$i.xml" + recpt1 $i ${ISDBT_Time} "${TSFILE}" >/dev/null 2>&1 + epgdump $i "${TSFILE}" "${XMLFILE}" + if [ -e "${XMLFILE}" ] ; then + epgdump_xml_parse.pl "${XMLFILE}" >> ${ISDBT_Info} 2>/dev/null + rm -f "${TSFILE}" "${XMLFILE}" + else + rm -f "${TSFILE}" + fi +done + +echo "start BS scan." +TSFILE="${TMP}/BS.ts" +XMLFILE="${TMP}/BS.xml" +recpt1 101 ${BS_Time} "${TSFILE}" >/dev/null 2>&1 +epgdump /BS "${TSFILE}" "${XMLFILE}" +if [ -e "${XMLFILE}" ] ; then + epgdump_xml_parse.pl "${XMLFILE}" > ${BS_Info} 2>/dev/null + rm -f "${TSFILE}" "${XMLFILE}" +else + rm -f "${TSFILE}" +fi + +echo "start CS scan." +for i in `seq 1 12` ; do + i=$((i*2)); + TSFILE="${TMP}/CS.ts" + XMLFILE="${TMP}/CS.xml" + recpt1 CS$i ${CS_Time} "${TSFILE}" > /dev/null 2>&1 + epgdump /CS "${TSFILE}" "${XMLFILE}" + if [ -e "${XMLFILE}" ] ; then + epgdump_xml_parse.pl "${XMLFILE}" >> ${CS_Info} 2>/dev/null + rm -f "${TSFILE}" "${XMLFILE}" + else + rm -f "${TSFILE}" + fi +done +if [ -e ${CS_Info} ] ; then + sort -n ${CS_Info} | uniq > ${CS_Info}.tmp + mv -f ${CS_Info}.tmp ${CS_Info} +fi + +test -e ~/.recpt1-channels && mv ~/.recpt1-channels ~/.recpt1-channels_`date +%Y%m%d%H%M%S` +if [ -e ${ISDB_Info} ] ; then +echo ---------------------ISDB-T------------------------ > ~/.recpt1-channels +echo SID,channel,name >> ~/.recpt1-channels +cat ${ISDBT_Info} >> ~/.recpt1-channels +fi +if [ -e ${BS_Info} ] ; then +echo -----------------------BS-------------------------- >> ~/.recpt1-channels +echo SID,channel,name >> ~/.recpt1-channels +cat ${BS_Info} >> ~/.recpt1-channels +fi +if [ -e ${CS_Info} ] ; then +echo -----------------------CS-------------------------- >> ~/.recpt1-channels +echo SID,channel,name >> ~/.recpt1-channels +cat ${CS_Info} >> ~/.recpt1-channels +fi diff -r a9f60d56d673 -r 036ae90f1b01 src/epgdump_xml_parse.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/epgdump_xml_parse.pl Fri Aug 31 05:12:44 2012 +0900 @@ -0,0 +1,63 @@ +#!/usr/bin/perl -w +# epgdmp_xml_parse.pl -- parse epgdump XML file. +# +# Copyright 2012 Naoya OYAMA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; +use XML::Simple; + +my $simple = XML::Simple->new (ForceArray => 1, KeepRoot => 1); +my $data = $simple->XMLin($ARGV[0]); + +my @base = @{$data->{tv}}; +my %tv = %{$base[0]}; +my %channels = %{$tv{channel}}; +my %channel_info_list = (); +my @service_id_list = (); + +while (my ($channelType, $channelRef) = each %channels) { + my %channel = %$channelRef; + my $service_id = $channel{service_id}; + my @si = (); + my %sih = (); + my $tp = ""; + + if (defined($channel{satelliteinfo})) { + @si = @{$channel{satelliteinfo}}; + %sih = %{$si[0]}; + $tp = $sih{TP}[0]; + if($tp =~ m/^BS\d+$/) { + $tp = $service_id; + } + } else { + $tp = $ARGV[0]; + $tp =~ s/^.*\/(\d+)\.xml$/$1/; + } + my @dpna = @{$channel{"display-name"}}; + my %dpnh = %{$dpna[0]}; + + $channel_info_list{$service_id}{SID} = $service_id; + $channel_info_list{$service_id}{TP} = $tp; + $channel_info_list{$service_id}{NAME} = $dpnh{content}; + push(@service_id_list, $service_id); +} + +foreach my $service_id (sort {$a <=> $b} @service_id_list) { + print $channel_info_list{$service_id}{SID} . ","; + print $channel_info_list{$service_id}{TP} . ","; + print $channel_info_list{$service_id}{NAME} . "\n"; +} +1;