Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 42 lines (41 sloc) 1.52 KB
#!/bin/bash
#
# Play a HDHomeRun channel. Pass the channel call sign. On the initial run this will ask you
# for the IP address of the HDHomeRun device and store the IP address in ~/.hdhrIpAddress.
#
# This script lives here: https://github.com/pla1/utils/blob/master/tv
#
# Wikipedia TV station call signs.
# http://en.wikipedia.org/wiki/List_of_television_stations_in_the_United_States_by_call_sign_(initial_letter_K)
# http://en.wikipedia.org/wiki/List_of_television_stations_in_the_United_States_by_call_sign_(initial_letter_W)
#
# Uses mplayer. Change the last line in this script to your favorite media player.
#
IP=$(cat ~/.hdhrIpAddress)
if [ -z "$IP" ]
then
read -p "Key the IP address of the HDHomeRun and press ENTER" IP
echo "$IP" > ~/.hdhrIpAddress
fi
callSign="$1"
lineup=$(curl --silent "http://$IP/lineup.json")
if [[ "$lineup" != *"GuideNumber"* ]]
then
rm -f ~/.hdhrIpAddress
echo -e "\n\nMissing channel lineup. Check the IP address $IP. Also make sure you have the latest firmware on your HDHomeRun device. https://www.silicondust.com/support/downloads/\n\n"
exit 1
fi
shopt -s nocasematch
regex=",\"GuideName\":\"$callSign ?\.*\",(\"HD\":[0-9]+,)?\"URL\":\"(http:\/\/[a-zA-Z0-9\/\.:]+)\"}"
echo "REGEX: $regex"
[[ $lineup =~ $regex ]]
echo "BASH REMATCH GROUP 1 ${BASH_REMATCH[1]}"
echo "BASH REMATCH GROUP 2 ${BASH_REMATCH[2]}"
url="${BASH_REMATCH[2]}"
if [ -z "$url" ]
then
echo "Call sign \"$callSign\" not found. Check http://$IP/lineup.json"
exit 1
fi
echo -e "\n\nPlaying $url\n\n"
/usr/bin/cvlc --fullscreen $url