summaryrefslogtreecommitdiff
path: root/templates/bin/yle-dl
blob: 89506075c206c369a25be9d0ae78e7901fc03f21 (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
#!/bin/sh

# Downloads a video stream from Yle Areena to stdout using yle-dl
# script. The first parameter is the video page URL. Second parameter
# is the output file (optional).

YLEDL=yle-dl

which $YLEDL > /dev/null 2>&1
if [ $? != 0 ]; then
    echo "ERROR: $YLEDL is not on \$PATH" 1>&2
    echo "Install yle-dl from https://github.com/aajanki/yle-dl" 1>&2
    exit 1
fi

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

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

$YLEDL $1 -q -o "$OUTFILE"

exit $?