summaryrefslogtreecommitdiff
path: root/templates/bin/ruutu-dl
blob: 2d2f0aba0066d201064303f3d2ced44622e79217 (plain)
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
#!/bin/sh

# Downloads a video stream from ruutu.fi to stdout using
# rtmpdump(-yle). The first parameter is the rtmp URL, the second
# parameter is the video page URL, the optional third parameter is the
# output file.

RTMPDUMP=

which rtmpdump > /dev/null 2>&1
if [ $? = 0 ]; then
    RTMPDUMP=rtmpdump
else
    which rtmpdump-yle > /dev/null 2>&1
    if [ $? = 0 ]; then
	RTMPDUMP=rtmpdump-yle
    fi
fi

if [ "x$RTMPDUMP" = "x" ]; then
    echo "ERROR: neither rtmpdump nor rtmpdump-yle on \$PATH" 1>&2
    exit 1
fi

if [ "x$1" = "x" ]; then
    echo "Expected rtmp URL as parameter" 1>&2
    exit 1
fi

if [ "x$2" = "x" ]; then
    echo "Expected ruutu.fi video page URL as parameter" 1>&2
    exit 1
fi

OUTFILE="$3"
if [ "x$OUTFILE" = "x" ]; then
    OUTFILE=-
fi

$RTMPDUMP -q -r "$1" -W http://n.sestatic.fi/sites/all/modules/media/Nelonen_mediaplayer_static_latest.swf -p "$2" -o "$OUTFILE"

exit $?