Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 77 lines (60 sloc) 2.12 KB
#!/bin/bash
# ard-mediathek-downloader - A downloader for the german ard-mediathek
# Copyright (C) 2011 Dominik Bruhn
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#Configuration:
targetdir="${HOME}/Downloads/ard/"
targettype="mp4" #Could also be 'mkv'
#=============
if [ ! -d "$targetdir" ]; then
echo "Targetdir $targetdir does not exist"
exit 1
fi
if [ ! -e "$targetdir" ]; then
echo "Targetdir $targetdir is not writeable"
exit 1
fi
url="$1"
if [ -z "$url" ]; then
echo "First parameter must be a url from the 'ARD-Mediathek'"
exit 2
fi
htmldata=$(curl -s "$url")
echo "Extracting HD Movie Param"
mline=$(echo "$htmldata" | grep "mediaCollection.addMediaStream(0, " | tail -n 1)
vod=$(echo "$mline" | grep -oE '"rtmp([^\"]*)"')
vod=${vod:1:-1}
path=$(echo "$mline" | grep -oE '"mp4:([^\"]*)"')
path=${path:1:-1}
title=$(echo "$htmldata" | grep -oE '<title>(.*)</title>' | sed 's/<title>\(ARD Mediathek: \|Das Erste Mediathek \[ARD\] - \)\(.*\)<\/title>/\2/g' | sed 's/ | Das Erste//g')
ofilename=$(echo "$title" | tr -cd "A-Za-z0-9äöüÄÖÜ_ -")
ofilename=${ofilename:0:100}
fifo="/tmp/${ofilename}.flv"
ofile="$targetdir/${ofilename}.${targettype}"
#Debugging
echo "Extracted Download-Params: "
echo " -VOD: $vod"
echo " -PATH: $path"
echo " -Title: $title"
echo " -FNAME: $ofilename"
if [ "x$2" == "x--dry-run" ]; then
exit 2
fi
echo "Downloading $url"
rm -f "$fifo"
rm -f "$ofile"
mkfifo "$fifo"
rtmpdump -r "$vod" -y "$path" -o "$fifo" &
ffmpeg -vcodec copy -acodec copy -y -i "$fifo" "$ofile"