Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: XXP / xmltv epg fetch



Hi,

for those using xmltv2vdr this script generates a xmltv
file for one week of the xxp programme, but please
be aware that xmltv2vdr.pl needs one patch/fix,
you have to remove the line which clears the epg,
in case u import more than one xml file (search for "CLRE").

Regards Onno

use like the other grab scripts:
grab_xxp-tv_de.sh >xxp-tv_epg.xml
xmltv2vdr -c xxp-tv.channels.conf -x xxp-tv_epg.xml

xxp-tv.channels.conf is for xmltv2vdr and has only this line:
XXP:12633:h:S19.2E:22000:203:303:203:0:12602:0:0:0:xxp.tv


Carsten Günther schrieb:
XXP:12633:h:S19.2E:22000:203:303:203:0:12602:0:0:0

Gruß,
C.Günther




#!/bin/sh
#set -xv
LYNX="/usr/bin/lynx"
WEEKDAYS="mo di mi do fr sa so"
#WEEKDAYS="mo"
BASEURL="http://www.xxp.tv/programm";
CT=0

#write xml header
echo '<?xml version="1.0" encoding="UTF-8"?>'
echo '<!DOCTYPE tv SYSTEM "xmltv.dtd">'
echo -e "<tv date=\"$(date +%Y%m%d%H%M) CEST\" generator-info-name=\"VDRUSER\" generator-info-url=\"http://nope.not\";>"
echo '  <channel id="xxp.tv">' 
echo '    <display-name>XXP.TV</display-name>'
echo '  </channel>'


#first get weekday to work on
for d in $WEEKDAYS
    do
	#fetch it, and parse the days program
	TEXT1="$($LYNX -dump $BASEURL/$d|grep -B 1 -C 900 "Tagesthema"|grep -C 0 -B 900 "DRUCKVERSION"|sed 's/\[[0-9][0-9]\]//g'|grep -v Tagesthema|grep -v DRUCKVERSION)"
	#get date from first line
	DATE_STRING="$(echo "$TEXT1"|head -n1|sed 's/^ *//g;s/ *$//g')"
	#make all text one line and set separators for event, title and starttime
	TEXT2="$(echo -e "$TEXT1"|sed '1d;s/^ *[0-9][0-9]:[0-9][0-9].*/&#/g;s/$/|/g;s/^ *//g')"
	#part 2
	TEXT3="$(echo $TEXT2|sed 's/^ *//g;s/   //g;s/  / /g;s/| | |/#/g;s/|//g')"
	
	#get number of separators
	EVENT_COUNT="$(expr $(echo -e "$TEXT3"|sed 's/[^#]//g'|wc -c|sed 's/ //g') \/ 2)"
	
	
	#get month day and year from DATE_STRING
	DAY="$(echo $DATE_STRING|cut -f3 -d" "|sed 's/\.//g')"
	YEAR="$(echo $DATE_STRING|cut -f5 -d" ")"
	MONTH_STRING="$(echo $DATE_STRING|cut -f4 -d" ")"	
		case "$MONTH_STRING" in
                        Jan*)
                        MONTH=01;DOM=31
                        ;;
                        Feb*)
                        MONTH=02;DOM=29
                        ;;
                        Mär*)
                        MONTH=03;DOM=31
                        ;;
                        Apr*)
                        MONTH=04;DOM=30
                        ;;
                        Mai)
                        MONTH=05;DOM=31
                        ;;
                        Jun*)
                        MONTH=06;DOM=30
                        ;;
                        Jul*)
                        MONTH=07;DOM=31
                        ;;
                        Aug*)
                        MONTH=08;DOM=31
                        ;;
                        Sep*)
                        MONTH=09;DOM=30
                        ;;
                        Okt*)
                        MONTH=10;DOM=31
                        ;;
                        Nov*)
                        MONTH=11;DOM=30
                        ;;
                        Dez*)
                        MONTH=12;DOM=31
                        ;;
		esac

	OLD_EPG_START=
	unset OLD_EPG_START 
	
	NEXTDAY=1
		
	while [ $EVENT_COUNT -ne 0 ]
	   do
		EVENT_POS=$(expr $EVENT_COUNT \* 2)
		TITLE_POS=$(expr $EVENT_POS \- 1)
		EVENT="$(echo "$TEXT3"|cut -d# -f${TITLE_POS}-${EVENT_POS})"
		
		START_HOURMINUTE="$(echo "$EVENT"|sed 's/^ *[0-9][0-9]:[0-9][0-9]/&#/'|cut -f1 -d#|sed 's/ //g;s/://g')"
		EPG_START="${YEAR}${MONTH}${DAY}${START_HOURMINUTE}"

		TITLE="$(echo "$EVENT"|cut -f1 -d#|sed 's/^ *[0-9][0-9]:[0-9][0-9]//g;s/^ //g')"
		DESC="$(echo "$EVENT"|cut -f2 -d#|sed 's/^ //g')"

		[ -n $NEXTDAY ] && [ $START_HOURMINUTE -gt 600 ] && unset NEXTDAY
		[ -z $NEXTDAY ] || EPG_START="200$(expr $(echo $EPG_START|sed 's/200//') \+ 10000)"
		[ -n $NEXTDAY ] && [ $(echo $EPG_START|sed 's/^200//') -gt 3${MONTH}${DOM}9999 ] && EPG_START="200$(expr $(echo $EPG_START|sed 's/^200//') \- ${DOM}0000 \+ 1000000)"

		[ -z "$OLD_EPG_START" ] && OLD_EPG_START="200$(expr 15 \+ $(echo $EPG_START|sed 's/200//'))"
		EPG_STOP="$OLD_EPG_START"
		OLD_EPG_START="$EPG_START"
		
		#output xml
		echo -e "  <programme start=\"$EPG_START CEST\" stop=\"$EPG_STOP CEST\" channel=\"xxp.tv\">"
		echo -e "    <title>$TITLE</title>"
		echo -e "    <desc>$DESC</desc>"
		echo -e "  </programme>"

		CT=$(expr $CT \+ 1)
		EVENT_COUNT=$(expr $EVENT_COUNT \- 1)
		
	   done
	unset OLD_EPG_START

echo '</tv>'
done
unset TEXT1 TEXT2 TEXT3

Home | Main Index | Thread Index