forked from dosshell/nkalh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnkalh
executable file
·61 lines (48 loc) · 1.28 KB
/
nkalh
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
#!/bin/bash
checkURL(){
if [ -z $1 ]; then
echo "No streams found" >&2
exit 254
fi
}
checkHost(){
echo "$1" | grep "$2" > /dev/null 2>&1
}
if [ -z $1 ]; then
echo "Usage: $0 url [file]" >&2
exit 255
fi
CONTENT=$(wget -O - -o /dev/null $1)
CONTENT_URL=$1
echo "$CONTENT" | grep "<title>.*</title>" > /dev/null 2>&1
if [ $? -eq 0 ]; then
OUT_FILE="$(echo "$CONTENT" | grep "<title>.*</title>" | sed 's/^[ \t]*//;s/[ \t]*$//' | sed -s 's|^<title>\(.*\)</title>$|\1|g').flv"
fi
if [ -z $2 ]; then
if [ -z "$OUT_FILE" ]; then
echo "Unable to generate filename, you have to specify one." >&2
exit 253
else
OUT_FILE=$( echo $OUT_FILE | sed "s|ö|ö|g; s|ä|ä|g; s|å|å|g; s|Å|Å|g; s|Ä|Å|g; s|&Oring;|Ö|g;" )
fi
else
OUT_FILE=$2
fi
checkHost $1 "svtplay.se"
if [ $? == 0 ]; then
echo $CONTENT_URL | grep "type=embed" > /dev/null 2>&1
if [ $? -gt 0 ]; then
echo $CONTENT_URL | grep "?" > /dev/null 2>&1
if [ $? == 0 ]; then
CONTENT_URL="$CONTENT_URL&type=embed"
else
CONTENT_URL="$CONTENT_URL?type=embed"
fi
fi
URL=$(wget "$CONTENT_URL" -O - -o /dev/null | egrep -o "rtmp[e]*[^,]+" | sed -s 's/\"//g' | sort -ru | head -n 1)
checkURL $URL
rtmpdump -r "$URL" --resume -o "$OUT_FILE"
exit 0
fi
echo "Unsupported service" >&2
exit 1