#!/bin/sh version=0.1.2-pre7 is_name=$HOSTNAME st_list=/malva/iepg/STATION.ID hr_out=1 ex_out=0 if [ "$1" = "-e" ];then hr_out=0 xml_org=$2 elif [ "$1" = "-x" ];then hr_out=0 ex_out=1 xml_org=$2 else xml_org=$1 fi pre_end="" prog_num=0 bs_id=`echo ${xml_org##*/} |cut -d'.' -f3` if [ ${bs_id:0:2} = bs ];then bs_list=`grep ^2 $st_list |cut -d':' -f1` for t in $bs_list ;do if [ "$ch_list" ];then ch_list="$ch_list 4${t:3:3}" else ch_list=4${t:3:3} fi done else ch_list="1" fi rvs=0 for x in $ch_list ;do prog_list=`grep -A1 '<programm.*channel="'$x $xml_org ` prog_list_num=`echo "$prog_list" |wc -l` if [ $prog_list_num -lt 12 ];then echo "unknown error occured, program too less, st_id=$x $prog_list_num" >&2 rv=32 rvs=$(($rvs|$rv)) break fi if [ $x = 1 ];then st_id=$bs_id else st_id=200${x:1} fi pre_start="" pre_end="" while read l ;do l=${l//$'\r'/} if [ "${l:0:8}" = "<program" ];then rv=0 p_start=${l##*start=\"} p_start=${p_start%% *} p_end=${l##*stop=\"} p_end=${p_end%% *} if [ "$pre_start" ];then if [ $pre_start -ge ${p_start:0:8}040000 ];then prog_num=$(($prog_num+1)) fi fi fi if [ "${l:0:6}" = "<title" ];then pt=${l#'<title lang="ja_JP">'} pt=${pt%'</title>'} if [ "$pre_end" ];then if [ $pre_end != $p_start ];then if [ "$pre_pt" = エンディング ]&&[ "$pt" = オープニング ];then rv=0 if [ $ex_out = 1 ];then echo $rv:$pre_end:$p_start:$st_id >&2 fi elif [ "$pre_pt" = GC番宣・ロゴ・カラーバー ]&&[ "$pt" = カラーバー・GCロゴ ];then rv=0 if [ $ex_out = 1 ];then echo $rv:$pre_end:$p_start:$st_id >&2 fi elif [ "$pre_pt" = クロージング ]&&[ ! "${pt##*オープニング*}" ];then rv=0 if [ $ex_out = 1 ];then echo $rv:$pre_end:$p_start:$st_id >&2 fi else renew_t=${pre_end:0:8}040000 if [ $pre_end -ge $renew_t ];then if [ $x = 1 ];then pre_end_HMS=060000 else pre_end_HMS=070000 fi if [ $p_start -ge ${pre_end:0:8}$pre_end_HMS ];then rv=1 elif [ $pre_start -ge $renew_t ];then rv=2 else pre_end_Ymd=${pre_end:0:8} pre_end_H=${pre_end:8:2} pre_end_M=${pre_end:10:2} pre_et="$pre_end_Ymd $pre_end_H:$pre_end_M" p_start_w=`date -d $pre_end_Ymd '+%w'` if [ $p_start_w = 1 ]||[ $x != 1 ];then w_span=60 else w_span=40 fi p_start_n=`date -d "$pre_et ${w_span}minutes" '+%Y%m%d%H%M'00` if [ $p_start -gt $p_start_n ];then rv=4 fi fi else pre_end_Ymd=${pre_end:0:8} pre_end_H=${pre_end:8:2} pre_end_M=${pre_end:10:2} pre_et="$pre_end_Ymd $pre_end_H:$pre_end_M" if [ $x = 1 ];then pre_end_w=`date -d $pre_end_Ymd '+%w'` if [ $pre_end_w = 1 ];then s_span=180 else s_span=120 fi else s_span=360 fi p_start_n=`date -d "$pre_et ${s_span}minutes" '+%Y%m%d%H%M'00` if [ $p_start -gt $p_start_n ];then rv=8 else if [ $x = 1 ];then pre_end_HMS=060000 else pre_end_HMS=070000 fi if [ $p_start -gt ${pre_end:0:8}$pre_end_HMS ];then rv=16 fi fi fi if [ $rv -gt 0 ];then if [ $hr_out = 1 ];then echo $rv:$st_id:$pre_pt:$pre_start:$pre_end:$pt:$p_start >&2 else echo $rv:$pre_end:$p_start:$st_id >&2 fi else if [ $hr_out = 1 ];then echo $rv:$st_id:$pre_pt:$pre_start:$pre_end:$pt:$p_start >&2 else if [ $ex_out = 1 ];then echo $rv:$pre_end:$p_start:$st_id >&2 fi fi fi fi fi fi pre_end=$p_end pre_start=$p_start pre_pt=$pt rvs=$(($rvs|$rv)) fi done <<EOF_fuie824 $prog_list EOF_fuie824 rec_date=`echo ${xml_org##*/} |cut -d'.' -f2` # xml_end=`date -d "${rec_date:0:8} 8day" '+%Y%m%d%H%M'` xml_end=`date -d "${rec_date:0:8} 7day" '+%Y%m%d2300'` if [ $p_end -lt ${xml_end}00 ];then rv=64 rvs=$(($rvs|$rv)) if [ $hr_out = 1 ];then echo $rv:$st_id:$pt:$p_start:$p_end:xml_end=${xml_end}00 >&2 else if [ $ex_out = 1 ];then echo $rv:$p_end:${xml_end}00:$st_id >&2 fi fi fi done exit $rvs --- txt.cgi-0.1.5