[mythtv-users] Comcast OnDemand on Multiple STBs

Worldnet onley at worldnet.att.net
Wed Nov 14 03:29:14 UTC 2007

> I dont think you can figure out the encoder being used from tvchain's  
> chanidinfo. I checked the chanid's on my system and one set start with 1  
> (i.e.1007) and the second set start with 2(i.e. 2007) which means it is  
> tied tothe listings source( of which I have 2 ) and not encoders ( of  
> which I have4) . Still there's got to be a mysql way of determining the  
> currentencoder running in livetv mode for a specific mythfrontend.  
> Perhaps youneed to repost the question again on the list more  
> specifically.
> I even checked the status port xml and I dont see anything unique there  
> toidentify which encoder is attached to which frontend.
> I see this as the biggest obstacle you have. Everything else seems very 
> workable. For example, remote execution with mysql would work like this 
> which would generate sql info that could be parsed with sed, tr, awk,  
> grep.
> mysql -umythtv -pmythtv mythconverg -e 'SELECT * FROM tvchain WHERE  
> chainidLIKE "%mybedroom%"' -h mymythtv
> Remote command execution of the channel change script would work like  
> this(assuming you have passwordless ssh setup):
> ssh user[at]backendhostname "changechannel encoder UP"
> And that could be called directly on the local mythfrontend by lirc via  
> anirexec command. Switching modes in lirc is possible such that you can  
> enter"VOD mode" by pressing a particular button (mode switch button?) ,  
> and allyour buttons are immediately redefined. Pressing the mode switch  
> buttonagain allows you to leave "VOD mode" and go back to "Default  
> Mode". This isby using the mode and flags option in lirc.
> There might be another way to get around to the "which frontend is using 
> which encoder" problem. If you setup a channel source for each encoder  
> suchthat encoder 1 channels will start with 1 (i.e. 1007); encoder 2  
> will startwith 2(i.e. 2007), encoder 3 would start with 3(i.e. 3007) if  
> that is indeedhow the channel naming scheme works in mythtv. If that is  
> the case,determining which encoder is active from the tvchain sql query  
> amounts tochecking for the value of chanid.
> So, basically your script (taking one argument which is either UP, DOWN, 
> etc) on the mythfrontends would do this :1. Determine the hostname where  
> the script is running
> 2. Determine the current time
> 3. query the remote mysql database as the above example, and parse the 
> output selecting the results that match the current frontend hostname and 
> the current time.
> 4. check for the chanid value to determine the encoder
> 5. remotely call the channelchange script on the backend with first 
> argument as encoder and second argument as UP,Down,etc.
> 6. Quit
> Let us know how things work out.
> Chris

Hi Chris

I have a VERY rough draft of the script working. I still have a LOT
of work to do but what I did was

create a script on the frontend that accepts the host name (arg $1) and the
key to send (arg $2) as arguments.

1) 	Create a string with the current time in the format of the tvchain

2)	Interogate the db for records that have the frontends host name in the
	chainid field (this ties the frontend to the record) and an endtime >
	the current time (giving the current record) this was done by using.

ssh <backend> 'mysql -umythtv -pmythtv mythconverg -e "SELECT chanid FROM
WHERE  endtime > '$current_time' AND chainid LIKE '%$1%'\G"'

	This actually got a little messy, I ended up puting the query in a script
	on the backend as the mysql -e apparently cannot handle nesting quotes and
	called that script with the current_time string and the frontend hostname
	but the idea remains the same.

3)	Here is where I have to do some more work, I pull the first digit from
	chanid field and use it to identify the input source. You think that this
	is related to the lineup source though so I may have to use the input
	field (which is the optional, arbitrary name you gave the encoder when
	you set it up during install) to identify the correct STB to send the
	commands to.

4) 	use   ssh <backend> [command]    to send arg $2 to the right STBs
	changing script on the backend.

Again what I have working is VERY rough and I am not a programmer but when
have cleaned it up some and have verified it is successful I will post it
this thread.

It should be noted that Mike's idea will work well in most cases where you
need interaction to start a show and you're done with it but I want to
out how to do it without using a key to enter interactive mode and then
it. I am afraid things would get left in an unknown state (4 & 5 year

I am using some nice universal remotes with nameable LCD touchscreen
that can be assigned to the arrows for the OnDemand feature and they would
mapped to this script in the lircrc file so there would be no mode

Thanks everyone for your ideas.

More information about the mythtv-users mailing list