-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvip-channellist
71 lines (59 loc) · 1.56 KB
/
vip-channellist
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
#!/usr/bin/env bash
#Usage
if [ $# -eq 0 ] || [ $1 = '-h' ] ; then
echo 'Usage: vip211_channellist STB_IP'
echo 'Optional parameters'
echo '--curl will return the xml string'
echo '--wget will download the file as channels.xml'
echo 'Example: vip222k_changer 10.0.0.123 --curl'
exit 0
fi
# Basic Settings
HOST=$1
PORT='49200'
QUERY='upnp/control/EchoSTB2'
SERVICE='urn:schemas-echostar-com:service:EchoSTB:2'
#Action to wake up a sleeping STB
CHANNEL_ACTION='GetAuthChannelList'
CHANNEL_ARGS=''
upnp_send()
{
local HOST=$1
local ACTION=$2
local UPNP_ARGS=$3
# prepare SOAP message
local CR=$'\r'
local MESSAGE='<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:'${ACTION}' xmlns:u="'${SERVICE}'">'${UPNP_ARGS}'</u:'${ACTION}'>
</s:Body>
</s:Envelope>'
exec 6<>/dev/tcp/$HOST/$PORT || {
echo "error: can not connect to $HOST:$PORT" >&2
return 1
}
cat <<EOF >&6
POST /$QUERY HTTP/1.0$CR
Host: $HOST:$PORT$CR
SOAPAction: "${SERVICE}#${ACTION}"$CR
Content-Type: text/xml; charset="utf-8"$CR
Content-Length: ${#MESSAGE}$CR
$CR
$MESSAGE
EOF
#Uncomment to debug
#cat <&6
exec 6<&-
exec 6>&-
}
#Request the channel list
upnp_send $HOST $CHANNEL_ACTION $CHANNEL_ARGS
if [ $# -eq 2 ] && [ $2 = "--wget" ] ; then
wget -O channels.xml "http://$HOST:49200/AuthChannels.xml"
elif [ $# -eq 2 ] && [ $2 = "--curl" ] ; then
curl "http://$HOST:49200/AuthChannels.xml"
else
echo "Open in a browser - http://$HOST:49200/AuthChannels.xml"
fi