You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

197 lines
10 KiB

#! /bin/sh
# Haltestellenfahrplan anzeigen
# by theobald123
# Version: 2.1 Coolstream HD1
# *************************************************************************************
# * Datenzeile in einzelne Parameter aufteilen *
# *-----------------------------------------------------------------------------------*
# * Übergabeparameter : Datenzeile *
# *************************************************************************************
Parameter ()
{ pn=$#;p1=$1;p2=$2;p3=$3;p4=$4;p5=$5;p6=$6;p7=$7;p8=$8;p9=$9;p10=$10; }
# *************************************************************************************
# * Zeichen ersetzen, HTML-Tags entfernen, Leerzeilen entfernen *
# *-----------------------------------------------------------------------------------*
# * Übergabeparameter : Eingabedatei Ausgabedatei *
# *************************************************************************************
Substitution ()
{
sed -e 's/ä/ä/g' -e 's/ä/ä/g' -e 's/ä/ä/g' -e 's/ä/ä/g' \
-e 's/ö/ö/g' -e 's/ö/ö/g' -e 's/ö/ö/g' -e 's/ö/ö/g' \
-e 's/ü/ü/g' -e 's/ü/ü/g' -e 's/ü/ü/g' -e 's/ü/ü/g' \
-e 's/Ä/Ä/g' -e 's/Ä/Ä/g' -e 's/Ä/Ä/g' -e 's/Ä/Ä/g' \
-e 's/Ö/Ö/g' -e 's/Ö/Ö/g' -e 's/Ö/Ö/g' -e 's/Ö/Ö/g' \
-e 's/Ãœ/Ü/g' -e 's/Ü/Ü/g' -e 's/Ü/Ü/g' -e 's/Ü/Ü/g' \
-e 's/à/a/g' -e 's/á/a/g' -e 's/â/a/g' -e 's/ã/a/g' -e 's/å/a/g' -e 's/æ/ae/g' \
-e 's/à/a/g' -e 's/á/a/g' -e 's/â/a/g' -e 's/ã/a/g' -e 's/å/a/g' -e 's/æ/ae/g' \
-e 's/À/A/g' -e 's/Á/A/g' -e 's/Â/A/g' -e 's/Ã/A/g' -e 's/Å/A/g' -e 's/Æ/AE/g' \
-e 's/À/A/g' -e 's/Á/A/g' -e 's/Â/A/g' -e 's/Ã/A/g' -e 's/Å/A/g' -e 's/Æ/AE/g' \
-e 's/ç/c/g' -e 's/ç/c/g' \
-e 's/Ç/C/g' -e 's/Ç/C/g' \
-e 's/è/e/g' -e 's/é/e/g' -e 's/ê/e/g' -e 's/ë/e/g' \
-e 's/è/e/g' -e 's/é/e/g' -e 's/ê/e/g' -e 's/ë/e/g' \
-e 's/È/E/g' -e 's/É/E/g' -e 's/Ê/E/g' -e 's/Ë/E/g' \
-e 's/È/E/g' -e 's/É/E/g' -e 's/Ê/E/g' -e 's/Ë/E/g' \
-e 's/ì/i/g' -e 's/í/i/g' -e 's/î/i/g' -e 's/ï/i/g' \
-e 's/ì/i/g' -e 's/í/i/g' -e 's/î/i/g' -e 's/ï/i/g' \
-e 's/Ì/I/g' -e 's/Í/I/g' -e 's/Î/I/g' -e 's/Ï/I/g' \
-e 's/Ì/I/g' -e 's/Í/I/g' -e 's/Î/I/g' -e 's/Ï/I/g' \
-e 's/ñ/n/g' -e 's/ñ/n/g' \
-e 's/Ñ/N/g' -e 's/Ñ/N/g' \
-e 's/ò/o/g' -e 's/ó/o/g' -e 's/ô/o/g' -e 's/õ/o/g' -e 's/ø/o/g' \
-e 's/ò/o/g' -e 's/ó/o/g' -e 's/ô/o/g' -e 's/õ/o/g' -e 's/ø/o/g' \
-e 's/Ò/O/g' -e 's/Ó/O/g' -e 's/Ô/O/g' -e 's/Õ/O/g' -e 's/Ø/O/g' \
-e 's/Ò/O/g' -e 's/Ó/O/g' -e 's/Ô/O/g' -e 's/Õ/O/g' -e 's/×/O/g' \
-e 's/ù/u/g' -e 's/ú/u/g' -e 's/û/u/g' \
-e 's/ù/u/g' -e 's/ú/u/g' -e 's/û/u/g' \
-e 's/ý/y/g' -e 's/ý/y/g' \
-e 's/Ù/U/g' -e 's/Ú/U/g' -e 's/Û/U/g' \
-e 's/Ø/U/g' -e 's/Ù/U/g' -e 's/Ú/U/g' \
-e 's/Ü/Y/g' -e 's/Ý/Y/g' \
-e 's/ß/ß/g' -e 's/ß/ß/g' -e 's/ß/ß/g' -e 's/ß/ß/g' \
-e 's/ss¡/+/g' -e 's/„//g' -e 's/“//g' \
-e 's/é/e/g' -e 's/é/e/g' -e 's/É/E/g' -e 's/á/a/g' -e 's/î/i/g' -e 's/ñ/n/g' \
-e 's/0/0/g' -e 's/1/1/g' -e 's/2/2/g' -e 's/3/3/g' -e 's/4/4/g' -e 's/5/5/g' -e 's/6/6/g' -e 's/7/7/g' -e 's/8/8/g' -e 's/9/9/g' \
-e 's/A/A/g' -e 's/B/B/g' -e 's/C/C/g' -e 's/D/D/g' -e 's/E/E/g' -e 's/F/F/g' -e 's/G/G/g' -e 's/H/H/g' -e 's/I/I/g' -e 's/J/J/g' -e 's/K/K/g' -e 's/L/L/g' -e 's/M/M/g' -e 's/N/N/g' -e 's/O/O/g' -e 's/P/P/g' -e 's/Q/Q/g' -e 's/R/R/g' -e 's/S/S/g' -e 's/T/T/g' -e 's/U/U/g' -e 's/V/V/g' -e 's/W/W/g' -e 's/X/X/g' -e 's/Y/Y/g' -e 's/Z/Z/g' \
-e 's/a/a/g' -e 's/b/b/g' -e 's/c/c/g' -e 's/d/d/g' -e 's/e/e/g' -e 's/f/f/g' -e 's/g/g/g' -e 's/h/h/g' -e 's/i/i/g' -e 's/j/j/g' -e 's/k/k/g' -e 's/l/l/g' -e 's/m/m/g' -e 's/n/n/g' -e 's/o/o/g' -e 's/p/p/g' -e 's/q/q/g' -e 's/r/r/g' -e 's/s/s/g' -e 's/t/t/g' -e 's/u/u/g' -e 's/v/v/g' -e 's/w/w/g' -e 's/x/x/g' -e 's/y/y/g' -e 's/z/z/g' \
-e 's/°/°/g' -e 's/°/°/g' -e 's/°/°/g' \
-e 's/&/\&/g' \
-e 's/"/\"/g' -e 's/„/\"/g' -e 's/“/\"/g' -e "s/'/\"/g" -e 's/'/\"/g' \
-e 's/>/>/g' \
-e 's/&lt;/</g' \
-e 's/&nbsp;/ /g' \
-e 's/&plusmn;/+\/-/g' \
-e 's/&euro;/EUR/g' \
-e 's/<br>/ /g' \
-e 's/<[^>]*>//g' \
-e '/^[^0-9a-zA-Z!-\/]*$/d' \
$1 > $2
}
# *************************************************************************************
# * Einlesen Haltestellenname *
# *************************************************************************************
getStation ()
{
conf=/var/tuxbox/config/Haltestelle.input
if [ -s $conf ] ; then
Station=`cat "$conf"`
else
Station=" "
fi
Station=`input l='@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@' t='Haltestelle' d="$Station" c=20 k=1`
Station=`echo "$Station"`
if [ "$Station" != "" ] ; then
echo $Station > $conf
echo $Station > /tmp/Fahrplan.data
sed -e 's/ /%20/g' /tmp/Fahrplan.data > /tmp/Fahrplan1.data
Station=`cat "/tmp/Fahrplan1.data"`
else
exit
fi
}
# *************************************************************************************
# * Haltestelle ermitteln *
# *************************************************************************************
getHaltestelle ()
{
rm /tmp/fahrplan5.data
sed -n "/<select/,/<\/select/ p" /tmp/Fahrplan.data > /tmp/Fahrplan1.data
anzahl=`sed -n -e "/<\/select/ =" /tmp/Fahrplan1.data`
Parameter $anzahl
ende=$p1; ende=`expr "$ende" - 1`;
sed -n 2,"$ende"p /tmp/Fahrplan1.data > /tmp/Fahrplan2.data
sed -e 's/^.*="//g' -e 's/ */ /g' -e 's/".*$//g' /tmp/Fahrplan2.data > /tmp/Fahrplan3.data
Substitution /tmp/Fahrplan3.data /tmp/Fahrplan4.data
Zeilen=`sed -n -e "$ =" /tmp/Fahrplan4.data`; Zeilen=`expr "$Zeilen"`
# *-----------------------------------------------------------------------------------*
# * Aufbau der Datei für Shellexec *
# *-----------------------------------------------------------------------------------*
echo FONT=/share/fonts/neutrino.ttf > /tmp/Fahrplan.conf
echo FONTSIZE=22 >> /tmp/Fahrplan.conf
echo HIGHT=480 >> /tmp/Fahrplan.conf
echo WIDTH=800 >> /tmp/Fahrplan.conf
echo LINESPP=10 >> /tmp/Fahrplan.conf
echo "MENU=Ihre Eingabe ist nicht eindeutig. Bitte wählen:" >> /tmp/Fahrplan.conf
count=1;
while [ "$count" -le "$Zeilen" ]; do
a1=`sed -n "$count"p /tmp/Fahrplan4.data`
a2=`sed -n -e "$count s/#.*$// p" /tmp/Fahrplan4.data`
echo "ACTION='$a2',echo '$a1' > /tmp/Fahrplan5.data" >> /tmp/Fahrplan.conf
count=`expr "$count" + 1`;
done
echo "ENDMENU" >> /tmp/Fahrplan.conf
shellexec /tmp/Fahrplan.conf
if [ -s /tmp/Fahrplan5.data ] ; then
a1=`sed -n -e "1 s/#.*$// p" /tmp/Fahrplan5.data`
a2=`sed -n -e "1 s/^.*#// p" /tmp/Fahrplan5.data`
echo $a1 > $conf
wget -q -O /tmp/Fahrplan.data "http://mobile.bahn.de/bin/mobil/bhftafel.exe/dox?si=$a2&bt=dep&p=$v1$v2$v3$v4$v5$v6$v7$v8$v9&max=20&start=yes"
else
continue
fi
}
# *************************************************************************************
# * Haltestellenfahrplan anzeigen *
# *************************************************************************************
displayFahrplan ()
{
sed -e 's/<span class="bold"><\/span>/<span class="bold">-<\/span>/g' \
-e 's/<[^>]*>//g' \
-e 's/&nbsp;//g' -e 's/&#223;/ß/g' -e 's/&#196;/Ä/g' -e 's/&#214;/Ö/g' -e 's/&#220;/Ü/g' -e 's/&#228;/ä/g' -e 's/&#246;/ö/g' -e 's/&#252;/ü/g' \
-e 's/\&.*;//g' /tmp/Fahrplan.data > /tmp/Fahrplan1.data #HTML-Tags entfernen; Sonderzeichen ersetzen
sed -e '/^[^0-9a-zA-Z!+-\/]*$/d' -e '/^Gl./d' /tmp/Fahrplan1.data > /tmp/Fahrplan2.data #Leerzeilen und Gleisangaben entfernen
#Anfang der Daten ermitteln
Head=`sed -n /Aktuell/p /tmp/Fahrplan2.data`
Start=`sed -n -e "/Früher/ =" /tmp/Fahrplan2.data`
Ende=`sed -n -e "/Später/ =" /tmp/Fahrplan2.data`
Ende=`expr "$Ende" - 1`
echo ~T0350Linie~T0450Abfahrt~T0550Richtung > /tmp/Fahrplan3.data
step=3; tab1=`expr "$Start" + 1`; tab2=`expr "$Start" + 2`; tab3=`expr "$Start" + 3`; anz=0
while [ $tab1 -lt $Ende ]; do
a1=`sed -n "$tab1"p /tmp/Fahrplan2.data` #Linie
a3=`sed -n "$tab2"p /tmp/Fahrplan2.data` #Abfahrtszeit
a2=`sed -n "$tab3"p /tmp/Fahrplan2.data` #Richtung
echo ~T0350$a1~T0450$a2~T0550$a3 >> /tmp/Fahrplan3.data
tab1=`expr "$tab1" + $step`; tab2=`expr "$tab2" + $step`; tab3=`expr "$tab3" + $step`; anz=`expr "$anz" + 1`
if [ "$anz" = "20" ]; then
tab1=$Ende
fi
done
msgbox title="$Head" size=22 timeout=600 popup=/tmp/Fahrplan3.data #Tabelle anzeigen
rm /tmp/Fahrplan*.data
exit
}
# Verkehrsmittel (1=auswählen, 0=nicht auswählen)
v1=1 # ICE
v2=1 # IC/EC
v3=1 # IR/D
v4=1 # RE/RB
v5=1 # S-Bahn
v6=1 # Busse
v7=1 # Schiff
v8=1 # U-Bahn
v9=1 # Straßenbahn
while [ 1 -eq 1 ]; do
getStation
wget -q -O /tmp/Fahrplan.data "http://mobile.bahn.de/bin/mobil/bhftafel.exe/dox?input=$Station&bt=dep&p=$v1$v2$v3$v4$v5$v6$v7$v8$v9&max=20&start=yes"
eindeutig=`sed -n -e "/Ihre Eingabe ist nicht eindeutig./ =" /tmp/Fahrplan.data`
if [ "$eindeutig" = "" ]; then
displayFahrplan
else
getHaltestelle
displayFahrplan
fi
done
exit