tatort-dl is a shell-scripted CLI tool for downloading films from http://www.ardmediathek.de/.
It's named after it's main purpose: to download Tatorts ;) However - as of Jan 25 2010 - it also works with any other content on http://www.ardmediathek.de/.
Please read the license under “help” at ardmediathek.de before using tatort-dl. Some Films or Clips are only available during certain hours and/or time-periods.
tatort-dl will work on all systems supporting bash, curl and rtmpdump. It's developed for GNU/Linux and may work on OSX and BSD.
Download: tatort-dl.sh (latest).
Save it as tatort-dl in ~/bin or /usr/local/bin/ and mark it as executable chmod +x tatort-dl.
You need to have rtmpdump and curl software installed (sudo apt-get install rtmpdump curl).
Usage: tatort-dl <ARDmediathek-URL> [out-file] The default out-file name is ./format<ard-uid>.f4v Example: tatort-dl "http://www.ardmediathek.de/ard/servlet/content/3517136?documentId=3701294"
#!/bin/bash
URL=$(echo -e "$1" | grep "^http")
OUTFILE=$2
INTERACTIVE=yes
RTMPDUMP=rtmpdump
RTMPDUMPOPTS=""
#RTMPDUMPOPTS+=" --live"
#RTMPDUMPOPTS+=" --resume"
#RTMPDUMPOPTS+=" --quiet"
if test -z "$URL" ; then
echo -e "Error: missing or invalid parameters\n\nUsage:\n $0 <ARDmediathek-URL> [out-file]\nThe deafult out-file name is ./format<ard-uid>.f4v\n\nExample:\n $0 \"http://www.ardmediathek.de/ard/servlet/content/3517136?documentId=3701294\"\n" >&2;
exit 1
fi
echo -en "curl \"$URL\" .."
RTMPURLS=$(curl -s "$URL" | grep -i rtmp)
if test -z "$RTMPURLS" ; then
echo -e "\nError: no 'rtmp://' URLs were found on the given Page.\n"
exit 1;
fi
COUNT=$(echo -e "$RTMPURLS" | wc -l)
echo -e " ..found $COUNT RTMP URL(s)."
urldecode(){
echo -e "$(sed 'y/+/ /; s/%/\\x/g')"
}
FLASH=$(echo "$RTMPURLS" | grep flashvars | tail -n1)
if test -n "$FLASH"; then
RTMPURL=$(echo -ne "$FLASH" \
| sed 's/^.*streamer=\([^&]*\)&.*$/\1/g' \
| urldecode)
PLAYPATH=$(echo -ne "$FLASH" \
| sed 's/^.*file=\([^&]*\)&.*$/\1/g' \
| urldecode)
#echo "RTMP: $RTMPURL"
#echo "FILE: $PLAYPATH"
else
# try high-qualty first
PARAM=$(echo "$RTMPURLS" | grep Web-L)
# fall-back to medium-qualty
if test -z "$PARAM"; then
PARAM=$(echo "$RTMPURLS" | grep Web-M)
fi
# 2nd fall-back: use any rtmp URL
if test -z "$PARAM"; then
PARAM=$(echo "$RTMPURLS" | tail -n 1 )
fi
RTMPURL=$(echo -ne "$PARAM" | sed 's/^.*"\(rtmp[t]*:[^"]*\)",.*$/\1/g')
PLAYPATH=$(echo -ne "$PARAM" | sed 's/^.*"\(mp4:[^"]*\)").*$/\1/g')
fi
test -z "$RTMPURL" && RTMPURL="rtmp://vod.daserste.de/ardfs/"
if test -z "$OUTFILE"; then
OUTFILE=$(echo -ne "$PLAYPATH" | sed 's/^mp4:.*\/\([^\/?]*\)\?.*$/\1/g')
OUTFILE=$(echo -ne "$OUTFILE" \
| sed 's/^.*\///g' \
| sed 's/\?.*$//g' \
| sed 's/mp4://g' \
| sed 's/\.f4v$//' \
| sed 's/\.flv$//'\
)
OUTFILE="${OUTFILE}.flv"
fi
echo
echo "Parameters:"
echo " RTMP-URL : $RTMPURL"
echo " Playpath : $PLAYPATH"
echo " Saving to: $OUTFILE"
echo -n " PWD : "
pwd
echo
if test -z "$PLAYPATH -o -z "$OUTFILE ; then
echo "Error: empty playpath or blank output filename."
exit 1
fi
if test -e "$OUTFILE"; then
echo "WARNING: output file "$OUTFILE" exists."
if test -n "$INTERACTIVE"; then
echo -n "[A]bort/[d]elete it/[r]esume? [A/d/r]? "
read -n 1 VAL
echo
if test "$VAL" == "d"; then
rm -i "$OUTFILE";
elif test "$VAL" == "r"; then
RTMPDUMPOPTS+=" --resume"
else
exit;
fi
else # NON-INTERACTIVE
echo "Error: file exists. bailing out."
exit
fi
fi
if test -n "$INTERACTIVE"; then
echo "rtmpdump command-line:"
echo " #$RTMPDUMP $RTMPDUMPOPTS -o \"$OUTFILE\" --playpath \"$PLAYPATH\" -r $RTMPURL"
echo
echo -n " Start Download ? [Y/n] "
read -n 1 VAL
echo
if test "$VAL" == "n" -o "$VAL" == "N"; then
exit;
fi
fi
$RTMPDUMP $RTMPDUMPOPTS -o "$OUTFILE" --playpath "$PLAYPATH" -r $RTMPURL
echo
ls -l "$OUTFILE"