#!/bin/bash # Copyright 2012 Christoph Langner # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ######### About # zdf-dl let's you download video streams from the no-flash version # of the zdf mediathek to your harddisk using curl and mplayer # http://www.zdf.de/ZDFmediathek/hauptnavigation/startseite?flash=off ######### Dependencies # - Curl # - xmlstarlet ######### Changelog # Version 1.1 # - Adapted to current zdf mediatek (Thanks Markus!) # - New dependency xmlstarlet # Version 1.0.2 # - Check if HTML-Version is used # - Disabled lirc-support in mplayer, removing error message # - Curl stuff before mplayer call not necessary # Version 1.0.1 # - Get filename out of url # - Fixed variables # Version 1.0 # - Initial Release ## Check for adb and imagemagick command -v curl >/dev/null 2>&1 || { echo >&2 "Please install curl. Aborting."; exit 1; } command -v xmlstarlet >/dev/null 2>&1 || { echo >&2 "Please install xmlstarlet. Aborting."; exit 1; } # Get url to video stream out of the no flash version of the zdf mediathek url_noflash="$1" url_stream=$(curl -s ${url_noflash} | grep asx | grep -o 'http://[^"]*') # Check if No Flash Mediathek is used if [[ "${url_noflash}" != *flash=off* ]] then echo "Die übergebene URL zeigt nicht auf die HTML-Version der Mediathek!"; echo "Bitte klicke auf der Webseite der Mediathek links unten auf \"HTML-Version\" "; echo "oder öffne die folgende URL im Browser:" echo "http://www.zdf.de/ZDFmediathek/hauptnavigation/startseite?flash=off" exit fi mov_id=$(echo "${url_noflash}" | grep -oP "(?<=http://www.zdf.de/ZDFmediathek/beitrag/video/)[^/]+") echo "Film id: ${mov_id}" url_xmlfile=$(echo "http://www.zdf.de/ZDFmediathek/xmlservice/web/beitragsDetails?id=${mov_id}") echo "Pfad xml-Datei: ${url_xmlfile}" xmlfile=$(curl -s ${url_xmlfile}) # Extract from xml-file the elements "formitaet", then search for "veryhigh", then for filename pattern url_stream=$(echo ${xmlfile} | xmlstarlet sel -t -m '//formitaet' -v . -n | grep -n1 'veryhigh' | grep -o 'http://rodl.zdf.de/none/zdf[^"]*.mp4') # Get stream and save it to disk echo "Lade ${url_stream} herunter, bitte haben Sie etwas Geduld..." wget -c ${url_stream}