PDA

View Full Version : Cmd Line method of seeing which channel is being viewed on tuner ?



abc4422
20-07-16, 09:10
Hi,

I only recently got my Enigma2 with two DVBS2 tuners, and am very impressed with the Xtrend hw and the whole Enigma2 OS.

I'm not a linux expert, but am happy working in the cmd line (basically because I'm that old there weren't GUI options available) :confused:. To that end I was trying to find out if / how I can determine which channel is currently being received.

I am not trying to view the channel, nor look to receive a stream, simply to see which channels are being viewed / recorded from the command line.

If I need to find a frequency or id, then look that up somewhere else to get a channel number, any advise welcome.

Many thanks

ABC.

birdman
20-07-16, 11:01
The attached script can be run on an OpenVix box.
(It can be run on other Linux boxes if you edit the box setting at the top).


#!/bin/sh
#
box=127.0.0.1

# python -m json.tool fails on OpenVix as runpy isn't there.
# So we do it on long-hand...
#
parse_json() {
python -c '
import json
import sys

str = sys.stdin.read()
kv = json.loads(str)
print json.dumps(kv, sort_keys=True, indent=0, separators=(",", ":"))
'
}

# python will sort the fields...
#
wget -qO - http://$box/api/statusinfo | parse_json |
while read line; do
case $line in
*\"currservice_station\":*)
channel=`echo $line | sed -e 's/.*:\"//' -e s'/\",.*//'`
;;
*\"currservice_name\":*)
name=`echo $line | sed -e 's/.*:\"//' -e s'/\",.*//'`
;;
*\"inStandby\":*)
case $line in
*true*|*True*) echo "In standby" ;;
*) echo $channel: $name ;;
esac
exit
;;
esac
done

abc4422
20-07-16, 12:10
Wow !!

Excellent, does exactly what I was looking to achieve.

With the added extra, as it opens up a route to find additional information from the queried URL:- /api/statusinfo

Many thanks.