Skip to content

Commit

Permalink
More options
Browse files Browse the repository at this point in the history
222k script added
All scripts have -h usage display
--curl and --wget options added to channellist
  • Loading branch information
jheizer committed Feb 27, 2015
1 parent 72c872d commit af03817
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 6 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ UPnP Channel Changing script (Designed for MythTV and the DISH Network VIP 211 b
Supported set top boxes:
+ VIP 211
+ VIP 211k
+ VIP 222k (vip222k_changer)

Set top boxes reported to have no UPnP interface:
+ None yet
Expand All @@ -16,11 +17,9 @@ If your box is not in the list above see: <https://github.com/jheizer/UPnPChanne
+ Test that sure you are using the HD specific channel number or else you may have the SD feed. (Dish I have to use the 9XXX channel numbers.)
+ Change mythtv's channel change script to read /path/to/script/upnpchannelchanger ip.of.settop.box

To test it: /path/to/script/upnpchannelchanger ip.of.settop.box Channel#
For usage information for your particular script: /path/to/script/upnpchannelchanger -h

Example: /home/jheizer/upnpchannelchanger 10.0.0.123 9520

To aid in converting you channel data over to the HD specific numbers download and run the channellist script above. It will return all subscribed channel numbers from your receiver.
To aid in converting you channel data over to the HD specific numbers download and run the channellist script above. It will return all subscribed channel numbers from your receiver. Run channellist -h for curl and wget usage.


Special Thanks to https://gist.github.com/markusfisch/6130842 For giving me a great spot to start on this script.
Expand Down
7 changes: 7 additions & 0 deletions upnpchannelchanger
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#!/usr/bin/env bash

if [ $# -eq 0 ] || [ $1 = '-h' ] ; then
echo 'Usage: upnpchannelchanger STB_IP Channel#'
echo 'Example: upnpchannelchanger 10.0.0.123 9475'

exit 0
fi

# Basic Settings
HOST=$1
PORT='49200'
Expand Down
21 changes: 19 additions & 2 deletions vip211-channellist
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
#!/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'
Expand Down Expand Up @@ -48,7 +59,13 @@ EOF
exec 6>&-
}

#Wake the STB up
#Request the channel list
upnp_send $HOST $CHANNEL_ACTION $CHANNEL_ARGS

echo "Open in a browser - http://$HOST:49200/AuthChannels.xml"
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
84 changes: 84 additions & 0 deletions vip222k_changer
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env bash

if [ $# -eq 0 ] || [ $1 = '-h' ] ; then
echo 'Usage: vip222k_changer STB_IP TUNER Number Channel#'
echo 'Tuner 0 = HD Tuner'
echo 'Tuner 1 = SD TV2 Tuner'
echo 'Example: vip222k_changer 10.0.0.123 0 9475'

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
WAKE_ACTION='WakeUp'
WAKE_ARGS='<Tuner>$2</Tuner>'

#Action to change the channel
CHANGE_ACTION='SetChannel'
CHANGE_ARGS="<Tuner>$2</Tuner><Channel>$3</Channel>"

#Disable Inactivity Standby
INACTIVE_ACTION='InactivityStandby'
INACTIVE_ARGS='<Enable_disable>Disable</Enable_disable><hours_4_to_8>8</hours_4_to_8>'

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>&-
}

#Wake the STB up
upnp_send $HOST $WAKE_ACTION $WAKE_ARGS

#Wait for it to wake up
sleep .7

#Change the channel
upnp_send $HOST $CHANGE_ACTION $CHANGE_ARGS

sleep .1

#Disabled the inactivity timeout
upnp_send $HOST $INACTIVE_ACTION $INACTIVE_ARGS

#Sleep to allow the STB time to settle before the tuner tries to access (HD-PVR)
sleep .1

0 comments on commit af03817

Please sign in to comment.