#! /bin/sh
#
# Ladet die aktuellen Spielergebnisse des UEFA-Cup's herunter
# Created by cHrIsZ
# 27. Februar 2007

PATH=$PATH:/usr/bin/:/usr/local/bin

#DATADIR=$1
DATADIR=/etc/vdr/plugins/sport
SORT="$DATADIR/UEFA_Ergebnisse.pl"
UEFARESULTURL="http://sport.ard.de/sp/layout/php/ticker/index.phtml?ea=uefa07"
GET1="wget -O - -q"

echo "UEFA_Ergebnisse.sh DATADIR = $DATADIR"

#CONTENTDFB=`$GET1 $UEFARESULTURL |sed -e '/<tr.*td.*/!d' -e '/<tr.*td.*/{n;!p;}'|sed  -e 's/.*[0-9][0-9][0-9]">/ /' -e 's/<\/a><\/td>/ /' -e 's/.*stat.*[0-9,:]">//' -e 's/<.*\/td>//' -e 's/.*\..*[0-9][0-9]/0:0/g' -e'/^[0-9]/!s/:/-/g' -e 's/\(.*-.*\)/\1\n/' |grep -v "<.*>"` 
CONTENTUEFA=`$GET1 $UEFARESULTURL |sed -e '/<tr.*td.*/!d' -e '/<tr.*td.*/{n;!p;}'|sed  -e 's/Kickers/Ki./' -e 's/.*[0-9][0-9][0-9]">/ /' -e 's/<\/a><\/td>/ /' -e 's/.*stat.*[0-9,:]">//' -e 's/<.*\/td>//' -e 's/\(.*-.*\)/\1\n/' -e 's/Celtic/Cel./' -e 's/United/United/' -e 's/Eintracht Frankfurt/Eint. Frankfurt/' -e 's/Borussia/Bor. /' -e 's/Bayer 04 Leverkusen/Bay. Leverkusen/' -e 's/DSC Arminia Bielefeld/Arm. Bielefeld/' -e 's/TSV Alemannia Aachen/Alem. Aachen/' |grep -v "<.*>"` 


UEFARESULTFILE="$DATADIR/UEFA_Ergebnisse.txt"


IFS=""

for i in $CONTENTUEFA
do
  START=`echo "$i"|grep \-`
  if [ "$START"x != "x" ]
  then
    echo "$i"
    echo ""
  else
    echo ""
    echo "$i"
  fi
done

echo $CONTENTUEFA | $SORT > $UEFARESULTFILE

