diff -Nru vdr-addon-epgdata2vdr-0.0.1/channelmapper_epgdata2vdr vdr-addon-epgdata2vdr-0.0.1+svn20100714/channelmapper_epgdata2vdr --- vdr-addon-epgdata2vdr-0.0.1/channelmapper_epgdata2vdr 1970-01-01 01:00:00.000000000 +0100 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/channelmapper_epgdata2vdr 2010-07-14 14:10:55.000000000 +0100 @@ -0,0 +1,93 @@ +#!/bin/bash +# + +. /etc/vdr/epgdata2vdr.conf + +EPGDATA2VDR_CHANNELS=$WORKDIR/include/epgdata2vdr_channelmap.conf +CHANNELS_CONF=/etc/vdr/channels.conf +CHANNEL_XML=$WORKDIR/include/channel_y.xml +CHANNEL_CH0=/tmp/channel_CH0.info +CHANNEL_CH4=/tmp/channel_CH4.info +CHANNEL_CH11=/tmp/channel_CH11.info +CHANNEL_INFO=/tmp/channel.info +CHANNEL_INFO_SORT=/tmp/channel.info.sort + +rm $EPGDATA2VDR_CHANNELS > /dev/null 2>&1 + +cat $CHANNEL_XML | grep "" | cut -d'>' -f2 | cut -d'<' -f1 > $CHANNEL_CH0 +cat $CHANNEL_XML | grep "" | cut -d'>' -f2 | cut -d'<' -f1 > $CHANNEL_CH4 +cat $CHANNEL_XML | grep "" | cut -d'>' -f2 | cut -d'<' -f1 > $CHANNEL_CH11 + +Kanal_Auswahl() +{ + sort -u $CHANNEL_INFO > $CHANNEL_INFO_SORT + if [ $(wc -l <$CHANNEL_INFO_SORT) -eq 1 ]; then + EINGABE=`cat $CHANNEL_INFO_SORT | cut -d' ' -f1` + echo + echo "Zuordnung für Kanal \"$CHANNELNAME\"" + cat $CHANNEL_INFO_SORT + else + echo + echo "Zuordnung für Kanal \"$CHANNELNAME\"" + cat $CHANNEL_INFO_SORT + echo -n "Auswahl (Nummer) (Enter übergeht): "; read EINGABE + fi + + for AUSWAHL in $EINGABE; do + cat -n $CHANNELS_CONF | cut -d' ' -f1 | grep "$AUSWAHL" > /dev/null 2>&1 + if [ $? -eq 1 ]; then + echo "$AUSWAHL: falsche Eingabe" + return 1 + fi + done +} + +NUMMER=1 + +while [ $NUMMER -le $(wc -l <$CHANNEL_CH11) ]; do + CHANNELNAME=`head -n $NUMMER $CHANNEL_CH11 | tail -n1` + cat $CHANNELS_CONF | cut -d ';' -f1 | grep -i -n -T "$CHANNELNAME" \ + > $CHANNEL_INFO + CHANNELNAME=`head -n $NUMMER $CHANNEL_CH0 | tail -n1` + cat $CHANNELS_CONF | cut -d ';' -f1 | grep -i -n -T "$CHANNELNAME" \ + >> $CHANNEL_INFO + + unset CHANNEL_IDS + EPGDATA_NUM=`head -n $NUMMER $CHANNEL_CH4 | tail -n1` + + if [ $(wc -l <$CHANNEL_INFO) -gt 0 ]; then + while ! Kanal_Auswahl; do + /bin/true + done + + for AUSWAHL in $EINGABE; do + NAME=`head -n $AUSWAHL $CHANNELS_CONF | tail -n1 | cut -d':' -f1` + SOURCE=`head -n $AUSWAHL $CHANNELS_CONF | tail -n1 | cut -d':' -f4` + NID=`head -n $AUSWAHL $CHANNELS_CONF | tail -n1 | cut -d':' -f11` + TID=`head -n $AUSWAHL $CHANNELS_CONF | tail -n1 | cut -d':' -f12` + SID=`head -n $AUSWAHL $CHANNELS_CONF | tail -n1 | cut -d':' -f10` + + if [ -z "$CHANNEL_IDS" ]; then + CHANNEL_IDS="$SOURCE-$NID-$TID-$SID" + else + CHANNEL_IDS="$CHANNEL_IDS,$SOURCE-$NID-$TID-$SID" + fi + done + fi + + if [ -z "$CHANNEL_IDS" ]; then + echo "// $EPGDATA_NUM = // $CHANNELNAME" \ + >> $EPGDATA2VDR_CHANNELS + else + echo "$EPGDATA_NUM = $CHANNEL_IDS // $NAME" \ + >> $EPGDATA2VDR_CHANNELS + fi + + NUMMER=$((NUMMER + 1)) +done + +rm $CHANNEL_CH0 +rm $CHANNEL_CH4 +rm $CHANNEL_CH11 +rm $CHANNEL_INFO +rm $CHANNEL_INFO_SORT diff -Nru vdr-addon-epgdata2vdr-0.0.1/debian/changelog vdr-addon-epgdata2vdr-0.0.1+svn20100714/debian/changelog --- vdr-addon-epgdata2vdr-0.0.1/debian/changelog 2009-12-05 17:05:15.000000000 +0000 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/debian/changelog 2010-07-14 17:36:27.000000000 +0100 @@ -1,8 +1,8 @@ -vdr-addon-epgdata2vdr (0.0.1-1tvt4) karmic; urgency=low +vdr-addon-epgdata2vdr (0.0.1+svn20100714-2yavdr1) lucid; urgency=low - * Initial release (rev. 166) + * Initial release (rev. 180) - -- Holger Schvestka Tue, 01 Dec 2009 23:22:26 +0100 + -- Holger Schvestka Wed, 14 Jul 2010 14:56:26 +0100 diff -Nru vdr-addon-epgdata2vdr-0.0.1/epgdata2vdr_channelmap.conf vdr-addon-epgdata2vdr-0.0.1+svn20100714/epgdata2vdr_channelmap.conf --- vdr-addon-epgdata2vdr-0.0.1/epgdata2vdr_channelmap.conf 2009-12-05 17:02:22.000000000 +0000 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/epgdata2vdr_channelmap.conf 2010-07-14 14:10:55.000000000 +0100 @@ -50,6 +50,7 @@ 43 = S19.2E-1-1089-12040,S19.2E-1-1091-28815 // Super RTL,Super RTL A 44 = S19.2E-1-1107-17502,S19.2E-1-1082-20004,S19.2E-1-1082-20003 // kabel eins,Kabel 1 Austria,Kabel 1 Schweiz 42 = S19.2E-1-1089-12060,S19.2E-1-1091-28805 // VOX,VOX Austria +//694 = S19.2E-133-5-776 // SIXX;ProSiebenSat.1 486 = S19.2E-133-5-1793 // DAS VIERTE,D VIERTE;BetaDigital 277 = S19.2E-133-33-51 // TELE 5;BetaDigital //1179 = S19.2E-1-1107-17504 // 9Live;ProSiebenSat.1 @@ -121,7 +122,7 @@ // = S19.2E-133-9-67 // e.clips;SKY ??? //539 = S19.2E-1-1102-13203 // ANIMAX;arena/SKY //553 = S19.2E-1-1078-28681 // MTV ENTERTAINMENT (S);MTV Networks Europe ??? -496 = S19.2E-1-1066-28657 // VH1 Classic;MTV Networks Europe ??? +//496 = S19.2E-1-1066-28657 // VH1 Classic;MTV Networks Europe ??? //504 = S19.2E-1-1102-13205 // EuroSport 2 (a/S);arena/SKY //591 = S19.2E-1-1115-13105 // ESPN America (S);SKY //622 = S19.2E-133-7-53 // Sky Sport Austria,SportAut;SKY diff -Nru vdr-addon-epgdata2vdr-0.0.1/epgdata2vdr_clre.sh vdr-addon-epgdata2vdr-0.0.1+svn20100714/epgdata2vdr_clre.sh --- vdr-addon-epgdata2vdr-0.0.1/epgdata2vdr_clre.sh 1970-01-01 01:00:00.000000000 +0100 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/epgdata2vdr_clre.sh 2010-07-14 14:10:55.000000000 +0100 @@ -0,0 +1,195 @@ +#!/bin/bash + +# Einstellungen +. /etc/vdr/epgdata2vdr/epgdata2vdr.conf + +# Debugging +#set -x + +# Spracheinstellungen, damit Umlaute zum VDR passen, +# wenn dieser in einer anderen Einstellung läuft (z.B. wegen dem Sky-EPG) +export LANG=de_DE +export LC_COLLATE=de_DE + +[ -n "$1" ] && MAXDAYS=$1 # Anzahl der Tage kann auch manuell übergeben werden + +# Pfade zu den Programmen +CURL=/usr/bin/curl +EPGDATA2VDR=/usr/local/src/_div/epgdata2vdr/epgdata2vdr +SVDRPSEND=/usr/bin/svdrpsend.pl +MKDIR=/bin/mkdir +UNZIP=/usr/bin/unzip +SED=/bin/sed +SENDMAIL=/usr/sbin/sendmail +WC=/bin/wc + +# check config and install required files if necessary +if [ ! -n "$WORKDIR" ]; then + echo "Work directory undefined. Stopping." + exit 1 +fi + +if [ ! -n "$PIN" ]; then + echo "epgdata.com PIN is not configured" + exit 1 +fi + +if [ ! -e $WORKDIR/include/epgdata2vdr_channelmap.conf ]; then + echo "epgdata2vdr_channelmap.conf not found. Stopping." + exit 1 +fi + +if [ ! -d $WORKDIR/files ]; then + mkdir -p $WORKDIR/files +fi + +if [ ! -e $WORKDIR/include/genre.xml -o ! -e $WORKDIR/include/category.xml ]; then + mkdir -p $WORKDIR/include + if [ x$? != x0 ]; then + echo "$WORKDIR/include exists but is not a directory" + exit 1 + else + nice -n 19 $CURL "http://www.epgdata.com/index.php?action=sendInclude&iOEM=&pin=$PIN&dataType=xml" \ + -o $WORKDIR/include/include.zip + $UNZIP -o $WORKDIR/include/include.zip -d $WORKDIR/include + fi +fi + +# Delete old EPG-Images +if [ -e $WORKDIR/files/images/ ]; then + find $WORKDIR/files/images/* -type f -mtime +$MAXDAYS -print0 | xargs -0 rm -f +fi +# Also delete old symlinks (-L only broken symlinks) +[ -n "$EPGIMAGES" ] && find -L $EPGIMAGES/* -type l -print0 | xargs -0 rm -f + +# Put configured channels in array (first element is 0) +EPGDATA_CHANNELS=( $(grep '^[0-9]* = S.*//' $WORKDIR/include/epgdata2vdr_channelmap.conf | cut -d "$(echo -e "\t")" -f1 | sed 's/[0-9]* = //' | sed "s/,/ /g" | awk '{printf "%s ",$0;}') ) +#echo ${EPGDATA_CHANNELS[*]} +echo "${#EPGDATA_CHANNELS[*]} channels configured for EPGData2VDR" + +# Download and process files for EPG +for i in `seq 0 $MAXDAYS` ; do + echo "<--- Processing data with offset $i --->" + TMP=`mktemp` + nice -n 19 $CURL -I -D $TMP "http://www.epgdata.com/index.php?action=sendPackage&iOEM=VDR&pin=$PIN&dayOffset=$i&dataType=xml" &> /dev/null + FILE=`grep -e "^Content-disposition.*$" $TMP | $SED -e ' s/\r//g' | cut -d"=" -f2` + [ -z $FILE ] && echo "No Datafile found in Download" + FILE="`basename $FILE .zip`" + SIZE=`grep -e "^Content-Length.*$" $TMP | $SED -e ' s/\r//g' | cut -d":" -f2` + #AVAILABLE=`grep -e "^x-epgdata-packageAvailable.*$" $TMP | sed -e ' s/\r//g' | cut -d":" -f2` + [ -z $TIMEOUT ] && TIMEOUT=`grep -e "^x-epgdata-timeout.*$" $TMP | $SED -e ' s/\r//g' | cut -d":" -f2` + if [ -z $LEFT ] && [ -n "$TIMEOUT" ]; then + LEFT=$((( $TIMEOUT - $(date +%s)) / 60 / 60 / 24 )) # Days left (subscription) + fi + if [ ! -z $SIZE ]; then + if [ ! -e $WORKDIR/files/$FILE.zip ]; then + nice -n 19 $CURL "http://www.epgdata.com/index.php?action=sendPackage&iOEM=VDR&pin=$PIN&dayOffset=$i&dataType=xml" -o $WORKDIR/files/$FILE.zip #-v + rm $WORKDIR/files/$FILE.epg > /dev/null 2>&1 + else + if [ `ls -la $WORKDIR/files/$FILE.zip | cut -d" " -f5` != $SIZE ]; then + nice -n 19 $CURL "http://www.epgdata.com/index.php?action=sendPackage&iOEM=VDR&pin=$PIN&dayOffset=$i&dataType=xml" -o $WORKDIR/files/$FILE.zip #-v + rm $WORKDIR/files/$FILE.epg > /dev/null 2>&1 + else + echo "File: $FILE already downloaded" + fi + fi + ### process start ### + if [ -s $WORKDIR/files/$FILE.epg ]; then + echo "File: $FILE already processed" + NO_CLRE=1 # Do not delete EPG from VDR + else + if [ -e $WORKDIR/files/$FILE.zip ]; then + echo -e " File: $FILE Size: $(( $SIZE / 1024 )) kB" + #epgdata2vdr includedir epgimagesdir file(s) + nice -n 19 $EPGDATA2VDR $WORKDIR/include/ $EPGIMAGES $WORKDIR/files/$FILE.zip #> $WORKDIR/files/$FILE.epg + nice -n 19 $SED -i 's/\x97/-/g' $WORKDIR/files/$FILE.epg # Replace long "-" + # List of channels with data in epgfile + EPG_CHANNELS=( $(grep '^C *' $WORKDIR/files/$FILE.epg | sed 's/C //' | awk '{printf "%s ",$0;}') ) + #echo ${EPG_CHANNELS[*]} + echo "${#EPG_CHANNELS[*]} EPG entries found" + # Check if data exist for each configured channel + for chan in `seq 0 $(( ${#EPGDATA_CHANNELS[*]} -1 ))` ; do + if [ "${EPGDATA_CHANNELS[$chan]}" != "0" ] ; then # skip already failed channels + echo -n "Checking EPG for channel #$chan: "; echo ${EPGDATA_CHANNELS[$chan]} + ### Found? + NUM[$chan]=0 # Set to 0 to avoid empty fields + for entry in ${EPG_CHANNELS[*]} ; do # Is there some epgdata to import? + if [ $entry == ${EPGDATA_CHANNELS[$chan]} ] ; then + NUM[$chan]=$(( ${NUM[$chan]} +1 )) # Put in array (and count) + fi + done #entry + if [ "${NUM[$chan]}" = "0" ]; then + echo "!!> NO EPG ENTRIES FOUND!" + # Do not delete EPG from VDR's EPG.data! + EPGDATA_CHANNELS[$chan]=0 + else + echo "--> ${NUM[$chan]} EPG entries found" + fi + fi + done #chan + echo "==> ${NUM[*]} EPG entries found" + # Add epgfile to importlist (Will be processed later) + IMPORT_LIST[$i]=$FILE + else + echo "File: Failed to load $FILE" + NO_CLRE=1 # Do not delete EPG from VDR + fi + fi + fi + rm $TMP +done #i + +#echo "${#EPGDATA_CHANNELS[*]} channels configured for EPGData2VDR:" +#echo ${EPGDATA_CHANNELS[*]} + +# Delete old EPG from VDR's EPG.data +if [ -z $NO_CLRE ] ; then # Already procesd files or download error + for i in ${EPGDATA_CHANNELS[*]} ; do + if [ "$i" != "0" ] ; then + $SVDRPSEND CLRE $i # Delete EPG for channel + fi + done +fi + +# Import EPG +for i in ${IMPORT_LIST[*]} ; do + $SVDRPSEND PUTE $PUTECHAR$WORKDIR/files/$i.epg # Import EPG to VDR +done + +# Delete all but last set +for i in `find $WORKDIR/files/* -name "*$SUFFIX.zip" | cut -d"_" -f2 | sort -r | uniq | tail -n +2` ; do + echo "Cleanup files of : $i " + rm -f $WORKDIR/files/*$i$SUFFIX.epg + rm -f $WORKDIR/files/*$i$SUFFIX.zip +done + +if [ -n "$EMAIL" ]; then # To enable set $EMAIL in epgdata2vdr.conf + # Check if all files could be loaded (only works if MAXDAYS is less than 14) + NUMFILES=$(($(ls $WORKDIR/files/*.zip | wc -l))) + if [ $NUMFILES -lt $(($MAXDAYS +1)) ] && [ $MAXDAYS -lt 14 ] || [ "$LEFT" -lt "5" ]; then + echo "<--- Sending email about missing files / ending subscription --->" + echo "From: \"EPGData2VDR-Skript\"<$EMAIL>" > /tmp/mail.txt + echo "T0: $EMAIL" >> /tmp/mail.txt + if [ "$LEFT" -lt "5" ]; then # Subscription is ending... + echo "Subject: EPGData.com Abo endet in $LEFT Tag(en)!" >> /tmp/mail.txt + echo "" >> /tmp/mail.txt + echo "Das Abo bei EPGData.com hat noch eine Laufzeit von $LEFT Tag(en)" >> /tmp/mail.txt + echo "und endet danach automatisch! Ein neues Abo kann unter" >> /tmp/mail.txt + echo "http://www.epgdata.com/index.php?action=newSubscription&iLang=de&iOEM=vdr&iCountry=de&popup=0" >> /tmp/mail.txt + echo "abgeschlossen werden. Das neue Abo startet sofort nach Bezahlung!" >> /tmp/mail.txt + else + echo "Subject: Fehler beim laden von EPGData.com!" >> /tmp/mail.txt + echo "" >> /tmp/mail.txt + echo "Beim Download von EPGData.com konnten nicht alle Daten" >> /tmp/mail.txt + echo "geladen werden. Hinweis: Das Abo endet in $LEFT Tag(en)" >> /tmp/mail.txt + echo "" >> /tmp/mail.txt + echo "Es wurde(n) $NUMFILES von $(($MAXDAYS +1)) Datei(en) geladen!" >> /tmp/mail.txt + fi + echo "" >> /tmp/mail.txt + echo "Inhalt von $WORKDIR/files:" >> /tmp/mail.txt + ls -l $WORKDIR/files >> /tmp/mail.txt + $SENDMAIL $EMAIL < /tmp/mail.txt + fi +fi + +exit diff -Nru vdr-addon-epgdata2vdr-0.0.1/epgdata2vdr.conf vdr-addon-epgdata2vdr-0.0.1+svn20100714/epgdata2vdr.conf --- vdr-addon-epgdata2vdr-0.0.1/epgdata2vdr.conf 2009-12-05 17:02:22.000000000 +0000 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/epgdata2vdr.conf 2010-07-14 14:10:55.000000000 +0100 @@ -3,3 +3,5 @@ MAXDAYS=30 # load until no files available or MAXDAYS PUTECHAR="" # @for patched PUTE "" for vdr >= 1.7.6 EPGIMAGES=/var/cache/vdr/epgimages # Auskommentieren, wenn keine EPG-Bilder gewünscht +SUFFIX=_de_qy # Suffix (needed for file deletion) +#EMAIL= # Set to your eMail-Adress to get info when abo ends diff -Nru vdr-addon-epgdata2vdr-0.0.1/epgdata2vdr.sh vdr-addon-epgdata2vdr-0.0.1+svn20100714/epgdata2vdr.sh --- vdr-addon-epgdata2vdr-0.0.1/epgdata2vdr.sh 2009-12-05 17:02:22.000000000 +0000 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/epgdata2vdr.sh 2010-07-14 14:10:55.000000000 +0100 @@ -7,12 +7,14 @@ SVDRPSENDBIN=/usr/bin/svdrpsend CURLBIN=/usr/bin/curl UNZIPBIN=/usr/bin/unzip +SENDMAIL=/usr/sbin/sendmail +WC=/bin/wc # install required files if necessary + create directories -if [ ! -n "$WORKDIR" ]; then +if [ ! -n "$WORKDIR" ]; then echo "Work directory undefined. Stopping." exit 1 -fi +fi if [ ! -n "$PIN" ]; then echo "epgdata.com PIN is not configured. Stopping" @@ -25,62 +27,104 @@ fi if [ ! -d $WORKDIR/files ]; then - mkdir -p $WORKDIR/files + mkdir -p $WORKDIR/files fi -if [ ! -e $WORKDIR/include/genre.xml -o ! -e $WORKDIR/include/category.xml ]; then - mkdir -p $WORKDIR/include - if [ x$? != x0 ]; then - echo "$WORKDIR/include exists but is not a directory" - exit 1 - else - $CURLBIN "http://www.epgdata.com/index.php?action=sendInclude&iOEM=&pin=$PIN&dataType=xml" \ - -o $WORKDIR/include/include.zip - $UNZIPBIN -o $WORKDIR/include/include.zip -d $WORKDIR/include - fi +if [ ! -e $WORKDIR/include/genre.xml -o ! -e $WORKDIR/include/category.xml ]; then + mkdir -p $WORKDIR/include + if [ x$? != x0 ]; then + echo "$WORKDIR/include exists but is not a directory" + exit 1 + else + nice -n 19 $CURLBIN "http://www.epgdata.com/index.php?action=sendInclude&iOEM=&pin=$PIN&dataType=xml" \ + -o $WORKDIR/include/include.zip + $UNZIPBIN -o $WORKDIR/include/include.zip -d $WORKDIR/include + fi fi +# Delete old EPG-Images +if [ -e $WORKDIR/files/images/ ]; then + find $WORKDIR/files/images/* -type f -mtime +$MAXDAYS -print0 | xargs -0 rm -f +fi +# Also delete old symlinks (-L only broken symlinks) +[ -n "$EPGIMAGES" ] && find -L $EPGIMAGES/* -type l -print0 | xargs -0 rm -f + +# process data for i in `seq 0 $MAXDAYS` ; do - TMP=`mktemp` - $CURLBIN -I -D $TMP "http://www.epgdata.com/index.php?action=sendPackage&iOEM=VDR&pin=$PIN&dayOffset=$i&dataType=xml" &> /dev/null - FILE=`grep -e "^Content-disposition.*$" $TMP | sed -e ' s/\r//g' | cut -d"=" -f2` - FILE="`basename $FILE .zip`" - SIZE=`grep -e "^Content-Length.*$" $TMP | sed -e ' s/\r//g' | cut -d":" -f2` - if [ ! -z $SIZE ]; then - if [ ! -e $WORKDIR/files/$FILE.zip ]; then - $CURLBIN "http://www.epgdata.com/index.php?action=sendPackage&iOEM=VDR&pin=$PIN&dayOffset=$i&dataType=xml" -o $WORKDIR/files/$FILE.zip - rm $WORKDIR/files/$FILE.epg > /dev/null 2>&1 - else - if [ `ls -la $WORKDIR/files/$FILE.zip | cut -d" " -f5` != $SIZE ]; then - nice -n 19 $CURLBIN "http://www.epgdata.com/index.php?action=sendPackage&iOEM=VDR&pin=$PIN&dayOffset=$i&dataType=xml" -o $WORKDIR/files/$FILE.zip - rm $WORKDIR/files/$FILE.epg > /dev/null 2>&1 - else - echo "File: $FILE already downloaded" - fi - fi -### process start ### - if [ -s $WORKDIR/files/$FILE.epg ]; then - echo "File: $FILE already processed" - else - echo -e " File: $FILE Size: $(( $SIZE /1024 )) kB" - #epgdata2vdr includedir epgimagesdir file(s) - $EPGDATA2VDRBIN $WORKDIR/include/ $EPGIMAGES $WORKDIR/files/$FILE.zip - $SVDRPSENDBIN PUTE ${PUTECHAR}$WORKDIR/files/$FILE.epg - fi - fi - rm $TMP + echo "<--- Processing data with offset $i --->" + TMP=`mktemp` + nice -n 19 $CURLBIN -I -D $TMP "http://www.epgdata.com/index.php?action=sendPackage&iOEM=VDR&pin=$PIN&dayOffset=$i&dataType=xml" &> /dev/null + FILE=`grep -e "^Content-disposition.*$" $TMP | sed -e ' s/\r//g' | cut -d"=" -f2` + FILE="`basename $FILE .zip`" + SIZE=`grep -e "^Content-Length.*$" $TMP | sed -e ' s/\r//g' | cut -d":" -f2` + [ -z $TIMEOUT ] && TIMEOUT=`grep -e "^x-epgdata-timeout.*$" $TMP | sed -e ' s/\r//g' | cut -d":" -f2` + if [ -z $LEFT ] && [ -n "$TIMEOUT" ]; then + LEFT=$((( $TIMEOUT - $(date +%s)) / 60 / 60 / 24 )) + fi + if [ ! -z $SIZE ]; then + if [ ! -e $WORKDIR/files/$FILE.zip ]; then + nice -n 19 $CURLBIN "http://www.epgdata.com/index.php?action=sendPackage&iOEM=VDR&pin=$PIN&dayOffset=$i&dataType=xml" -o $WORKDIR/files/$FILE.zip + rm $WORKDIR/files/$FILE.epg > /dev/null 2>&1 + else + if [ `ls -la $WORKDIR/files/$FILE.zip | cut -d" " -f5` != $SIZE ]; then + nice -n 19 $CURLBIN "http://www.epgdata.com/index.php?action=sendPackage&iOEM=VDR&pin=$PIN&dayOffset=$i&dataType=xml" -o $WORKDIR/files/$FILE.zip + rm $WORKDIR/files/$FILE.epg > /dev/null 2>&1 + else + echo "File: $FILE already downloaded" + fi + fi + ### process start ### + if [ -s $WORKDIR/files/$FILE.epg ]; then + echo "File: $FILE already processed" + else + if [ -e $WORKDIR/files/$FILE.zip ]; then + echo -e " File: $FILE Size: $(( $SIZE / 1024 )) kB" + #epgdata2vdr includedir epgimagesdir file(s) + $EPGDATA2VDRBIN $WORKDIR/include/ $EPGIMAGES $WORKDIR/files/$FILE.zip + $SVDRPSENDBIN PUTE ${PUTECHAR}$WORKDIR/files/$FILE.epg + else + echo "File: Failed to load $FILE" + fi + fi + fi + rm $TMP done +# Delete all but last set echo -n "Cleanup old files ... " -for i in `find $WORKDIR/files/* -name "*$SUFFIX.zip" | cut -d"_" -f2 | sort -r | uniq | tail -n +2` ; do - echo "Cleanup files of : $i " - rm -f $WORKDIR/files/*$i$SUFFIX.epg - rm -f $WORKDIR/files/*$i$SUFFIX.zip +for i in `find $WORKDIR/files/* -name "*$SUFFIX.zip" | cut -d"_" -f2 | sort -r | uniq | tail -n +2` ; do + echo "Cleanup files of : $i " + rm -f $WORKDIR/files/*$i$SUFFIX.epg + rm -f $WORKDIR/files/*$i$SUFFIX.zip done -# Delete old EPG-Images -if [ -e $WORKDIR/files/images/ ]; then - find $WORKDIR/files/images/* -type f -mtime +$MAXDAYS -print0 | xargs -0 rm -f -fi -# Also delete old symlinks (-L only broken symlinks) -[ -n "$EPGIMAGES" ] && find -L $EPGIMAGES/* -type l -delete &> /dev/null +if [ -n "$EMAIL" ]; then # To enable set $EMAIL in epgdata2vdr.conf + # Check if all files could be loaded (only works if MAXDAYS is less than 14) + NUMFILES=$(($(ls $WORKDIR/files/*.zip | wc -l))) + if [ $NUMFILES -lt $(($MAXDAYS +1)) ] && [ $MAXDAYS -lt 14 ] || [ "$LEFT" -lt "5" ]; then + echo "<--- Sending email about missing files / ending subscription --->" + echo "From: \"EPGData2VDR-Skript\"<$EMAIL>" > /tmp/mail.txt + echo "T0: $EMAIL" >> /tmp/mail.txt + if [ "$LEFT" -lt "5" ]; then # Subscription is ending... + echo "Subject: EPGData.com Abo endet in $LEFT Tag(en)!" >> /tmp/mail.txt + echo "" >> /tmp/mail.txt + echo "Das Abo bei EPGData.com hat noch eine Laufzeit von $LEFT Tag(en)" >> /tmp/mail.txt + echo "und endet danach automatisch! Ein neues Abo kann unter" >> /tmp/mail.txt + echo "http://www.epgdata.com/index.php?action=newSubscription&iLang=de&iOEM=vdr&iCountry=de&popup=0" >> /tmp/mail.txt + echo "abgeschlossen werden. Das neue Abo startet sofort nach Bezahlung!" >> /tmp/mail.txt + else + echo "Subject: Fehler beim laden von EPGData.com!" >> /tmp/mail.txt + echo "" >> /tmp/mail.txt + echo "Beim Download von EPGData.com konnten nicht alle Daten" >> /tmp/mail.txt + echo "geladen werden. Hinweis: Das Abo endet in $LEFT Tag(en)" >> /tmp/mail.txt + echo "" >> /tmp/mail.txt + echo "Es wurde(n) $NUMFILES von $(($MAXDAYS +1)) Datei(en) geladen!" >> /tmp/mail.txt + fi + echo "" >> /tmp/mail.txt + echo "Inhalt von $WORKDIR/files:" >> /tmp/mail.txt + ls -l $WORKDIR/files >> /tmp/mail.txt + $SENDMAIL $EMAIL < /tmp/mail.txt + fi +fi + +exit diff -Nru vdr-addon-epgdata2vdr-0.0.1/epgdata-update.cron-daily vdr-addon-epgdata2vdr-0.0.1+svn20100714/epgdata-update.cron-daily --- vdr-addon-epgdata2vdr-0.0.1/epgdata-update.cron-daily 2009-12-05 17:02:22.000000000 +0000 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/epgdata-update.cron-daily 2010-07-14 14:10:55.000000000 +0100 @@ -1,7 +1,7 @@ #!/bin/sh logger -s "Starting epgdata2vdr" -svdrpsend MESG "Suche EPG per EPGDATA..." +svdrpsend MESG "Lade EPG von EPGData.com" # Plugin EPGSearch anhalten svdrpsend plug epgsearch SETS off diff -Nru vdr-addon-epgdata2vdr-0.0.1/.svn/all-wcprops vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/all-wcprops --- vdr-addon-epgdata2vdr-0.0.1/.svn/all-wcprops 1970-01-01 01:00:00.000000000 +0100 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/all-wcprops 2010-07-14 14:10:55.000000000 +0100 @@ -0,0 +1,89 @@ +K 25 +svn:wc:ra_dav:version-url +V 50 +/vdr-plugin-tvm2vdr/!svn/ver/180/trunk/epgdata2vdr +END +channelmapper_epgdata2vdr +K 25 +svn:wc:ra_dav:version-url +V 76 +/vdr-plugin-tvm2vdr/!svn/ver/167/trunk/epgdata2vdr/channelmapper_epgdata2vdr +END +epgdata2vdr_clre.sh +K 25 +svn:wc:ra_dav:version-url +V 70 +/vdr-plugin-tvm2vdr/!svn/ver/179/trunk/epgdata2vdr/epgdata2vdr_clre.sh +END +update.c +K 25 +svn:wc:ra_dav:version-url +V 59 +/vdr-plugin-tvm2vdr/!svn/ver/180/trunk/epgdata2vdr/update.c +END +epgdata-update.cron-daily +K 25 +svn:wc:ra_dav:version-url +V 76 +/vdr-plugin-tvm2vdr/!svn/ver/171/trunk/epgdata2vdr/epgdata-update.cron-daily +END +main.c +K 25 +svn:wc:ra_dav:version-url +V 57 +/vdr-plugin-tvm2vdr/!svn/ver/144/trunk/epgdata2vdr/main.c +END +channelmap.c +K 25 +svn:wc:ra_dav:version-url +V 63 +/vdr-plugin-tvm2vdr/!svn/ver/125/trunk/epgdata2vdr/channelmap.c +END +epgdata2vdr.conf +K 25 +svn:wc:ra_dav:version-url +V 67 +/vdr-plugin-tvm2vdr/!svn/ver/171/trunk/epgdata2vdr/epgdata2vdr.conf +END +datamap.c +K 25 +svn:wc:ra_dav:version-url +V 60 +/vdr-plugin-tvm2vdr/!svn/ver/165/trunk/epgdata2vdr/datamap.c +END +update.h +K 25 +svn:wc:ra_dav:version-url +V 59 +/vdr-plugin-tvm2vdr/!svn/ver/165/trunk/epgdata2vdr/update.h +END +channelmap.h +K 25 +svn:wc:ra_dav:version-url +V 63 +/vdr-plugin-tvm2vdr/!svn/ver/144/trunk/epgdata2vdr/channelmap.h +END +epgdata2vdr.sh +K 25 +svn:wc:ra_dav:version-url +V 65 +/vdr-plugin-tvm2vdr/!svn/ver/178/trunk/epgdata2vdr/epgdata2vdr.sh +END +Makefile +K 25 +svn:wc:ra_dav:version-url +V 59 +/vdr-plugin-tvm2vdr/!svn/ver/159/trunk/epgdata2vdr/Makefile +END +datamap.h +K 25 +svn:wc:ra_dav:version-url +V 60 +/vdr-plugin-tvm2vdr/!svn/ver/125/trunk/epgdata2vdr/datamap.h +END +epgdata2vdr_channelmap.conf +K 25 +svn:wc:ra_dav:version-url +V 78 +/vdr-plugin-tvm2vdr/!svn/ver/179/trunk/epgdata2vdr/epgdata2vdr_channelmap.conf +END diff -Nru vdr-addon-epgdata2vdr-0.0.1/.svn/entries vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/entries --- vdr-addon-epgdata2vdr-0.0.1/.svn/entries 1970-01-01 01:00:00.000000000 +0100 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/entries 2010-07-14 14:10:55.000000000 +0100 @@ -0,0 +1,504 @@ +10 + +dir +180 +https://svn.origo.ethz.ch/vdr-plugin-tvm2vdr/trunk/epgdata2vdr +https://svn.origo.ethz.ch/vdr-plugin-tvm2vdr + + + +2010-07-14T07:22:19.250593Z +180 +megav0lt + + + + + + + + + + + + + + +8551bf61-fb70-47f8-9cdc-e5c233175072 + +channelmapper_epgdata2vdr +file + + + + +2010-07-14T13:10:55.882073Z +2960fa791c7e7ce0b21926b7a6a96d9f +2010-01-05T20:13:34.022474Z +167 +steffen_b + + + + + + + + + + + + + + + + + + + + + +2830 + +epgdata2vdr_clre.sh +file + + + + +2010-07-14T13:10:55.882073Z +b04f759691f5350c7c16ac7f5e34c269 +2010-05-09T06:36:59.369677Z +179 +megav0lt + + + + + + + + + + + + + + + + + + + + + +7551 + +update.c +file + + + + +2010-07-14T13:10:55.882073Z +96e1c364b788dc26a6247c7001b44ab3 +2010-07-14T07:22:19.250593Z +180 +megav0lt + + + + + + + + + + + + + + + + + + + + + +28411 + +epgdata-update.cron-daily +file + + + + +2010-07-14T13:10:55.886073Z +e7900746438c273a5b355eb474d5f552 +2010-03-27T12:27:38.334035Z +171 +megav0lt +has-props + + + + + + + + + + + + + + + + + + + + +517 + +main.c +file + + + + +2010-07-14T13:10:55.886073Z +f85a4d731d0fa025030fb07c4cae2d8b +2009-11-10T07:01:09.645313Z +144 +steffen_b + + + + + + + + + + + + + + + + + + + + + +488 + +channelmap.c +file + + + + +2010-07-14T13:10:55.886073Z +34bb8c63bf2d1c705950b93331812e81 +2009-10-10T13:08:29.888027Z +125 +steffen_b + + + + + + + + + + + + + + + + + + + + + +2427 + +epgdata2vdr.conf +file + + + + +2010-07-14T13:10:55.886073Z +eea6183ce346ed91274fdf3c41d7aeb8 +2010-03-27T12:27:38.334035Z +171 +megav0lt + + + + + + + + + + + + + + + + + + + + + +478 + +datamap.c +file + + + + +2010-07-14T13:10:55.886073Z +5d07c3695b20f9c67058faf77cd73a9a +2009-12-05T00:02:36.789882Z +165 +steffen_b +has-props + + + + + + + + + + + + + + + + + + + + +3349 + +update.h +file + + + + +2010-07-14T13:10:55.886073Z +65aedfd53bd0305b30e8cf4ceeb9f711 +2009-12-05T00:02:36.789882Z +165 +steffen_b +has-props + + + + + + + + + + + + + + + + + + + + +2016 + +channelmap.h +file + + + + +2010-07-14T13:10:55.890072Z +c8dccc5802be3e6f82118dbcb1ac4faa +2009-11-10T07:01:09.645313Z +144 +steffen_b +has-props + + + + + + + + + + + + + + + + + + + + +762 + +epgdata2vdr.sh +file + + + + +2010-07-14T13:10:55.890072Z +a3f3666ffbe85fddef9ebb6f19a4ea2c +2010-04-14T13:08:57.253502Z +178 +megav0lt + + + + + + + + + + + + + + + + + + + + + +4941 + +Makefile +file + + + + +2010-07-14T13:10:55.890072Z +f42a99a16360e6e95903b518cb77113e +2009-12-03T22:19:41.805963Z +159 +steffen_b + + + + + + + + + + + + + + + + + + + + + +1394 + +datamap.h +file + + + + +2010-07-14T13:10:55.890072Z +b1da23e0cb833a57131b50f5a041722d +2009-10-10T13:08:29.888027Z +125 +steffen_b +has-props + + + + + + + + + + + + + + + + + + + + +617 + +epgdata2vdr_channelmap.conf +file + + + + +2010-07-14T13:10:55.890072Z +5465a3d878c2ce6f27e2dfd94ec448c5 +2010-05-09T06:36:59.369677Z +179 +megav0lt + + + + + + + + + + + + + + + + + + + + + +6820 + diff -Nru vdr-addon-epgdata2vdr-0.0.1/.svn/prop-base/channelmap.h.svn-base vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/prop-base/channelmap.h.svn-base --- vdr-addon-epgdata2vdr-0.0.1/.svn/prop-base/channelmap.h.svn-base 1970-01-01 01:00:00.000000000 +0100 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/prop-base/channelmap.h.svn-base 2010-07-14 14:10:55.000000000 +0100 @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff -Nru vdr-addon-epgdata2vdr-0.0.1/.svn/prop-base/datamap.c.svn-base vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/prop-base/datamap.c.svn-base --- vdr-addon-epgdata2vdr-0.0.1/.svn/prop-base/datamap.c.svn-base 1970-01-01 01:00:00.000000000 +0100 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/prop-base/datamap.c.svn-base 2010-07-14 14:10:55.000000000 +0100 @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff -Nru vdr-addon-epgdata2vdr-0.0.1/.svn/prop-base/datamap.h.svn-base vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/prop-base/datamap.h.svn-base --- vdr-addon-epgdata2vdr-0.0.1/.svn/prop-base/datamap.h.svn-base 1970-01-01 01:00:00.000000000 +0100 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/prop-base/datamap.h.svn-base 2010-07-14 14:10:55.000000000 +0100 @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff -Nru vdr-addon-epgdata2vdr-0.0.1/.svn/prop-base/epgdata-update.cron-daily.svn-base vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/prop-base/epgdata-update.cron-daily.svn-base --- vdr-addon-epgdata2vdr-0.0.1/.svn/prop-base/epgdata-update.cron-daily.svn-base 1970-01-01 01:00:00.000000000 +0100 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/prop-base/epgdata-update.cron-daily.svn-base 2010-07-14 14:10:55.000000000 +0100 @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff -Nru vdr-addon-epgdata2vdr-0.0.1/.svn/prop-base/update.h.svn-base vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/prop-base/update.h.svn-base --- vdr-addon-epgdata2vdr-0.0.1/.svn/prop-base/update.h.svn-base 1970-01-01 01:00:00.000000000 +0100 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/prop-base/update.h.svn-base 2010-07-14 14:10:55.000000000 +0100 @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff -Nru vdr-addon-epgdata2vdr-0.0.1/.svn/text-base/channelmap.c.svn-base vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/text-base/channelmap.c.svn-base --- vdr-addon-epgdata2vdr-0.0.1/.svn/text-base/channelmap.c.svn-base 1970-01-01 01:00:00.000000000 +0100 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/text-base/channelmap.c.svn-base 2010-07-14 14:10:55.000000000 +0100 @@ -0,0 +1,123 @@ +/* + * channelmap.c: TVM2VDR plugin for the Video Disk Recorder + * + * See the README file for copyright information and how to reach the author. + * + */ + +#include "channelmap.h" + + +cChannelMap::cChannelMap (string confdir) +{ + chanmap.clear (); + read_config_file(confdir); +} + +cChannelMap::~cChannelMap () +{ + chanmap.clear (); +} + + +void +cChannelMap::remove_whitespaces (char *s) +{ + unsigned int i = 0; + char *dum; + if (s != NULL) + { + dum = (char *) calloc (1, strlen (s) + 1); + for (i = 0; i < strlen (s); i++) + if (!isspace (s[i])) + strncat (dum, &(s[i]), 1); + memset (s, 0, strlen (s)); + strcpy (s, dum); + free (dum); + } +} + + +int +cChannelMap::read_config_file (string confdir) +{ + ifstream cmfile; + string mapfile = confdir + "/epgdata2vdr_channelmap.conf" ; + string s; + size_t p; + int tvmid; + int n; + char *cfg_fname = NULL; + + cmfile.open (mapfile.c_str()); + if (!cmfile) + { + //esyslog ("TVM2VDR: Error reading '%s'!", cfg_fname); + fprintf(stderr,"TVM2VDR: Error reading '%s'!", cfg_fname); + return -1; + } + //isyslog + //fprintf(stderr,"TVM2VDR: Loading '%s'", cfg_fname); + n = 0; + while (!cmfile.eof ()) + { + getline (cmfile, s); + + if (!s.empty ()) + { + remove_whitespaces ((char *) s.c_str ()); + + // remove comments + p = s.find_first_of ("//"); + if (p != string::npos) + s.erase (p); + + // split line + p = s.find_first_of ("="); + if ((p != string::npos) && (s.substr (p + 1).length ())) + { + char *ptr = NULL; + tvmid = atoi (s.substr (0, p).c_str ()); + if ((ptr = strdup(s.substr (p + 1).c_str ())) != NULL) + { + char *vpsptr = NULL; + // one of the chars "1yYjJ" separated from the channelids + // by a colon means the sender has VPS + vpsmap[tvmid] = false; + if ((vpsptr = index(ptr, ':')) != NULL) + { + *vpsptr++ = '\0'; + vpsmap[tvmid] = (index("1yYjJ", *vpsptr) != NULL); + } + chanmap[tvmid].push_back(ptr); + // are there more channelids separated by commas? + while ((ptr = index(ptr, ',')) != NULL) + { + *ptr++ = '\0'; + chanmap[tvmid].push_back(ptr); + } + } + n++; + } + } + } + cmfile.close (); + //isyslog ("TVM2VDR: %d channel mappings read.", n); + //fprintf(stderr,"TVM2VDR: %d channel mappings read.", n); + return n; +} + +int +cChannelMap::GetChanCnt(int tvmid) +{ + return chanmap[tvmid].size(); +} + +char * +cChannelMap::GetChanStr (int tvmid, int index) +{ + return chanmap[tvmid][index]; +} + + + diff -Nru vdr-addon-epgdata2vdr-0.0.1/.svn/text-base/channelmap.h.svn-base vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/text-base/channelmap.h.svn-base --- vdr-addon-epgdata2vdr-0.0.1/.svn/text-base/channelmap.h.svn-base 1970-01-01 01:00:00.000000000 +0100 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/text-base/channelmap.h.svn-base 2010-07-14 14:10:55.000000000 +0100 @@ -0,0 +1,41 @@ +/* + * channelmap.h: TVTV plugin for the Video Disk Recorder + * + * See the README file for copyright information and how to reach the author. + * + */ + +#ifndef _CHANNELMAP__H +#define _CHANNELMAP__H + +#include +#include +#include +#include + +#include +#include + +using namespace std; + +typedef vector cChanVec; + +typedef map cChanMap; + +typedef map cVPSMap; + +class cChannelMap { +private: + void remove_whitespaces(char *s); + int read_config_file(string confdir); +public: + cChannelMap(string confir); + ~cChannelMap(); + cChanMap chanmap; + cVPSMap vpsmap; + int GetChanCnt(int tvmid); + char *GetChanStr(int tvmid, int index); +// tChannelID GetChanID(int tvmid, int index); +}; + +#endif diff -Nru vdr-addon-epgdata2vdr-0.0.1/.svn/text-base/channelmapper_epgdata2vdr.svn-base vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/text-base/channelmapper_epgdata2vdr.svn-base --- vdr-addon-epgdata2vdr-0.0.1/.svn/text-base/channelmapper_epgdata2vdr.svn-base 1970-01-01 01:00:00.000000000 +0100 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/text-base/channelmapper_epgdata2vdr.svn-base 2010-07-14 14:10:55.000000000 +0100 @@ -0,0 +1,93 @@ +#!/bin/bash +# + +. /etc/vdr/epgdata2vdr.conf + +EPGDATA2VDR_CHANNELS=$WORKDIR/include/epgdata2vdr_channelmap.conf +CHANNELS_CONF=/etc/vdr/channels.conf +CHANNEL_XML=$WORKDIR/include/channel_y.xml +CHANNEL_CH0=/tmp/channel_CH0.info +CHANNEL_CH4=/tmp/channel_CH4.info +CHANNEL_CH11=/tmp/channel_CH11.info +CHANNEL_INFO=/tmp/channel.info +CHANNEL_INFO_SORT=/tmp/channel.info.sort + +rm $EPGDATA2VDR_CHANNELS > /dev/null 2>&1 + +cat $CHANNEL_XML | grep "" | cut -d'>' -f2 | cut -d'<' -f1 > $CHANNEL_CH0 +cat $CHANNEL_XML | grep "" | cut -d'>' -f2 | cut -d'<' -f1 > $CHANNEL_CH4 +cat $CHANNEL_XML | grep "" | cut -d'>' -f2 | cut -d'<' -f1 > $CHANNEL_CH11 + +Kanal_Auswahl() +{ + sort -u $CHANNEL_INFO > $CHANNEL_INFO_SORT + if [ $(wc -l <$CHANNEL_INFO_SORT) -eq 1 ]; then + EINGABE=`cat $CHANNEL_INFO_SORT | cut -d' ' -f1` + echo + echo "Zuordnung für Kanal \"$CHANNELNAME\"" + cat $CHANNEL_INFO_SORT + else + echo + echo "Zuordnung für Kanal \"$CHANNELNAME\"" + cat $CHANNEL_INFO_SORT + echo -n "Auswahl (Nummer) (Enter übergeht): "; read EINGABE + fi + + for AUSWAHL in $EINGABE; do + cat -n $CHANNELS_CONF | cut -d' ' -f1 | grep "$AUSWAHL" > /dev/null 2>&1 + if [ $? -eq 1 ]; then + echo "$AUSWAHL: falsche Eingabe" + return 1 + fi + done +} + +NUMMER=1 + +while [ $NUMMER -le $(wc -l <$CHANNEL_CH11) ]; do + CHANNELNAME=`head -n $NUMMER $CHANNEL_CH11 | tail -n1` + cat $CHANNELS_CONF | cut -d ';' -f1 | grep -i -n -T "$CHANNELNAME" \ + > $CHANNEL_INFO + CHANNELNAME=`head -n $NUMMER $CHANNEL_CH0 | tail -n1` + cat $CHANNELS_CONF | cut -d ';' -f1 | grep -i -n -T "$CHANNELNAME" \ + >> $CHANNEL_INFO + + unset CHANNEL_IDS + EPGDATA_NUM=`head -n $NUMMER $CHANNEL_CH4 | tail -n1` + + if [ $(wc -l <$CHANNEL_INFO) -gt 0 ]; then + while ! Kanal_Auswahl; do + /bin/true + done + + for AUSWAHL in $EINGABE; do + NAME=`head -n $AUSWAHL $CHANNELS_CONF | tail -n1 | cut -d':' -f1` + SOURCE=`head -n $AUSWAHL $CHANNELS_CONF | tail -n1 | cut -d':' -f4` + NID=`head -n $AUSWAHL $CHANNELS_CONF | tail -n1 | cut -d':' -f11` + TID=`head -n $AUSWAHL $CHANNELS_CONF | tail -n1 | cut -d':' -f12` + SID=`head -n $AUSWAHL $CHANNELS_CONF | tail -n1 | cut -d':' -f10` + + if [ -z "$CHANNEL_IDS" ]; then + CHANNEL_IDS="$SOURCE-$NID-$TID-$SID" + else + CHANNEL_IDS="$CHANNEL_IDS,$SOURCE-$NID-$TID-$SID" + fi + done + fi + + if [ -z "$CHANNEL_IDS" ]; then + echo "// $EPGDATA_NUM = // $CHANNELNAME" \ + >> $EPGDATA2VDR_CHANNELS + else + echo "$EPGDATA_NUM = $CHANNEL_IDS // $NAME" \ + >> $EPGDATA2VDR_CHANNELS + fi + + NUMMER=$((NUMMER + 1)) +done + +rm $CHANNEL_CH0 +rm $CHANNEL_CH4 +rm $CHANNEL_CH11 +rm $CHANNEL_INFO +rm $CHANNEL_INFO_SORT diff -Nru vdr-addon-epgdata2vdr-0.0.1/.svn/text-base/datamap.c.svn-base vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/text-base/datamap.c.svn-base --- vdr-addon-epgdata2vdr-0.0.1/.svn/text-base/datamap.c.svn-base 1970-01-01 01:00:00.000000000 +0100 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/text-base/datamap.c.svn-base 2010-07-14 14:10:55.000000000 +0100 @@ -0,0 +1,134 @@ +/* + * datamap.c: TVM2VDR plugin for the Video Disk Recorder + * + * See the README file for copyright information and how to reach the author. + * + */ + +#include "datamap.h" + + +cDataMap::cDataMap (string confdir) +{ + datamap.clear(); + read_xml_file(confdir); +} + +cDataMap::~cDataMap () +{ + datamap.clear(); +} + + +int cDataMap::read_xml_file(string confdir) +{ + xmlTextReaderPtr reader; + int ret; + string genre = confdir + "genre.xml" ; + string category = confdir + "category.xml" ; + + // read categories and genre into ONE map. They don't share id's (Logic genre div 100 = category, genre is never full 100) + + // categories + reader = xmlReaderForFile(category.c_str(), "iso-8859-1" , XML_PARSE_NOENT | XML_PARSE_DTDLOAD); + if (reader != NULL) { + ret = xmlTextReaderRead(reader); + while (ret == 1) { + processData(reader); + ret = xmlTextReaderRead(reader); + } + xmlFreeTextReader(reader); + + if (ret != 0) { + fprintf(stderr, "category.xml : failed to parse\n"); + return ret; + } + } + else { + fprintf(stderr, "Unable to open category.xml\n"); + return -1; + } + + // genres + reader = xmlReaderForFile(genre.c_str(), "iso-8859-1" , XML_PARSE_NOENT | XML_PARSE_DTDLOAD); + if (reader != NULL) { + ret = xmlTextReaderRead(reader); + while (ret == 1) { + processData(reader); + ret = xmlTextReaderRead(reader); + } + xmlFreeTextReader(reader); + if (ret != 0) { + fprintf(stderr, "genre.xml : failed to parse\n"); + return ret; + } + } + else { + fprintf(stderr, "Unable to open genre.xml\n"); + return -1; + } + return 0; +} + +int cDataMap::processData(xmlTextReaderPtr reader) +{ + // element callback from read_xmlfile + // args: pointer to the xmlTextreader + xmlNodePtr node ; + xmlChar *content; + string value; + int epgdataid; + int retval; + + // get name, type and depth in the xml structure + string name = string((char *)xmlTextReaderConstName(reader)); + + int type = xmlTextReaderNodeType(reader) ; + int depth = xmlTextReaderDepth(reader) ; + + + // get ca0/ca1 or g0/g1 depending which file we read + if (type == XML_READER_TYPE_ELEMENT && depth == 2 && (name.compare("ca0") == 0)) { + node = xmlTextReaderExpand(reader); + content = xmlXPathCastNodeToString(node); + node = NULL ; + epgdataid = atoi((char *)content); + xmlFree(content); + + retval = xmlTextReaderNext(reader); // jump to end element + retval = xmlTextReaderNext(reader); // jump to next start element + + node = xmlTextReaderExpand(reader); + content = xmlXPathCastNodeToString(node); + node = NULL ; + value = string((char *)content); + xmlFree(content); + datamap[epgdataid] = value; + + } else if (type == XML_READER_TYPE_ELEMENT && depth == 2 && ( name.compare("g0") == 0 )) { + node = xmlTextReaderExpand(reader); + content = xmlXPathCastNodeToString(node); + node = NULL ; + epgdataid = atoi((char *)content); + xmlFree(content); + + retval = xmlTextReaderNext(reader); // jump to end element + retval = xmlTextReaderNext(reader); // jump to next start element + + node = xmlTextReaderExpand(reader); + content = xmlXPathCastNodeToString(node); + node = NULL ; + value = string((char *)content); + xmlFree(content); + datamap[epgdataid] = value; + } + return 0 ; +} + +string cDataMap::GetStr(int dataid) +{ + return datamap[dataid]; +} + + + diff -Nru vdr-addon-epgdata2vdr-0.0.1/.svn/text-base/datamap.h.svn-base vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/text-base/datamap.h.svn-base --- vdr-addon-epgdata2vdr-0.0.1/.svn/text-base/datamap.h.svn-base 1970-01-01 01:00:00.000000000 +0100 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/text-base/datamap.h.svn-base 2010-07-14 14:10:55.000000000 +0100 @@ -0,0 +1,35 @@ +/* + * datamap.h: TVTV plugin for the Video Disk Recorder + * + * See the README file for copyright information and how to reach the author. + * + */ + +#ifndef _DATAMAP__H +#define _DATAMAP__H + +#include +#include +#include +#include + +#include +#include +#include + +using namespace std; + +typedef map cDMap; + +class cDataMap { +private: + int read_xml_file(string confdir); + int processData(xmlTextReaderPtr reader); +public: + cDataMap(string confdir); + ~cDataMap(); + cDMap datamap; + string GetStr(int dataid); +}; + +#endif diff -Nru vdr-addon-epgdata2vdr-0.0.1/.svn/text-base/epgdata2vdr_channelmap.conf.svn-base vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/text-base/epgdata2vdr_channelmap.conf.svn-base --- vdr-addon-epgdata2vdr-0.0.1/.svn/text-base/epgdata2vdr_channelmap.conf.svn-base 1970-01-01 01:00:00.000000000 +0100 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/text-base/epgdata2vdr_channelmap.conf.svn-base 2010-07-14 14:10:55.000000000 +0100 @@ -0,0 +1,143 @@ +// +// ChannelMap for EPGDATA2VDR-Script +// -------------------------- +// +// EPGDATA2VDR ChannelID = VDR ChannelID (Src-NID-TID-SID) +// +// e.g.: +// +//71 = S19.2E-1-1101-28106 // Das Erste;ARD +//37 = S19.2E-1-1079-28006 // ZDF;ZDFvision +// +// multi-id's are by separated by "," +// +// e.g.: +// 4 = S19.2E-1-1089-12003,S19.2E-1-1091-28800 // RTL Television,RTL Austria +// +// VPS enabled by ":" and one of "1yYjJ" after channel-id +// +// e.g.: +// 1 = S19.2E-1-1101-28106:y // ARD +// +// +// Öffenlich-Rechtliche +//71 = S19.2E-1-1101-28106 // Das Erste;ARD +//37 = S19.2E-1-1079-28006 // ZDF;ZDFvision +//58 = S19.2E-1-1051-28724 // arte;ARD +//56 = S19.2E-1-1079-28007 // 3sat;ZDFvision +//104 = S19.2E-1-1101-28112 // BR-alpha*;ARD +//475 = S19.2E-1-1051-28723 // EinsPlus;ARD +//146 = S19.2E-1-1051-28722 // EinsFestival;ARD +//100 = S19.2E-1-1051-28721 // EinsExtra;ARD +//276 = S19.2E-1-1079-28011 // ZDFinfokanal;ZDFvision +//275 = S19.2E-1-1079-28016 // ZDFtheaterkanal;ZDFvision +//659 = S19.2E-1-1079-28014 // zdf_neo;ZDFvision +//194 = S19.2E-1-1051-28725 // Phoenix;ARD +//51 = S19.2E-1-1101-28107 // Bayerisches FS Süd;ARD +//49 = S19.2E-1-1101-28108 // hr-fernsehen;ARD +//52 = S19.2E-1-1073-28206,S19.2E-1-1073-28205 // rbb Berlin,rbb Brandenburg +//50 = S19.2E-1-1101-28113 // SWR Fernsehen BW;ARD +//46 = S19.2E-1-1201-28307,S19.2E-1-1201-28308,S19.2E-1-1201-28309,S19.2E-1-1101-28111,S19.2E-1-1201-28306,S19.2E-1-1201-28311,S19.2E-1-1201-28310 // WDR Dortmund,WDR Düsseldorf,WDR Essen,WDR Köln,WDR Bielefeld,WDR Siegen,WDR Münster +//47 = S19.2E-1-1073-28224,S19.2E-1-1073-28225,S19.2E-1-1073-28226,S19.2E-1-1073-28227 // NDR FS MV,NDR FS HH,NDR FS NDS,NDR FS SH +//57 = S19.2E-1-1079-28008 // KiKa;ZDFvision +//48 = S19.2E-1-1073-28230 // MDR Thüringen;ARD +// +// Private +38 = S19.2E-1-1089-12003,S19.2E-1-1091-28800 // RTL Television,RTL Austria +39 = S19.2E-1-1107-17500,S19.2E-1-1082-20005,S19.2E-1-1082-20006 // SAT.1,SAT.1 A +41 = S19.2E-1-1089-12020,S19.2E-1-1091-28810 // RTL2,RTL2 Austria +40 = S19.2E-1-1107-17501,S19.2E-1-1082-20002,S19.2E-1-1082-20001 // ProSieben,ProSieben Austria,ProSieben Schweiz +43 = S19.2E-1-1089-12040,S19.2E-1-1091-28815 // Super RTL,Super RTL A +44 = S19.2E-1-1107-17502,S19.2E-1-1082-20004,S19.2E-1-1082-20003 // kabel eins,Kabel 1 Austria,Kabel 1 Schweiz +42 = S19.2E-1-1089-12060,S19.2E-1-1091-28805 // VOX,VOX Austria +//694 = S19.2E-133-5-776 // SIXX;ProSiebenSat.1 +486 = S19.2E-133-5-1793 // DAS VIERTE,D VIERTE;BetaDigital +277 = S19.2E-133-33-51 // TELE 5;BetaDigital +//1179 = S19.2E-1-1107-17504 // 9Live;ProSiebenSat.1 +//66 = S19.2E-1-1089-12090 // n-tv;RTL World +68 = S19.2E-1-1091-31220 // EuroNews;Globecast +//175 = S19.2E-1-1107-17503 // N24;ProSiebenSat.1 +//127 = S19.2E-1-1108-12160 // Bloomberg TV Germany;Bloomberg +//69 = S19.2E-1-1068-28522 // CNN Int.;CNN +//65 = S19.2E-1-1091-31200 // Eurosport;SES Astra +//64 = S19.2E-133-33-900 // DSF;BetaDigital +589 = S19.2E-1-1078-28680 // Nick / Comedy Central +//507 = S19.2E-1-1092-10101 // DMAX;BetaDigital +//159 = S19.2E-133-33-40 // HSE24,HSE24;BetaDigital +//208 = S19.2E-1-1108-12100 // QVC Deutschland;QVC +//494 = S19.2E-133-5-776 // GIGA;BetaDigital +//280 = S19.2E-1-1108-12122 // Bibel TV;Bibel TV +//588 = S19.2E-1-1113-12600 // TIMM;MEDIA BROADCAST +// +// Österreich +//54 = S19.2E-1-1117-13001 // ORF1;ORF +//55 = S19.2E-1-1117-13002 // ORF2;ORF +//115 = S19.2E-1-1117-13012 // ATV+;ATV+ +//265 = S19.2E-1-1115-13101 // TW1;ORF +// +// Sky Deutschland +//610 = S19.2E-133-2-10 // Sky Cinema,Cinema;SKY +//611 = S19.2E-133-2-11 // Sky Cinema +1,Cinema1;SKY +//612 = S19.2E-133-2-43 // Sky Cinema +24,Cinema24;SKY +//613 = S19.2E-133-2-9 // Sky Action,Action;SKY +//617 = S19.2E-133-2-8 // Sky Comedy,Comedy;SKY +//616 = S19.2E-133-2-20 // Sky Emotion,Emotion;SKY +//614 = S19.2E-133-3-516 // Sky Nostalgie,Nostalgie;SKY +//618 = S19.2E-133-3-41 // Sky Cinema Hits,CineHits;SKY +//630 = S19.2E-133-3-25 // Disney Cinemagic,Cinemagic;SKY +//1196 = S19.2E-133-3-515 // MGM;SKY +//138 = S19.2E-133-4-14 // Discovery Channel,Discovery;SKY +//453 = S19.2E-133-4-13 // National Geographic,NatGeo;SKY +//626 = S19.2E-133-4-12 // NatGeo Wild,NG Wild;SKY +//625 = S19.2E-133-4-52 // Spiegel Geschichte,SpiegelG;SKY +//627 = S19.2E-133-1-168 // Motorvision TV,Motorvis;SKY +//476 = S19.2E-133-4-15 // Focus Gesundheit,Focus;SKY +//615 = S19.2E-133-1-23 // Sky Krimi,SkyKrimi;SKY +//527 = S19.2E-133-1-27 // RTL Crime,RTLCrime;SKY +//471 = S19.2E-133-1-42 // 13th Street,13Street;SKY +//472 = S19.2E-133-17-36 // SciFi;SKY +//565 = S19.2E-133-1-16 // Fox Serie,Fox;SKY +//590 = S19.2E-133-1-50 // TNT Serie,TNTSerie;SKY +//529 = S19.2E-133-1-29 // RTL Passion,Passion;SKY +//154 = S19.2E-133-17-22 // Heimatkanal,Heimat;SKY +//139 = S19.2E-133-17-34 // Disney Channel,Disney;SKY +//460 = S19.2E-133-17-26 // Playhouse Disney,Playhouse;SKY ??? +//160 = S19.2E-133-17-19 // Junior;SKY +// = S19.2E-133-17-28 // Disney XD,DisneyXD;SKY ??? +//152 = S19.2E-133-17-518 // Goldstar TV,Goldstar;SKY +//133 = S19.2E-133-17-24 // Classica;SKY +//123 = S19.2E-133-17-21 // Beate-Uhse.TV,BeateU;SKY +//491 = S19.2E-1-1107-17505 // Sat.1 Comedy;ProSiebenSat.1 +468 = S19.2E-133-9-62 // AXN Action,AXN;arena/SKY +//633 = S19.2E-133-9-61 // TNT Film (TCM),TNT Film;arena/SKY +//492 = S19.2E-1-1107-17506 // kabel eins classics;ProSiebenSat.1 +//450 = S19.2E-133-9-60 // Kinowelt TV,Kinowelt;SKY ??? +//552 = S19.2E-133-9-63 // Romance TV,Romance;SKY ??? +//551 = S19.2E-1-1078-28682 // NICK PREMIUM (S);MTV Networks Europe ??? +//493 = S19.2E-133-9-66 // Boomerang;arena/SKY ??? +//132 = S19.2E-1-1102-13204 // Cartoon Network (a/S);arena/SKY +//452 = S19.2E-133-9-68 // History;SKY +//536 = S19.2E-1-1102-13208 // Biography Channel;arena/SKY ??? +//528 = S19.2E-1-1102-13207 // RTL Living;arena/SKY +// = S19.2E-133-9-67 // e.clips;SKY ??? +//539 = S19.2E-1-1102-13203 // ANIMAX;arena/SKY +//553 = S19.2E-1-1078-28681 // MTV ENTERTAINMENT (S);MTV Networks Europe ??? +//496 = S19.2E-1-1066-28657 // VH1 Classic;MTV Networks Europe ??? +//504 = S19.2E-1-1102-13205 // EuroSport 2 (a/S);arena/SKY +//591 = S19.2E-1-1115-13105 // ESPN America (S);SKY +//622 = S19.2E-133-7-53 // Sky Sport Austria,SportAut;SKY +//628 = S19.2E-133-4-18 // Sky Select,SkySel;SKY +// +// Musik +266 = S19.2E-1-1078-28676 // VIVA Germany;MTV Networks Europe +70 = S19.2E-1-1078-28673 // MTV Germany;MTV Networks Europe +391 = S19.2E-1-1115-13102 // GoTV;GoTV +// +// Ausland +//67 = S13.0E-318-9400-8204 // BBC World News;Globecast UK +//260 = S13.0E-318-15800-8432 // CONTO TV 5;Telespazio +//209 = S19.2E-1-1024-9015 // RAI 1;CANALSATELLITE +//231 = S13.0E-318-8500-911 // SF info;Schweizer Fernsehen +//127 = S19.2E-1-1114-8904 // BLOOMBERG TV;CSAT +//298 = S13.0E-272-6000-1 // Italia 1;Mediaset +//455 = S13.0E-1-1-17 // Fashion TV;RRSat diff -Nru vdr-addon-epgdata2vdr-0.0.1/.svn/text-base/epgdata2vdr_clre.sh.svn-base vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/text-base/epgdata2vdr_clre.sh.svn-base --- vdr-addon-epgdata2vdr-0.0.1/.svn/text-base/epgdata2vdr_clre.sh.svn-base 1970-01-01 01:00:00.000000000 +0100 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/text-base/epgdata2vdr_clre.sh.svn-base 2010-07-14 14:10:55.000000000 +0100 @@ -0,0 +1,195 @@ +#!/bin/bash + +# Einstellungen +. /etc/vdr/epgdata2vdr/epgdata2vdr.conf + +# Debugging +#set -x + +# Spracheinstellungen, damit Umlaute zum VDR passen, +# wenn dieser in einer anderen Einstellung läuft (z.B. wegen dem Sky-EPG) +export LANG=de_DE +export LC_COLLATE=de_DE + +[ -n "$1" ] && MAXDAYS=$1 # Anzahl der Tage kann auch manuell übergeben werden + +# Pfade zu den Programmen +CURL=/usr/bin/curl +EPGDATA2VDR=/usr/local/src/_div/epgdata2vdr/epgdata2vdr +SVDRPSEND=/usr/bin/svdrpsend.pl +MKDIR=/bin/mkdir +UNZIP=/usr/bin/unzip +SED=/bin/sed +SENDMAIL=/usr/sbin/sendmail +WC=/bin/wc + +# check config and install required files if necessary +if [ ! -n "$WORKDIR" ]; then + echo "Work directory undefined. Stopping." + exit 1 +fi + +if [ ! -n "$PIN" ]; then + echo "epgdata.com PIN is not configured" + exit 1 +fi + +if [ ! -e $WORKDIR/include/epgdata2vdr_channelmap.conf ]; then + echo "epgdata2vdr_channelmap.conf not found. Stopping." + exit 1 +fi + +if [ ! -d $WORKDIR/files ]; then + mkdir -p $WORKDIR/files +fi + +if [ ! -e $WORKDIR/include/genre.xml -o ! -e $WORKDIR/include/category.xml ]; then + mkdir -p $WORKDIR/include + if [ x$? != x0 ]; then + echo "$WORKDIR/include exists but is not a directory" + exit 1 + else + nice -n 19 $CURL "http://www.epgdata.com/index.php?action=sendInclude&iOEM=&pin=$PIN&dataType=xml" \ + -o $WORKDIR/include/include.zip + $UNZIP -o $WORKDIR/include/include.zip -d $WORKDIR/include + fi +fi + +# Delete old EPG-Images +if [ -e $WORKDIR/files/images/ ]; then + find $WORKDIR/files/images/* -type f -mtime +$MAXDAYS -print0 | xargs -0 rm -f +fi +# Also delete old symlinks (-L only broken symlinks) +[ -n "$EPGIMAGES" ] && find -L $EPGIMAGES/* -type l -print0 | xargs -0 rm -f + +# Put configured channels in array (first element is 0) +EPGDATA_CHANNELS=( $(grep '^[0-9]* = S.*//' $WORKDIR/include/epgdata2vdr_channelmap.conf | cut -d "$(echo -e "\t")" -f1 | sed 's/[0-9]* = //' | sed "s/,/ /g" | awk '{printf "%s ",$0;}') ) +#echo ${EPGDATA_CHANNELS[*]} +echo "${#EPGDATA_CHANNELS[*]} channels configured for EPGData2VDR" + +# Download and process files for EPG +for i in `seq 0 $MAXDAYS` ; do + echo "<--- Processing data with offset $i --->" + TMP=`mktemp` + nice -n 19 $CURL -I -D $TMP "http://www.epgdata.com/index.php?action=sendPackage&iOEM=VDR&pin=$PIN&dayOffset=$i&dataType=xml" &> /dev/null + FILE=`grep -e "^Content-disposition.*$" $TMP | $SED -e ' s/\r//g' | cut -d"=" -f2` + [ -z $FILE ] && echo "No Datafile found in Download" + FILE="`basename $FILE .zip`" + SIZE=`grep -e "^Content-Length.*$" $TMP | $SED -e ' s/\r//g' | cut -d":" -f2` + #AVAILABLE=`grep -e "^x-epgdata-packageAvailable.*$" $TMP | sed -e ' s/\r//g' | cut -d":" -f2` + [ -z $TIMEOUT ] && TIMEOUT=`grep -e "^x-epgdata-timeout.*$" $TMP | $SED -e ' s/\r//g' | cut -d":" -f2` + if [ -z $LEFT ] && [ -n "$TIMEOUT" ]; then + LEFT=$((( $TIMEOUT - $(date +%s)) / 60 / 60 / 24 )) # Days left (subscription) + fi + if [ ! -z $SIZE ]; then + if [ ! -e $WORKDIR/files/$FILE.zip ]; then + nice -n 19 $CURL "http://www.epgdata.com/index.php?action=sendPackage&iOEM=VDR&pin=$PIN&dayOffset=$i&dataType=xml" -o $WORKDIR/files/$FILE.zip #-v + rm $WORKDIR/files/$FILE.epg > /dev/null 2>&1 + else + if [ `ls -la $WORKDIR/files/$FILE.zip | cut -d" " -f5` != $SIZE ]; then + nice -n 19 $CURL "http://www.epgdata.com/index.php?action=sendPackage&iOEM=VDR&pin=$PIN&dayOffset=$i&dataType=xml" -o $WORKDIR/files/$FILE.zip #-v + rm $WORKDIR/files/$FILE.epg > /dev/null 2>&1 + else + echo "File: $FILE already downloaded" + fi + fi + ### process start ### + if [ -s $WORKDIR/files/$FILE.epg ]; then + echo "File: $FILE already processed" + NO_CLRE=1 # Do not delete EPG from VDR + else + if [ -e $WORKDIR/files/$FILE.zip ]; then + echo -e " File: $FILE Size: $(( $SIZE / 1024 )) kB" + #epgdata2vdr includedir epgimagesdir file(s) + nice -n 19 $EPGDATA2VDR $WORKDIR/include/ $EPGIMAGES $WORKDIR/files/$FILE.zip #> $WORKDIR/files/$FILE.epg + nice -n 19 $SED -i 's/\x97/-/g' $WORKDIR/files/$FILE.epg # Replace long "-" + # List of channels with data in epgfile + EPG_CHANNELS=( $(grep '^C *' $WORKDIR/files/$FILE.epg | sed 's/C //' | awk '{printf "%s ",$0;}') ) + #echo ${EPG_CHANNELS[*]} + echo "${#EPG_CHANNELS[*]} EPG entries found" + # Check if data exist for each configured channel + for chan in `seq 0 $(( ${#EPGDATA_CHANNELS[*]} -1 ))` ; do + if [ "${EPGDATA_CHANNELS[$chan]}" != "0" ] ; then # skip already failed channels + echo -n "Checking EPG for channel #$chan: "; echo ${EPGDATA_CHANNELS[$chan]} + ### Found? + NUM[$chan]=0 # Set to 0 to avoid empty fields + for entry in ${EPG_CHANNELS[*]} ; do # Is there some epgdata to import? + if [ $entry == ${EPGDATA_CHANNELS[$chan]} ] ; then + NUM[$chan]=$(( ${NUM[$chan]} +1 )) # Put in array (and count) + fi + done #entry + if [ "${NUM[$chan]}" = "0" ]; then + echo "!!> NO EPG ENTRIES FOUND!" + # Do not delete EPG from VDR's EPG.data! + EPGDATA_CHANNELS[$chan]=0 + else + echo "--> ${NUM[$chan]} EPG entries found" + fi + fi + done #chan + echo "==> ${NUM[*]} EPG entries found" + # Add epgfile to importlist (Will be processed later) + IMPORT_LIST[$i]=$FILE + else + echo "File: Failed to load $FILE" + NO_CLRE=1 # Do not delete EPG from VDR + fi + fi + fi + rm $TMP +done #i + +#echo "${#EPGDATA_CHANNELS[*]} channels configured for EPGData2VDR:" +#echo ${EPGDATA_CHANNELS[*]} + +# Delete old EPG from VDR's EPG.data +if [ -z $NO_CLRE ] ; then # Already procesd files or download error + for i in ${EPGDATA_CHANNELS[*]} ; do + if [ "$i" != "0" ] ; then + $SVDRPSEND CLRE $i # Delete EPG for channel + fi + done +fi + +# Import EPG +for i in ${IMPORT_LIST[*]} ; do + $SVDRPSEND PUTE $PUTECHAR$WORKDIR/files/$i.epg # Import EPG to VDR +done + +# Delete all but last set +for i in `find $WORKDIR/files/* -name "*$SUFFIX.zip" | cut -d"_" -f2 | sort -r | uniq | tail -n +2` ; do + echo "Cleanup files of : $i " + rm -f $WORKDIR/files/*$i$SUFFIX.epg + rm -f $WORKDIR/files/*$i$SUFFIX.zip +done + +if [ -n "$EMAIL" ]; then # To enable set $EMAIL in epgdata2vdr.conf + # Check if all files could be loaded (only works if MAXDAYS is less than 14) + NUMFILES=$(($(ls $WORKDIR/files/*.zip | wc -l))) + if [ $NUMFILES -lt $(($MAXDAYS +1)) ] && [ $MAXDAYS -lt 14 ] || [ "$LEFT" -lt "5" ]; then + echo "<--- Sending email about missing files / ending subscription --->" + echo "From: \"EPGData2VDR-Skript\"<$EMAIL>" > /tmp/mail.txt + echo "T0: $EMAIL" >> /tmp/mail.txt + if [ "$LEFT" -lt "5" ]; then # Subscription is ending... + echo "Subject: EPGData.com Abo endet in $LEFT Tag(en)!" >> /tmp/mail.txt + echo "" >> /tmp/mail.txt + echo "Das Abo bei EPGData.com hat noch eine Laufzeit von $LEFT Tag(en)" >> /tmp/mail.txt + echo "und endet danach automatisch! Ein neues Abo kann unter" >> /tmp/mail.txt + echo "http://www.epgdata.com/index.php?action=newSubscription&iLang=de&iOEM=vdr&iCountry=de&popup=0" >> /tmp/mail.txt + echo "abgeschlossen werden. Das neue Abo startet sofort nach Bezahlung!" >> /tmp/mail.txt + else + echo "Subject: Fehler beim laden von EPGData.com!" >> /tmp/mail.txt + echo "" >> /tmp/mail.txt + echo "Beim Download von EPGData.com konnten nicht alle Daten" >> /tmp/mail.txt + echo "geladen werden. Hinweis: Das Abo endet in $LEFT Tag(en)" >> /tmp/mail.txt + echo "" >> /tmp/mail.txt + echo "Es wurde(n) $NUMFILES von $(($MAXDAYS +1)) Datei(en) geladen!" >> /tmp/mail.txt + fi + echo "" >> /tmp/mail.txt + echo "Inhalt von $WORKDIR/files:" >> /tmp/mail.txt + ls -l $WORKDIR/files >> /tmp/mail.txt + $SENDMAIL $EMAIL < /tmp/mail.txt + fi +fi + +exit diff -Nru vdr-addon-epgdata2vdr-0.0.1/.svn/text-base/epgdata2vdr.conf.svn-base vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/text-base/epgdata2vdr.conf.svn-base --- vdr-addon-epgdata2vdr-0.0.1/.svn/text-base/epgdata2vdr.conf.svn-base 1970-01-01 01:00:00.000000000 +0100 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/text-base/epgdata2vdr.conf.svn-base 2010-07-14 14:10:55.000000000 +0100 @@ -0,0 +1,7 @@ +WORKDIR=/var/cache/vdr/epgdata2vdr # downloaded files and processed EPG will be kept here +PIN= # your PIN as provided by epgdata.com +MAXDAYS=30 # load until no files available or MAXDAYS +PUTECHAR="" # @for patched PUTE "" for vdr >= 1.7.6 +EPGIMAGES=/var/cache/vdr/epgimages # Auskommentieren, wenn keine EPG-Bilder gewünscht +SUFFIX=_de_qy # Suffix (needed for file deletion) +#EMAIL= # Set to your eMail-Adress to get info when abo ends diff -Nru vdr-addon-epgdata2vdr-0.0.1/.svn/text-base/epgdata2vdr.sh.svn-base vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/text-base/epgdata2vdr.sh.svn-base --- vdr-addon-epgdata2vdr-0.0.1/.svn/text-base/epgdata2vdr.sh.svn-base 1970-01-01 01:00:00.000000000 +0100 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/text-base/epgdata2vdr.sh.svn-base 2010-07-14 14:10:55.000000000 +0100 @@ -0,0 +1,130 @@ +#!/bin/bash + +. /etc/vdr/epgdata2vdr.conf + +# only change if you know what you are doing +EPGDATA2VDRBIN=/usr/bin/epgdata2vdr +SVDRPSENDBIN=/usr/bin/svdrpsend +CURLBIN=/usr/bin/curl +UNZIPBIN=/usr/bin/unzip +SENDMAIL=/usr/sbin/sendmail +WC=/bin/wc + +# install required files if necessary + create directories +if [ ! -n "$WORKDIR" ]; then + echo "Work directory undefined. Stopping." + exit 1 +fi + +if [ ! -n "$PIN" ]; then + echo "epgdata.com PIN is not configured. Stopping" + exit 1 +fi + +if [ ! -e $WORKDIR/include/epgdata2vdr_channelmap.conf ]; then + echo "epgdata2vdr_channelmap.conf not found. Stopping." + exit 1 +fi + +if [ ! -d $WORKDIR/files ]; then + mkdir -p $WORKDIR/files +fi + +if [ ! -e $WORKDIR/include/genre.xml -o ! -e $WORKDIR/include/category.xml ]; then + mkdir -p $WORKDIR/include + if [ x$? != x0 ]; then + echo "$WORKDIR/include exists but is not a directory" + exit 1 + else + nice -n 19 $CURLBIN "http://www.epgdata.com/index.php?action=sendInclude&iOEM=&pin=$PIN&dataType=xml" \ + -o $WORKDIR/include/include.zip + $UNZIPBIN -o $WORKDIR/include/include.zip -d $WORKDIR/include + fi +fi + +# Delete old EPG-Images +if [ -e $WORKDIR/files/images/ ]; then + find $WORKDIR/files/images/* -type f -mtime +$MAXDAYS -print0 | xargs -0 rm -f +fi +# Also delete old symlinks (-L only broken symlinks) +[ -n "$EPGIMAGES" ] && find -L $EPGIMAGES/* -type l -print0 | xargs -0 rm -f + +# process data +for i in `seq 0 $MAXDAYS` ; do + echo "<--- Processing data with offset $i --->" + TMP=`mktemp` + nice -n 19 $CURLBIN -I -D $TMP "http://www.epgdata.com/index.php?action=sendPackage&iOEM=VDR&pin=$PIN&dayOffset=$i&dataType=xml" &> /dev/null + FILE=`grep -e "^Content-disposition.*$" $TMP | sed -e ' s/\r//g' | cut -d"=" -f2` + FILE="`basename $FILE .zip`" + SIZE=`grep -e "^Content-Length.*$" $TMP | sed -e ' s/\r//g' | cut -d":" -f2` + [ -z $TIMEOUT ] && TIMEOUT=`grep -e "^x-epgdata-timeout.*$" $TMP | sed -e ' s/\r//g' | cut -d":" -f2` + if [ -z $LEFT ] && [ -n "$TIMEOUT" ]; then + LEFT=$((( $TIMEOUT - $(date +%s)) / 60 / 60 / 24 )) + fi + if [ ! -z $SIZE ]; then + if [ ! -e $WORKDIR/files/$FILE.zip ]; then + nice -n 19 $CURLBIN "http://www.epgdata.com/index.php?action=sendPackage&iOEM=VDR&pin=$PIN&dayOffset=$i&dataType=xml" -o $WORKDIR/files/$FILE.zip + rm $WORKDIR/files/$FILE.epg > /dev/null 2>&1 + else + if [ `ls -la $WORKDIR/files/$FILE.zip | cut -d" " -f5` != $SIZE ]; then + nice -n 19 $CURLBIN "http://www.epgdata.com/index.php?action=sendPackage&iOEM=VDR&pin=$PIN&dayOffset=$i&dataType=xml" -o $WORKDIR/files/$FILE.zip + rm $WORKDIR/files/$FILE.epg > /dev/null 2>&1 + else + echo "File: $FILE already downloaded" + fi + fi + ### process start ### + if [ -s $WORKDIR/files/$FILE.epg ]; then + echo "File: $FILE already processed" + else + if [ -e $WORKDIR/files/$FILE.zip ]; then + echo -e " File: $FILE Size: $(( $SIZE / 1024 )) kB" + #epgdata2vdr includedir epgimagesdir file(s) + $EPGDATA2VDRBIN $WORKDIR/include/ $EPGIMAGES $WORKDIR/files/$FILE.zip + $SVDRPSENDBIN PUTE ${PUTECHAR}$WORKDIR/files/$FILE.epg + else + echo "File: Failed to load $FILE" + fi + fi + fi + rm $TMP +done + +# Delete all but last set +echo -n "Cleanup old files ... " +for i in `find $WORKDIR/files/* -name "*$SUFFIX.zip" | cut -d"_" -f2 | sort -r | uniq | tail -n +2` ; do + echo "Cleanup files of : $i " + rm -f $WORKDIR/files/*$i$SUFFIX.epg + rm -f $WORKDIR/files/*$i$SUFFIX.zip +done + +if [ -n "$EMAIL" ]; then # To enable set $EMAIL in epgdata2vdr.conf + # Check if all files could be loaded (only works if MAXDAYS is less than 14) + NUMFILES=$(($(ls $WORKDIR/files/*.zip | wc -l))) + if [ $NUMFILES -lt $(($MAXDAYS +1)) ] && [ $MAXDAYS -lt 14 ] || [ "$LEFT" -lt "5" ]; then + echo "<--- Sending email about missing files / ending subscription --->" + echo "From: \"EPGData2VDR-Skript\"<$EMAIL>" > /tmp/mail.txt + echo "T0: $EMAIL" >> /tmp/mail.txt + if [ "$LEFT" -lt "5" ]; then # Subscription is ending... + echo "Subject: EPGData.com Abo endet in $LEFT Tag(en)!" >> /tmp/mail.txt + echo "" >> /tmp/mail.txt + echo "Das Abo bei EPGData.com hat noch eine Laufzeit von $LEFT Tag(en)" >> /tmp/mail.txt + echo "und endet danach automatisch! Ein neues Abo kann unter" >> /tmp/mail.txt + echo "http://www.epgdata.com/index.php?action=newSubscription&iLang=de&iOEM=vdr&iCountry=de&popup=0" >> /tmp/mail.txt + echo "abgeschlossen werden. Das neue Abo startet sofort nach Bezahlung!" >> /tmp/mail.txt + else + echo "Subject: Fehler beim laden von EPGData.com!" >> /tmp/mail.txt + echo "" >> /tmp/mail.txt + echo "Beim Download von EPGData.com konnten nicht alle Daten" >> /tmp/mail.txt + echo "geladen werden. Hinweis: Das Abo endet in $LEFT Tag(en)" >> /tmp/mail.txt + echo "" >> /tmp/mail.txt + echo "Es wurde(n) $NUMFILES von $(($MAXDAYS +1)) Datei(en) geladen!" >> /tmp/mail.txt + fi + echo "" >> /tmp/mail.txt + echo "Inhalt von $WORKDIR/files:" >> /tmp/mail.txt + ls -l $WORKDIR/files >> /tmp/mail.txt + $SENDMAIL $EMAIL < /tmp/mail.txt + fi +fi + +exit diff -Nru vdr-addon-epgdata2vdr-0.0.1/.svn/text-base/epgdata-update.cron-daily.svn-base vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/text-base/epgdata-update.cron-daily.svn-base --- vdr-addon-epgdata2vdr-0.0.1/.svn/text-base/epgdata-update.cron-daily.svn-base 1970-01-01 01:00:00.000000000 +0100 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/text-base/epgdata-update.cron-daily.svn-base 2010-07-14 14:10:55.000000000 +0100 @@ -0,0 +1,24 @@ +#!/bin/sh + +logger -s "Starting epgdata2vdr" +svdrpsend MESG "Lade EPG von EPGData.com" + +# Plugin EPGSearch anhalten +svdrpsend plug epgsearch SETS off + +sleep 1 +if [ ! -e /var/log/epg-update ]; then + touch /var/log/epg-update + chown vdr:vdr /var/log/epg-update +fi + +echo -n "`date` " >> /var/log/epg-update +su -c '/usr/bin/epgdata2vdr.sh >> /var/log/epg-update' vdr + +sleep 1 + +# Plugin EPGSearch wieder starten +svdrpsend plug epgsearch SETS on + +svdrpsend MESG "EPG-Suche beendet" +logger -s "EPG Suche beendet" diff -Nru vdr-addon-epgdata2vdr-0.0.1/.svn/text-base/main.c.svn-base vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/text-base/main.c.svn-base --- vdr-addon-epgdata2vdr-0.0.1/.svn/text-base/main.c.svn-base 1970-01-01 01:00:00.000000000 +0100 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/text-base/main.c.svn-base 2010-07-14 14:10:55.000000000 +0100 @@ -0,0 +1,29 @@ + +#include + +#include "update.h" +using namespace std; + + +int main(int argc, char *argv[]) +{ + int n; + cProcessEpg *process ; + process = new cProcessEpg(); + process->confdir = string(argv[1]) ; +#ifdef USE_IMAGEMAGICK + process->epgimagesdir = string(argv[2]) ; +#endif + process->readMaps(process->confdir) ; + +#ifndef USE_IMAGEMAGICK + for (n=2; nprocessFile(process->confdir, argv[n]); + } + delete process; + return 0 ; +} diff -Nru vdr-addon-epgdata2vdr-0.0.1/.svn/text-base/Makefile.svn-base vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/text-base/Makefile.svn-base --- vdr-addon-epgdata2vdr-0.0.1/.svn/text-base/Makefile.svn-base 1970-01-01 01:00:00.000000000 +0100 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/text-base/Makefile.svn-base 2010-07-14 14:10:55.000000000 +0100 @@ -0,0 +1,38 @@ + +USE_IMAGEMAGICK=1 + +ifdef USE_IMAGEMAGICK +LIBS += $(shell Magick-config --ldflags --libs) +endif + +ifdef USE_IMAGEMAGICK +DEFINES = -DUSE_IMAGEMAGICK $(shell Magick-config --cflags --cppflags) +endif + + +all: epgdata2vdr + +epgdata2vdr: main.c update.h update.c channelmap.h channelmap.c datamap.c + $(CXX) -Wall -g -I/usr/include/libxml2 -I/usr/include/libzip $(DEFINES) main.c update.h update.c channelmap.h channelmap.c datamap.c -lzip -lxml2 $(LIBS) -o epgdata2vdr + +clean: + @rm -rf epgdata2vdr + +install: + install -m 750 epgdata2vdr $(DESTDIR)/usr/bin/ + install -m 750 epgdata2vdr.sh $(DESTDIR)/usr/bin/ + install -m 750 epgdata-update.cron-daily $(DESTDIR)/etc/cron.daily/epgdata2vdr-update + install -d -m 755 $(DESTDIR)/var/cache/vdr/epgdata2vdr/include/ + install -d -m 755 $(DESTDIR)/var/cache/vdr/epgdata2vdr/files/ + install -m 660 epgdata2vdr_channelmap.conf $(DESTDIR)/var/cache/vdr/epgdata2vdr/include/ + install -d $(DESTDIR)/etc/vdr + install -m 660 epgdata2vdr.conf $(DESTDIR)/etc/vdr/epgdata2vdr.conf + +uninstall: + @rm -rf $(DESTDIR)/var/cache/vdr/epgdata2vdr/include/ + @rm -rf $(DESTDIR)/var/cache/vdr/epgdata2vdr/files/ + @rm -f $(DESTDIR)/etc/cron.daily/epgdata2vdr-update + @rm -f $(DESTDIR)/usr/bin/epgdata2vdr + @rm -f $(DESTDIR)/usr/bin/epgdata2vdr.sh + @rm -f $(DESTDIR)/var/cache/vdr/epgdata2vdr/include/epgdata2vdr_channelmap.conf + @rm -f $(DESTDIR)/etc/vdr/vdr-addon-epgdata2vdr.conf diff -Nru vdr-addon-epgdata2vdr-0.0.1/.svn/text-base/update.c.svn-base vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/text-base/update.c.svn-base --- vdr-addon-epgdata2vdr-0.0.1/.svn/text-base/update.c.svn-base 1970-01-01 01:00:00.000000000 +0100 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/text-base/update.c.svn-base 2010-07-14 14:10:55.000000000 +0100 @@ -0,0 +1,661 @@ +/* + * update.c: epgdata plugin for the Video Disk Recorder + * + * See the README file for copyright information and how to reach the author. + * + */ +#include "update.h" + +using namespace std; + +cProcessEpg::cProcessEpg() +{ + LIBXML_TEST_VERSION +#ifdef USE_IMAGEMAGICK + InitializeMagick("epgdata2vdr-im"); +#endif +} + +cProcessEpg::~cProcessEpg() +{ + xmlCleanupParser(); +#ifdef USE_IMAGEMAGICK + DestroyMagick(); +#endif +} + +void cProcessEpg::readMaps(string confdir) +{ + cProcessEpg::chanmap = new cChannelMap(confdir); + cProcessEpg::datamap = new cDataMap(confdir); +} + +void cProcessEpg::processNode(xmlTextReaderPtr reader, xmlTextWriterPtr writer, UserDataPtr &user_data) +{ + UserDataPtr pud = user_data; + + struct tm tm; + xmlNodePtr node ; + xmlChar *value; + int retval; + + int type = xmlTextReaderNodeType(reader) ; + int depth = xmlTextReaderDepth(reader) ; + const char *name = (char *)xmlTextReaderConstName(reader); + + if (type == XML_READER_TYPE_ELEMENT && depth == 2) + { + node = xmlTextReaderExpand(reader); + value = xmlXPathCastNodeToString(node) ; // get the content and ... + node = NULL ; + retval = xmlTextReaderNext(reader); // move to closing tag on same level, we don't need to go deeper + + // decide where to put the value + // + if (!strcmp(name,"d0")) pud->broadcast_id = xmlStrdup(value); + else if (!strcmp(name,"d1")) pud->tvshow_id = xmlStrdup(value); + else if (!strcmp(name,"d2")) pud->tvchannel_id = atol((char *)value); + else if (!strcmp(name,"d3")) pud->regional = atol((char *)value); + else if (!strcmp(name,"d4")) { // starttime - next would be d5,d6: endtime, broadcast_day not required + sscanf((char *)value, "%04d-%02d-%02d %02d:%02d:%02d", &tm.tm_year, + &tm.tm_mon, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec); + tm.tm_year -= 1900; + tm.tm_mon -= 1; + tm.tm_zone = strdup("CET"); // assume date in XML to be CET + tm.tm_isdst = -1 ; // determine DST based on the time and locale + pud->starttime = mktime(&tm); //time_t as out of mktime is UTC on Linux + } + else if (!strcmp(name,"d7")) pud->tvshow_length = atol((char *)value) * 60; + else if (!strcmp(name,"d8")) { // VPS + if (strlen((char *)value) == 5) { + gmtime_r(&pud->starttime, &tm); + sscanf((char *)value, "%02d:%02d", &tm.tm_hour, &tm.tm_min); + tm.tm_sec = 0; + pud->vps = mktime(&tm); + } + else pud->vps = 0; + } + else if (!strcmp(name,"d9")) { + if (atol((char *)value)) pud->primetime = xmlCharStrdup("PrimeTime"); + else pud->primetime = xmlCharStrdup(""); + } + else if (!strcmp(name,"d10")) { + if (atol((char *)value)) pud->category = cProcessEpg::datamap->GetStr(atoi((char *)value)); + else pud->category = string(""); + } + else if (!strcmp(name,"d11")) { + if (atol((char *)value)) pud->technics_bw = xmlCharStrdup("Schwarz Weiß"); + else pud->technics_bw = xmlCharStrdup(""); + } + else if (!strcmp(name,"d12")) { + if (atol((char *)value)) pud->technics_co_channel = xmlCharStrdup("Zweikanalton"); + else pud->technics_co_channel = xmlCharStrdup(""); + } + else if (!strcmp(name,"d13")) { + if (atol((char *)value)) pud->technics_vt150 = xmlCharStrdup("Untertitel"); + else pud->technics_vt150 = xmlCharStrdup(""); + } + else if (!strcmp(name,"d14")) { + if (atol((char *)value)) pud->technics_coded = xmlCharStrdup("PayTV"); + else pud->technics_coded = xmlCharStrdup(""); + } + else if (!strcmp(name,"d15")) { + if (atol((char *)value)) pud->technics_blind = xmlCharStrdup("Hörfilm"); + else pud->technics_blind = xmlCharStrdup(""); + } + else if (!strcmp(name,"d16")) { + if (xmlStrlen(value)) { + pud->age_marker = xmlCharStrdup("FSK: "); + pud->age_marker = xmlStrcat(pud->age_marker, value); + } + else { + pud->age_marker = xmlCharStrdup(""); + } + } + else if (!strcmp(name,"d17")) { + switch(atol((char *)value)) { + case 0: pud->live = xmlCharStrdup(""); break; + case 1: pud->live = xmlCharStrdup("Live"); break; + case 2: pud->live = xmlCharStrdup("Wiederholung"); break; + case 3: pud->live = xmlCharStrdup("Zeitversetzte Ãœbertragung"); break; + default: + pud->live = xmlCharStrdup("") ; + fprintf(stderr, + "unknown live_id: %ld !\n", + atol((char *)value)); + } + } + else if (!strcmp(name,"d18")) { + if (xmlStrlen(value)) { + pud->tip = atoi((char *)value) ; + } + else { + pud->tip = 0 ; + } + } + else if (!strcmp(name,"d19")) pud->title = xmlStrdup(value); + else if (!strcmp(name,"d20")) pud->subtitle = xmlStrdup(value); + else if (!strcmp(name,"d21")) { // comment_long + if (xmlStrlen(value)) { + size_t size = xmlStrlen(value); + for (size_t i = 0; i < size; ++i) { //Replacing the \n and \r with | + if ((value[i] == '\n') || (value[i] == '\r')) value[i] = '|'; + } + } + pud->comment_long = xmlStrdup(value); + } + + else if (!strcmp(name,"d22")) { // comment_middle + if (xmlStrlen(value)) { + size_t size = xmlStrlen(value); + for (size_t i = 0; i < size; ++i) { //Replacing the \n and \r with | + if ((value[i] == '\n') || (value[i] == '\r')) value[i] = '|'; + } + } + pud->comment_middle = xmlStrdup(value); + } + + else if (!strcmp(name,"d23")) { // comment_short + if (xmlStrlen(value)) { + size_t size = xmlStrlen(value); + for (size_t i = 0; i < size; ++i) { //Replacing the \n and \r with | + if ((value[i] == '\n') || (value[i] == '\r')) value[i] = '|'; + } + } + pud->comment_short = xmlStrdup(value); + } + + else if (!strcmp(name,"d24")) { + if (xmlStrlen(value)) { + pud->themes = xmlCharStrdup("|"); + pud->themes = xmlStrcat(pud->themes,value); + } + else pud->themes = xmlCharStrdup(""); + } + else if (!strcmp(name,"d25")) { + if (atol((char *)value)) pud->genre = cProcessEpg::datamap->GetStr(atol((char *)value)); + else pud->genre = string(""); + } + else if (!strcmp(name,"d26")) { + if ((xmlStrlen(value) != 0) && (atol((char *)value) != 0)) { + pud->sequence = xmlCharStrdup("Folge: "); + pud->sequence = xmlStrcat(pud->sequence,value); + } + else pud->sequence = xmlCharStrdup(""); + } + else if (!strcmp(name,"d27")) { + if (atol((char *)value)) pud->technics_stereo = xmlCharStrdup("Stereo"); + else pud->technics_stereo = xmlCharStrdup(""); + } + else if (!strcmp(name,"d28")) { + if (atol((char *)value)) pud->technics_dolby = xmlCharStrdup("DolbyDigital"); + else pud->technics_dolby = xmlCharStrdup(""); + } + else if (!strcmp(name,"d29")) { + if (atol((char *)value)) pud->technics_wide = xmlCharStrdup("16:9"); + else pud->technics_wide = xmlCharStrdup(""); + } + else if (!strcmp(name,"d30")) { + switch(atol((char *)value)) { + case 0: pud->stars = xmlCharStrdup(""); break; + case 1: pud->stars = xmlCharStrdup("[*----] "); break; + case 2: pud->stars = xmlCharStrdup("[**---] "); break; + case 3: pud->stars = xmlCharStrdup("[***--] "); break; + case 4: pud->stars = xmlCharStrdup("[****-] "); break; + case 5: pud->stars = xmlCharStrdup("[*****] "); break; + default: + pud->stars = xmlCharStrdup(""); + fprintf(stderr, "unknown rating: %ld !\n", atol((char *)value)); + } + } + else if (!strcmp(name,"d31")) { + if (xmlStrlen(value)) { + pud->attribute = xmlCharStrdup("Prädikat: "); + pud->attribute = xmlStrcat(pud->attribute,value); + } + else pud->attribute = xmlCharStrdup(""); + } + else if (!strcmp(name,"d32")) { + if (xmlStrlen(value)) { + size_t size = xmlStrlen(value); // Replace "|" with "/" + for (size_t i = 0; i < size; ++i) { + if (value[i] == '|') value[i] = '/'; // Result = "USA/GB/D" + } + pud->country = xmlStrdup(value); + } + else pud->country = xmlCharStrdup(""); + } + else if (!strcmp(name,"d33")) { + if (xmlStrlen(value)) { + pud->year = xmlStrdup(value); + } + else pud->year = xmlCharStrdup(""); + } + else if (!strcmp(name,"d34")) { + if (xmlStrlen(value)) { + pud->moderator = xmlCharStrdup("|Moderator: "); + pud->moderator = xmlStrcat(pud->moderator,value); + } + else pud->moderator = xmlCharStrdup(""); + } + else if (!strcmp(name,"d35")) { + if (xmlStrlen(value)) { + pud->studio_guest = xmlCharStrdup("|Zu Gast: "); + pud->studio_guest = xmlStrcat(pud->studio_guest,value); + } + else pud->studio_guest = xmlCharStrdup(""); + } + else if (!strcmp(name,"d36")) { + if (xmlStrlen(value)) { + pud->regisseur = xmlCharStrdup("|Regie: "); + pud->regisseur = xmlStrcat(pud->regisseur,value); + } + else pud->regisseur = xmlCharStrdup(""); + } + else if (!strcmp(name,"d37")) { + if (xmlStrlen(value)) { + pud->actor = xmlCharStrdup("|Schauspieler: "); + pud->actor = xmlStrcat(pud->actor,value); + } + else pud->actor = xmlCharStrdup(""); + } + // d38, d39 - pictures don't exist ! (image_small, image_medium) + else if (!strcmp(name,"d40")) { + if (xmlStrlen(value)) { + string pic = pud->picdir + "/" + string((char *)value); + pud->sourcepic = pic.substr(0,pic.length() - 4) + ".png" ; + } + } + xmlFree(value); + value = NULL ; + } + else if (type == XML_READER_TYPE_END_ELEMENT && depth == 1) + { + // One event finished (data end tag reached), lets print the event! + // + + + if (!pud->regional) { + for (pud->chanindex = 0; pud->chanindex < cProcessEpg::chanmap->GetChanCnt(pud->tvchannel_id); pud->chanindex++) + { + // C: channelid channelname + // S19.2E-1-1101-28106 Das Erste + xmlTextWriterWriteFormatString(writer,"C %s\n", cProcessEpg::chanmap->GetChanStr(pud->tvchannel_id, pud->chanindex) ); + + // E: eventid starttime(unixdate) duration 0 0 + // 37237569 1236067500 3000 0 0 + xmlTextWriterWriteFormatString(writer,"E %s %ld %d 0\n", pud->broadcast_id, pud->starttime, pud->tvshow_length); + + //T: title + xmlTextWriterWriteFormatString(writer,"T %s\n", pud->title); + + // subtitle(episodetitle or the like) + xmlTextWriterWriteFormatString(writer,"S %s\n", pud->subtitle); + + //main text + xmlTextWriterWriteFormatString(writer,"D "); + xmlTextWriterWriteFormatString(writer,"%s",pud->stars); + switch(pud->tip) { + case 0: break; + case 1: xmlTextWriterWriteFormatString(writer,"[Spartentipp %s] ",pud->category.c_str()); + break; + case 2: xmlTextWriterWriteFormatString(writer,"[Genretipp %s] ",pud->genre.c_str()); + break; + case 3: xmlTextWriterWriteFormatString(writer,"[Tagestipp] "); + break; + default: + fprintf(stderr, "unknown tipflag: %d !\n", pud->tip); + } + if (xmlStrlen(pud->comment_short) != xmlStrlen(pud->comment_long) && xmlStrlen(pud->comment_short) > 0 ){ + xmlTextWriterWriteFormatString(writer,"Zusammenfassung: %s||", pud->comment_short); + } + if (xmlStrlen(pud->comment_long) > 0) xmlTextWriterWriteFormatString(writer,"%s", pud->comment_long); + + if (pud->category.size() > 0 && pud->genre.size() > 0) { + xmlTextWriterWriteFormatString(writer,"|%s - %s",pud->category.c_str(), pud->genre.c_str()); + } else if (pud->category.size() > 0) { + xmlTextWriterWriteFormatString(writer,"|%s",pud->category.c_str()); + } else if (pud->genre.size() > 0) { + xmlTextWriterWriteFormatString(writer,"|%s",pud->genre.c_str()); + } + if (pud->category.size() > 0 || pud->genre.size() > 0) { // Put secuence after category - genre + if (xmlStrlen(pud->sequence) > 0) xmlTextWriterWriteFormatString(writer,", %s",pud->sequence); + } else if (xmlStrlen(pud->sequence) > 0) xmlTextWriterWriteFormatString(writer,"|%s",pud->sequence); + if (xmlStrlen(pud->primetime) > 0) xmlTextWriterWriteFormatString(writer,"|%s",pud->primetime); + + if (xmlStrlen(pud->year) > 0 && xmlStrlen(pud->country) > 0) { + xmlTextWriterWriteFormatString(writer,"|%s %s.",pud->country, pud->year); // D 2005. 45 Min. + } else if (xmlStrlen(pud->country) > 0) { + xmlTextWriterWriteFormatString(writer,"|%s.",pud->country); // D. 45 Min. + } else if (xmlStrlen(pud->year) > 0 ) { + xmlTextWriterWriteFormatString(writer,"|%s.",pud->year); // 2005. 45 Min. + } + if (xmlStrlen(pud->country) > 0 || xmlStrlen(pud->year) > 0) xmlTextWriterWriteFormatString(writer," %d Min.",(pud->tvshow_length/60)); + else xmlTextWriterWriteFormatString(writer,"|%d Min.",(pud->tvshow_length/60)); + + if ((xmlStrlen(pud->technics_bw) > 0) || + (xmlStrlen(pud->technics_co_channel) > 0) || + (xmlStrlen(pud->technics_coded) > 0) || + (xmlStrlen(pud->technics_blind) > 0) || + (xmlStrlen(pud->technics_stereo) > 0) || + (xmlStrlen(pud->technics_dolby) > 0) || + (xmlStrlen(pud->technics_wide) > 0) ) { + xmlTextWriterWriteFormatString(writer,"|Technische Details: "); + if (xmlStrlen(pud->technics_bw) > 0) xmlTextWriterWriteFormatString(writer,"%s ",pud->technics_bw); + if (xmlStrlen(pud->technics_co_channel) > 0) xmlTextWriterWriteFormatString(writer,"%s ",pud->technics_co_channel); + if (xmlStrlen(pud->technics_vt150) > 0) xmlTextWriterWriteFormatString(writer,"%s ",pud->technics_vt150); + if (xmlStrlen(pud->technics_coded) > 0) xmlTextWriterWriteFormatString(writer,"%s ",pud->technics_coded); + if (xmlStrlen(pud->technics_blind) > 0) xmlTextWriterWriteFormatString(writer,"%s ",pud->technics_blind); + if (xmlStrlen(pud->technics_stereo) > 0) xmlTextWriterWriteFormatString(writer,"%s ",pud->technics_stereo); + if (xmlStrlen(pud->technics_dolby) > 0) xmlTextWriterWriteFormatString(writer,"%s ",pud->technics_dolby); + if (xmlStrlen(pud->technics_wide) > 0) xmlTextWriterWriteFormatString(writer,"%s ",pud->technics_wide); + } + if (xmlStrlen(pud->age_marker) > 0) xmlTextWriterWriteFormatString(writer,"|%s",pud->age_marker); + if (xmlStrlen(pud->live) > 0) xmlTextWriterWriteFormatString(writer,"|%s",pud->live); + if (xmlStrlen(pud->attribute) > 0) xmlTextWriterWriteFormatString(writer,"|%s",pud->attribute); + xmlTextWriterWriteFormatString(writer,"%s",pud->themes); + xmlTextWriterWriteFormatString(writer,"%s",pud->moderator); + xmlTextWriterWriteFormatString(writer,"%s",pud->studio_guest); + xmlTextWriterWriteFormatString(writer,"%s",pud->regisseur); + xmlTextWriterWriteFormatString(writer,"%s",pud->actor); + xmlTextWriterWriteFormatString(writer,"|Show-Id: %s",pud->tvshow_id); + xmlTextWriterWriteFormatString(writer,"\n"); // end of D (main information section, line breaks are '|' (pipe) in here ! + if (pud->vps) + { + xmlTextWriterWriteFormatString(writer,"V %ld\n", pud->vps); + } + + // end event and channel + xmlTextWriterWriteFormatString(writer,"e\n"); + xmlTextWriterWriteFormatString(writer,"c\n"); +#ifdef USE_IMAGEMAGICK + if (pud->sourcepic.length() > 0) { + string destpic = epgimagesdir + "/" + string((char *)pud->broadcast_id) + ".png"; + symlink(pud->sourcepic.c_str(),destpic.c_str()); + } +#endif + } + + // cleanup for next element + xmlFree(pud->primetime); pud->primetime = NULL ; + xmlFree(pud->technics_bw); pud->technics_bw = NULL; + xmlFree(pud->technics_co_channel); pud->technics_co_channel = NULL; + xmlFree(pud->technics_vt150); pud->technics_vt150 =NULL; + xmlFree(pud->technics_coded); pud->technics_coded = NULL; + xmlFree(pud->technics_blind); pud->technics_blind = NULL; + xmlFree(pud->age_marker); pud->age_marker = NULL; + xmlFree(pud->live); pud->live = NULL; + pud->tip = 0; + xmlFree(pud->title); pud->title = NULL; + xmlFree(pud->subtitle); pud->subtitle = NULL; + xmlFree(pud->comment_long); pud->comment_long = NULL; + xmlFree(pud->comment_middle); pud->comment_middle = NULL; + xmlFree(pud->comment_short); pud->comment_short = NULL; + xmlFree(pud->themes); pud->themes = NULL; + xmlFree(pud->sequence); pud->sequence = NULL; + xmlFree(pud->stars); pud->stars = NULL; + xmlFree(pud->attribute); pud->attribute = NULL; + xmlFree(pud->technics_stereo); pud->technics_stereo = NULL; + xmlFree(pud->technics_dolby); pud->technics_dolby = NULL; + xmlFree(pud->technics_wide); pud->technics_wide = NULL; + xmlFree(pud->country); pud->country = NULL; + xmlFree(pud->year); pud->year = NULL; + xmlFree(pud->moderator); pud->moderator = NULL; + xmlFree(pud->studio_guest); pud->studio_guest = NULL; + xmlFree(pud->regisseur); pud->regisseur = NULL; + xmlFree(pud->actor); pud->actor = NULL; + pud->sourcepic = "" ; + } + } + + +} + + + + + +int cProcessEpg::processFile(string confdir , char *filename) +{ + // unzip + int num_files; + int zipfilenum; + struct zip *pzip; + struct zip_stat zstat; + struct zip_file *zfile; + char *buffer; + const char *fname; + + // parse + xmlCharEncodingHandlerPtr encoder; + xmlOutputBufferPtr outdocbuffer ; + xmlTextReaderPtr reader; + xmlTextWriterPtr writer; + int parseretval; + + // temp store + UserData ud; + UserDataPtr user_data = &ud ; + + // in/output - filename e.g.: 20091014_20091009_de_qy.zip + string file = string(filename); + char *dir = dirname(filename); + string outfile = file.substr(0,file.length() -4) + ".epg"; + user_data->picdir = string(dir) + "/images" ; // Put all images in same dir + + // TODO: make it more error tolerant +#ifdef USE_IMAGEMAGICK + struct stat ds; + if ( !stat(user_data->picdir.c_str(), &ds) == 0) { + if (mkdir(user_data->picdir.c_str(), ACCESSPERMS) == -1) { + fprintf(stderr, "can't create picture directory %s\n", user_data->picdir.c_str()); + return -2; + } + } +#endif + + if ((pzip = zip_open(file.c_str(), 0, NULL)) == NULL) + { + fprintf(stderr, "error: can't open %s\n", file.c_str()); + return -2; + } + + num_files = zip_get_num_files(pzip); // get number of files in zip to iterate + + // first get dtd, then pictures then xml + + // extract the dtd + for (zipfilenum = 0; zipfilenum < num_files; zipfilenum++) { + if ((fname = zip_get_name(pzip, zipfilenum, 0)) == NULL) { // get the filename + fprintf(stderr, "error: can't get filename for index %d\n", zipfilenum); + return -3; + } + + if (!strcmp(fname + strlen(fname) - 4, ".dtd")) { + string dtdname = confdir + string(fname); + if (zip_stat_index(pzip, zipfilenum, 0, &zstat)) { + fprintf(stderr, "error: can't get stat for %s\n", fname); + return -4; + } + if ((buffer = (char *)malloc(zstat.size)) == NULL) { + fprintf(stderr, "error: can't get enough memory\n"); + return -5; + } + if ((zfile = zip_fopen_index(pzip, zipfilenum, 0)) == NULL) { + fprintf(stderr, "error: can't open zip file %s\n", fname); + return -7; + } + + // fill buffer from dtd + if (zip_fread(zfile, buffer, zstat.size) == -1 ) { + fprintf(stderr, "could not extract dtd file from %s.\n", dtdname.c_str()); + }; + zip_fclose(zfile); + + FILE *fh1 = NULL; + if ((fh1 = fopen(dtdname.c_str(), "w"))) { + fwrite(buffer, 1, zstat.size, fh1); + fclose(fh1); + } else { + fprintf(stderr, "could not write dtd file to confdir.\n"); + } + free(buffer); buffer = NULL; + } // if dtd + } // loop through zip file for dtd + +#ifdef USE_IMAGEMAGICK + // extract the pictures + for (zipfilenum = 0; zipfilenum < num_files; zipfilenum++) { + if ((fname = zip_get_name(pzip, zipfilenum, 0)) == NULL) { // get the filename + fprintf(stderr, "error: can't get filename for index %d\n", zipfilenum); + return -3; + } + + if (!strcmp(fname + strlen(fname) - 4, ".jpg")) { // if we have a picture + string outpic = user_data->picdir + "/" + string(fname).substr(0,string(fname).length() -4) + ".png"; + struct stat pic; + if ( !stat(outpic.c_str(), &pic) == 0) { // check if it exists allready, if yes, do nothing about it + if (zip_stat_index(pzip, zipfilenum, 0, &zstat)) { + fprintf(stderr, "error: can't get stat for %s\n", fname); + return -4; + } // are we able to find it in the zp file ? + if ((buffer = (char *)malloc(zstat.size)) == NULL) { + fprintf(stderr, "error: can't get enough memory\n"); + return -5; + } + if ((zfile = zip_fopen_index(pzip, zipfilenum, 0)) == NULL) { + fprintf(stderr, "error: can't open zip file %s\n", fname); + return -7; + } + if (zip_fread(zfile, buffer, zstat.size) == -1 ) { // fill buffer from jpg + fprintf(stderr, "could not extract jpg file from %s.\n", outfile.c_str()); + }; + zip_fclose(zfile); // close file after reading it from zip + + + + Image *image, *scaled_image; + ImageInfo *image_info; + ExceptionInfo *exception; + + if ((exception=(ExceptionInfo *) AcquireMagickMemory(sizeof(*exception))) == NULL){ + fprintf(stderr,"can't AcquireMagickMemory"); + return -4; + } + fprintf(stderr, "Processing %s\n", outpic.c_str()); + GetExceptionInfo(exception); + + image_info = CloneImageInfo((ImageInfo *) NULL); + image = BlobToImage(image_info, buffer, zstat.size, exception); + if (exception->severity != UndefinedException) + CatchException(exception); + + double factor = 120.0 / std::max(image->columns, image->rows); + scaled_image = ScaleImage(image, (int)(image->columns * factor + 0.5), (int)(image->rows * factor + 0.5), exception); + if (exception->severity != UndefinedException) + CatchException(exception); + + strcpy(scaled_image->filename, outpic.c_str()); + WriteImage(image_info, scaled_image); + + DestroyImage(image); + DestroyImage(scaled_image); + DestroyImageInfo(image_info); + DestroyExceptionInfo(exception); + free(buffer); buffer = NULL; + } + } + } // loop through zip file for pictures +#endif + + for (zipfilenum = 0; zipfilenum < num_files; zipfilenum++) { + if ((fname = zip_get_name(pzip, zipfilenum, 0)) == NULL) { // get the filename + fprintf(stderr, "error: can't get filename for index %d\n", zipfilenum); + return -3; + } + + if (!strcmp(fname + strlen(fname) - 4, ".xml")) { + if (zip_stat_index(pzip, zipfilenum, 0, &zstat)) { + fprintf(stderr, "error: can't get stat for %s\n", fname); + return -4; + } + if ((buffer = (char *)malloc(zstat.size)) == NULL) { + fprintf(stderr, "error: can't get enough memory\n"); + return -5; + } + if ((zfile = zip_fopen_index(pzip, zipfilenum, 0)) == NULL) { + fprintf(stderr, "error: can't open zip file %s\n", fname); + return -7; + } + + // fill buffer from xml + if (zip_fread(zfile, buffer, zstat.size) == -1 ) { + fprintf(stderr, "could not extract xml file from %s.\n", outfile.c_str()); + } + zip_fclose(zfile); + // start the processing + setlocale(LC_ALL, ""); + const char *encoding = nl_langinfo(CODESET); // get encoding + fprintf(stderr, "Encoding detected: %s \n", encoding ); + encoder = xmlFindCharEncodingHandler(encoding); + outdocbuffer = xmlOutputBufferCreateFilename (outfile.c_str(), encoder, 0); + if (outdocbuffer == NULL) { + xmlOutputBufferClose(outdocbuffer); + fprintf(stderr, "could not create file %s.\n",outfile.c_str()); + } + writer = xmlNewTextWriter(outdocbuffer); // create the writer + if (writer == NULL) { + xmlFreeTextWriter(writer); + fprintf(stderr, "could not create file output for %s.\n", outfile.c_str()); + } + reader = xmlReaderForMemory(buffer, zstat.size,confdir.c_str() ,"iso-8859-1" , XML_PARSE_NOENT | XML_PARSE_DTDLOAD); // create the reader + if (reader != NULL) { // reader created successfull + parseretval = xmlTextReaderRead(reader); + while (parseretval == 1) { + processNode(reader, writer, user_data); + parseretval = xmlTextReaderRead(reader); + } // parsing happens here + xmlFreeTextReader(reader); // first destroy the reader ... + xmlFreeTextWriter(writer); // ... and writer instance + if (parseretval != 0) { // something bad happened, cleanup + fprintf(stderr, "failed to parse %s,\n skipping rest of the file and cleanup\n",file.c_str()); + xmlFree(user_data->primetime); user_data->primetime = NULL ; + xmlFree(user_data->technics_bw); user_data->technics_bw = NULL; + xmlFree(user_data->technics_co_channel); user_data->technics_co_channel = NULL; + xmlFree(user_data->technics_vt150); user_data->technics_vt150 =NULL; + xmlFree(user_data->technics_coded); user_data->technics_coded = NULL; + xmlFree(user_data->technics_blind); user_data->technics_blind = NULL; + xmlFree(user_data->age_marker); user_data->age_marker = NULL; + xmlFree(user_data->live); user_data->live = NULL; + user_data->tip = 0; + xmlFree(user_data->title); user_data->title = NULL; + xmlFree(user_data->subtitle); user_data->subtitle = NULL; + xmlFree(user_data->comment_long); user_data->comment_long = NULL; + xmlFree(user_data->comment_middle); user_data->comment_middle = NULL; + xmlFree(user_data->comment_short); user_data->comment_short = NULL; + xmlFree(user_data->themes); user_data->themes = NULL; + xmlFree(user_data->sequence); user_data->sequence = NULL; + xmlFree(user_data->stars); user_data->stars = NULL; + xmlFree(user_data->attribute); user_data->attribute = NULL; + xmlFree(user_data->technics_stereo); user_data->technics_stereo = NULL; + xmlFree(user_data->technics_dolby); user_data->technics_dolby = NULL; + xmlFree(user_data->technics_wide); user_data->technics_wide = NULL; + xmlFree(user_data->country); user_data->country = NULL; + xmlFree(user_data->year); user_data->year = NULL; + xmlFree(user_data->moderator); user_data->moderator = NULL; + xmlFree(user_data->studio_guest); user_data->studio_guest = NULL; + xmlFree(user_data->regisseur); user_data->regisseur = NULL; + xmlFree(user_data->actor); user_data->actor = NULL; + } + } + else fprintf(stderr, "Unable to get xml\n"); + free(buffer); buffer = NULL; + } // if xml + } // loop through zip file for xml + + if (zip_close(pzip)) { + fprintf(stderr, "error: can't close zip file\n"); + return -9; + } // close the zip + return 0; // ... and done ! +} diff -Nru vdr-addon-epgdata2vdr-0.0.1/.svn/text-base/update.h.svn-base vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/text-base/update.h.svn-base --- vdr-addon-epgdata2vdr-0.0.1/.svn/text-base/update.h.svn-base 1970-01-01 01:00:00.000000000 +0100 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/.svn/text-base/update.h.svn-base 2010-07-14 14:10:55.000000000 +0100 @@ -0,0 +1,102 @@ +/* + * update.h: epgdata plugin for the Video Disk Recorder + * + * See the README file for copyright information and how to reach the author. + * + */ + +#ifndef _UPDATE__H +#define _UPDATE__H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef USE_IMAGEMAGICK +#include +#ifdef VERSION // Workaround for old and buggy imagemagick +#undef VERSION +#endif +#endif + +#include + +#include +#include +#include +#include + +#include "channelmap.h" +#include "datamap.h" + +typedef struct { +// mapping of external data + char *name; + int chanindex; +// data + // coming from map + string category; + string genre; + + //coming from XML + int regional; + int tvchannel_id; + time_t starttime; + time_t vps; + int tvshow_length; + xmlChar *broadcast_id; + xmlChar *tvshow_id; + xmlChar *primetime ; + xmlChar *technics_bw; + xmlChar *technics_co_channel; + xmlChar *technics_vt150; + xmlChar *technics_coded; + xmlChar *technics_blind; + xmlChar *age_marker; + xmlChar *live; + int tip; + xmlChar *title; + xmlChar *subtitle; + xmlChar *comment_long; + xmlChar *comment_middle; + xmlChar *comment_short; + xmlChar *themes; + xmlChar *sequence; + xmlChar *technics_stereo; + xmlChar *technics_dolby; + xmlChar *technics_wide; + xmlChar *stars; + xmlChar *attribute; + xmlChar *country; + xmlChar *moderator; + xmlChar *year; + xmlChar *studio_guest; + xmlChar *regisseur; + xmlChar *actor; + string picdir; + string sourcepic ; +} UserData, * UserDataPtr; +using namespace std; + +class cProcessEpg { +private: + void processNode(xmlTextReaderPtr reader, xmlTextWriterPtr writer, UserDataPtr &user_data); +public: + cProcessEpg(); + ~cProcessEpg(); + cChannelMap *chanmap; + cDataMap *datamap; + int processFile(string confdir, char *filename); + void readMaps(string confdir) ; + string confdir ; + string epgimagesdir ; +}; + +#endif diff -Nru vdr-addon-epgdata2vdr-0.0.1/update.c vdr-addon-epgdata2vdr-0.0.1+svn20100714/update.c --- vdr-addon-epgdata2vdr-0.0.1/update.c 2009-12-05 17:02:22.000000000 +0000 +++ vdr-addon-epgdata2vdr-0.0.1+svn20100714/update.c 2010-07-14 14:10:55.000000000 +0100 @@ -5,7 +5,7 @@ * */ #include "update.h" - + using namespace std; cProcessEpg::cProcessEpg() @@ -135,9 +135,36 @@ } else if (!strcmp(name,"d19")) pud->title = xmlStrdup(value); else if (!strcmp(name,"d20")) pud->subtitle = xmlStrdup(value); - else if (!strcmp(name,"d21")) pud->comment_long = xmlStrdup(value); - else if (!strcmp(name,"d22")) pud->comment_middle = xmlStrdup(value); - else if (!strcmp(name,"d23")) pud->comment_short = xmlStrdup(value); + else if (!strcmp(name,"d21")) { // comment_long + if (xmlStrlen(value)) { + size_t size = xmlStrlen(value); + for (size_t i = 0; i < size; ++i) { //Replacing the \n and \r with | + if ((value[i] == '\n') || (value[i] == '\r')) value[i] = '|'; + } + } + pud->comment_long = xmlStrdup(value); + } + + else if (!strcmp(name,"d22")) { // comment_middle + if (xmlStrlen(value)) { + size_t size = xmlStrlen(value); + for (size_t i = 0; i < size; ++i) { //Replacing the \n and \r with | + if ((value[i] == '\n') || (value[i] == '\r')) value[i] = '|'; + } + } + pud->comment_middle = xmlStrdup(value); + } + + else if (!strcmp(name,"d23")) { // comment_short + if (xmlStrlen(value)) { + size_t size = xmlStrlen(value); + for (size_t i = 0; i < size; ++i) { //Replacing the \n and \r with | + if ((value[i] == '\n') || (value[i] == '\r')) value[i] = '|'; + } + } + pud->comment_short = xmlStrdup(value); + } + else if (!strcmp(name,"d24")) { if (xmlStrlen(value)) { pud->themes = xmlCharStrdup("|"); @@ -440,11 +467,12 @@ // extract the dtd for (zipfilenum = 0; zipfilenum < num_files; zipfilenum++) { if ((fname = zip_get_name(pzip, zipfilenum, 0)) == NULL) { // get the filename - fprintf(stderr, "error: can't get filename for index %d\n", zipfilenum); - return -3; + fprintf(stderr, "error: can't get filename for index %d\n", zipfilenum); + return -3; } if (!strcmp(fname + strlen(fname) - 4, ".dtd")) { + string dtdname = confdir + string(fname); if (zip_stat_index(pzip, zipfilenum, 0, &zstat)) { fprintf(stderr, "error: can't get stat for %s\n", fname); return -4; @@ -460,11 +488,10 @@ // fill buffer from dtd if (zip_fread(zfile, buffer, zstat.size) == -1 ) { - fprintf(stderr, "could not extract dtd file from %s.\n", outfile.c_str()); + fprintf(stderr, "could not extract dtd file from %s.\n", dtdname.c_str()); }; zip_fclose(zfile); - string dtdname = confdir + string(fname); FILE *fh1 = NULL; if ((fh1 = fopen(dtdname.c_str(), "w"))) { fwrite(buffer, 1, zstat.size, fh1);