forked from devurandom/zdf-dl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzdf-dl
executable file
·78 lines (65 loc) · 2.67 KB
/
zdf-dl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/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}