Personal tools
You are here: Home Unix Network and Scripts DIE ZEIT als mp3
Document Actions

DIE ZEIT als mp3

by admin last modified 2008-06-14 20:25

DIE ZEIT stellt Abonenten einige Artikel als mp3 Datei zur Verfügung. Mit einem Script, eingebunden in einen cronjob, bekommt man die Dateien jeden Donnerstag frisch auf den Frühstückstisch. Username und Passwort müssen natürlich noch angepasst werden.

/etc/crontab

Dieser Eintrag startet das Script Donnerstags um 09:30 Uhr.
# m h dom mon dow user  command
30 09    * * 4   renner    /usr/local/bin/zeit.sh

/usr/local/bin/zeit.sh

Hier das Script, das mit beliebigen Rechen aufgerufen wird. Wichtig nur, dass Schreibrechte auf das Verzeichnis existieren.
#!/bin/sh

# get the mp3 files from http://www.zeit.de

# some variables
SERVER=hoeren.zeit.de
USER=joedo
PASS=foobar
BASEPATH=/global/vx/ZEIT/`date +%Y`
METHOD=http

TIME_START=`date +%s`

# get the list of files ...
echo contacting $SERVER, this may take a while .....
wget -O /tmp/aktuell.html --proxy=on --http-user=$USER --http-passwd=$PASS http://$SERVER/aktuell.html 2> /dev/null

# create the directory if nessesary
mkdir -p $BASEPATH && cd $BASEPATH

# parse the list
if [ -f "/tmp/aktuell.html" ] ; then
        echo parsing aktuell.html
        FILE=`cat /tmp/aktuell.html | grep "cgi-bin" | grep Audiofiles_DIE_ZEIT_ | cut -d '"' -f6 | cut -d '"' -f1`
        DATEI=`echo $FILE | cut -d "/" -f7`
        rm /tmp/aktuell.html
else
        echo aktuell.html not found ..... better exit
        exit
fi

if [ -f "$DATEI" ] ; then
        echo found $DATEI, no need to get it twice
        exit
fi

echo getting $DATEI, this may take a while
# get the zip file
wget --proxy=on --http-user=$USER --http-passwd=$PASS http://$SERVER/$FILE #2> /dev/null

unzip $DATEI #2> /dev/null

TIME_STOP=`date +%s`


TIME=`echo "($TIME_STOP - $TIME_START) /60 | bc`
echo done. Took $TIME minutes

exit 0



Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: