#! /bin/sh
#
# Ladet die aktuellen Spielergebnisse der Champions Leage herunter
# Created by cHrIsZ
# 27. Februar 2007

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

#DATADIR=$1
DATADIR=/etc/vdr/plugins/sport
CHAMPRESULTURL="http://sport.ard.de/sp/layout/php/ticker/index.phtml?ea=cl07"
GET1="wget -O - -q"
SORT="$DATADIR/CL_Ergebnisse.pl"
echo "CL_Ergebnisse.sh DATADIR = $DATADIR"

#CONTENTCHAMP=`$GET1 $CHAMPRESULTURL |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 "<.*>"` 
CONTENTCHAMP=`$GET1 $CHAMPRESULTURL |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/\(.*-.*\)/\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 "<.*>"` 




CHAMPRESULTFILE="$DATADIR/CL_Ergebnisse.txt"


IFS=""

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

echo $CONTENTCHAMP | $SORT > $CHAMPRESULTFILE

