#!/bin/sh version=0.1.3-pre4 check_xml=/rita/scripts/check_xml.sh rm_ok=1 prog_data_lnum=10 gnp_log=gnp.log echo -n >$gnp_log if [ -f /etc/iepgd.conf ];then . /etc/iepgd.conf fi if [ -f .iepgd.conf ];then . $PWD/.iepgd.conf fi get_nx_prog() { nxrx=$1 gnp_xml=$2 gnp_rv=-1 gnp_i=$prog_data_lnum while [ $gnp_rv != 0 ];do gnp_prv=`grep -m1 -A$gnp_i "$nxrx" $gnp_xml |grep -m1 -B$gnp_i '</programme>'` ;gnp_rv=$? if [ $gnp_rv = 0 ];then echo "$gnp_prv" else if [ $gnp_i -gt 31 ];then break fi gnp_i=$(($gnp_i+10)) fi done return $gnp_rv } err_xml=$* res="" res_x="" p=0 e0_xml="" err_list="" ch_list_pre="" for t in $err_xml ;do if [ -s $t ];then if [ "$e0_xml" ];then if [ "$err_list" ];then err_list="$err_list $t" else err_list=$t fi while read st_id ;do res_x="" prog_ex_st=`grep -m1 '<programme .*channel="'$st_id $t` if [ "$prog_ex_st" ];then prog_ex_st=${prog_ex_st#*start=\"} prog_ex_st=${prog_ex_st%% *} prog_1_st=`grep -m1 '<programme .*channel="'$st_id $e0_xml` if [ "$prog_1_st" ];then prog_1_st=${prog_1_st#*start=\"} prog_1_st=${prog_1_st%% *} else res_y="" while read l ;do add_e0=`get_nx_prog "$l" $t` if [ "$res_y" ];then res_y="$res_y $add_e0" else res_y=$add_e0 fi done <<EOF_wr5309fgeu `grep '<programme .*channel="'$st_id $t` EOF_wr5309fgeu fl=`grep -m1 "<programme start=" $e0_xml` if [ "$fl" ];then ed -s $e0_xml >/dev/null 2>&1 <<EOF_G47vhzf8 /$fl i $res_y . w $e0_xml_org.$p q EOF_G47vhzf8 else echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <!DOCTYPE tv SYSTEM \"xmltv.dtd\"> <tv generator-info-name=\"tsEPG2xml\" generator-info-url=\"http://localhost/\"> $res_y </tv>" >$e0_xml_org.$p fi if [ $rm_ok = 1 ]&&[ $e0_xml != $e0_xml_org ];then rm $e0_xml fi e0_xml=$e0_xml_org.$p p=$(($p+1)) continue fi else continue fi if [ $prog_ex_st -lt $prog_1_st ];then while read l ;do l=${l//$'\r'/} check_et=${l#*stop=\"} check_et=${check_et%% *} if [ $check_et -gt $prog_1_st ];then break else res=`get_nx_prog "$l" $t` if [ "$res_x" ];then res_x="$res_x $res" else res_x=$res fi fi done <<EOF_g78hfHH `grep '<programme .*channel="'$st_id $t` EOF_g78hfHH ed -s $e0_xml >/dev/null 2>&1 <<EOF_fgy83615 /start="$prog_1_st.*channel="$st_id i $res_x . w $e0_xml_org.$p q EOF_fgy83615 if [ $rm_ok = 1 ]&&[ $e0_xml != $e0_xml_org ];then rm $e0_xml fi e0_xml=$e0_xml_org.$p p=$(($p+1)) fi prog_Lx_et=`tac $t |grep -m1 '<programme .*channel="'$st_id` prog_Lx_et=${prog_Lx_et#*stop=\"} prog_Lx_et=${prog_Lx_et%% *} prog_L_et=`tac $e0_xml |grep -m1 '<programme .*channel="'$st_id` prog_L_et=${prog_L_et#*stop=\"} prog_L_et=${prog_L_et%% *} if [ $prog_Lx_et -gt $prog_L_et ];then while read l ;do l=${l//$'\r'/} check_st=${l#*start=\"} check_st=${check_st%% *} if [ $check_st -lt $prog_L_et ];then break else res=`get_nx_prog "$l" $t` if [ "$res_x" ];then res_x="$res $res_x" else res_x=$res fi fi done <<EOF_g7u5dhf4G `tac $t |grep '<programme .*channel="'$st_id` EOF_g7u5dhf4G ed -s $e0_xml >/dev/null 2>&1 <<EOF_g6xc433 /stop="$prog_L_et.*channel="$st_id /<\/programme> a $res_x . w $e0_xml_org.$p q EOF_g6xc433 if [ $rm_ok = 1 ]&&[ $e0_xml != $e0_xml_org ];then rm $e0_xml fi e0_xml=$e0_xml_org.$p p=$(($p+1)) fi done <<EOF_LL8dgT5 $ch_list_pre EOF_LL8dgT5 else e0_xml=$t e0_xml_org=$e0_xml bc_type=`echo ${e0_xml##*/} |cut -d'.' -f3` if [ $bc_type = bs ];then for s in `grep ^2 /malva/iepg/STATION.ID |cut -d: -f1` ;do if [ "$ch_list_pre" ];then ch_list_pre="$ch_list_pre ${s/200/4}" else ch_list_pre=${s/200/4} fi done else ch_list_pre=$bc_type fi fi fi done for t in $err_list ;do e0_err=`$check_xml -x $e0_xml 2>&1` for x in $e0_err ;do err_st=`echo $x |cut -d':' -f2` err_et=`echo $x |cut -d':' -f3` err_id=`echo $x |cut -d':' -f4` if [ ${err_id:0:1} = 1 ];then st_id=$err_id elif [ "${err_id//[0-9]/}" ];then continue else st_id=4${err_id:3:3} fi res="" res_x="" res_fin=0 while read l ;do l=${l//$'\r'/} if [ ! "$l" ];then continue fi check_st=${l#*start=\"} check_st=${check_st%% *} check_et=${l#*stop=\"} check_et=${check_et%% *} if [ $check_st -ge $err_st ];then if [ $check_et -le $err_et ];then if [ "$res" ];then res="$res $l" else res=$l fi else res_fin=1 fi if [ $res_fin = 1 ];then if [ "$res" ];then while read f ;do res_x_p=`get_nx_prog "$f" $t` if [ "$res_x" ];then res_x="$res_x $res_x_p" else res_x="$res_x_p" fi done <<EOF__Mn77fAai $res EOF__Mn77fAai ed -s $e0_xml >/dev/null 2>&1 <<EOF_m_nj9I74 /stop="$err_st.*channel="$st_id /<\/programme> a $res_x . w $e0_xml_org.$p EOF_m_nj9I74 if [ $rm_ok = 1 ]&&[ $e0_xml != $e0_xml_org ];then rm $e0_xml fi e0_xml=$e0_xml_org.$p p=$(($p+1)) fi break fi fi done <<EOF__7fiqfe `grep '<programme .*channel="'$st_id $t` EOF__7fiqfe done done if [ "$e0_xml" ];then $check_xml $e0_xml >/dev/null 2>&1 ;cv=$? echo $e0_xml fi exit $cv --- txt.cgi-0.1.5