Tivo Hacks. 100 Industrial-strength Tips Tools 2003

   

Hack 99 Disabling the Live TV button

What good is limiting your children's viewing to the G-rated bounty TiVo's brought them if they can just meander into an R-rated neighborhood with a click of the Live TV button?

You've carefully crafted your children's television viewing to contain only television shows you believe are wholesome and good for them. But then they go mucking about with the Live TV button and catch some gruesome action flick or racy Sex in the City episode you'd rather they not see for a couple of years or ever, for that matter. This hack is all about disabling that dastardly Live TV button on the kids ' TiVo.

Now that you've learned all about events [Hack #98], it shouldn't surprise you to know that getting to Live TV is controlled by an event passing through the event switcher. Try it out by running events.tcl [Hack #98], and press the Live TV button on your remote. You should see something like this:

bash-2.02# /var/hack/bin/events.tcl 28 00 : 6 1 1 0 245947039 -971910840 27 00 : 6 2147480992 29693532 0 0 2147481008 28 01 : 6 1 1 1 245947039 -723092840

There are two event types here: type 28 is the remote control event, and type 27 is something called EVT_MW_STATUS . While you're running events.tcl , navigate to the TiVo Central menu, select Watch Live TV , and see what happens. You should see a few events float by, most notably this:

27 00 : 6 0 0 2138912008 0 2147480992

You might guess that an event type 27 with a first data value of 6 is telling TiVo to display live television. And you'd be right.

While it's tempting to simply squelch that event, we just can't do thatat least not without some serious programming know-how and developer-level knowledge of all the places the message is caught. But we can catch it and do something in retaliation. The plan of attack is to detect when the TiVo wants to display live television, asking it to put up the TiVo Central menu instead. This way, no matter how the TiVo attempts to get to live televisionthrough the Live TV button, the Watch Live TV menu option on TiVo Central , or automatically after being on TiVo Central for too longyour TiVo will be asked to go back to the TiVo Central menu.

The Code

Because this code needs to be running at all times, it tends to be a little more on the complicated side. At its heart, it registers a callback to catch_livetv whenever an EVT_MW_STATUS event is noticed. If the event has a data value of 6 , the script asks TiVo to simulate the pressing of the button, sending the viewer back to TiVo Central . (Do not pass Go. Do not collect $200). All the other code around the catch_livetv procedure is for support, to make this script as unintrusive as possible.

#!/tvbin/tivosh # include some TiVo TCL libraries source $tcl_library/tv/log.tcl source $tcl_library/tv/sendkey.tcl # disable the key sending from being put on the screen set verboseSendKeyG 0 # the name of the file containing the PID set pidfile "/tmp/livetv.pid" # the callback function to call when we get a EVT_MW_STATUS event. # whenever the TiVo attempts to switch into LiveTV, this event is sent # out with a state number 6 proc catch_livetv { type subtype } { global EventData # pull out the state value -- if we get a state 6, then we send # the "TiVo" key binary scan $EventData I state if { $state == 6 } { SendKey "tivo" } } # see if we are supposed to be killing a version that is in the # background. if we are, read the PID file and kill the forked off # process -- then delete the file if { [lindex $argv 0] == "-stop" } { if { [file exists $pidfile] } { set pfchan [open $pidfile "r"] set lpid [gets $pfchan] close $pfchan file delete -force $pidfile try { kill $lpid } catch errCode { } } exit 0 } # if livetv is already running, then put up a warning to that point if { [file exists $pidfile] } { puts stderr "livetv is already running" puts stderr "if it is not, then delete /tmp/livetv.pid" exit 1 } # if we get the -run flag, then we are going to create the pid file # and start a process waiting for the right events if { [lindex $argv 0] == "-run" } { set pfchan [open $pidfile "w"] puts $pfchan [pid] close $pfchan # register to watch EVT_MW_STATUS events event register 27 catch_livetv set StillWaiting 1 vwait StillWaiting } else { # fork off a copy of this script to be run in the background exec $argv0 "-run" "&" }

Save the code as disabletv.tcl in TiVo's /var/hack/bin directory, and make it executable:

bash-2.02# chmod 755 /var/hack/bin/disabletv.tcl

Running the Hack

Run the script from TiVo's command line Section 3.3, like so:

bash-2.02# /var/hack/bin/disabletv.tcl

This should return you to the prompt right away. If you take a look at the running processes, you should see that a version of this program is running in the background:

bash-2.02# ps auxw grep disabletv root 333 1.2 8.4 7936 1172 p1 S 02:47 0:01 tivosh /var/hack/ bin/disabletv.tcl -run

And it should be doing what it's programmed to do. Go ahead, push the Live TV button on your remote. Your television will show live television for an instant, followed immediately by the gentle "bling" sound of the button being pressed, and the TiVo Central menu will flicker right up on the screen. Any other way you attempt to get to live television will have the same effect.

To stop the hack, simply run the following command:

bash-2.02# /var/hack/bin/disabletv.tcl -stop

Your live television abilities will be returned to you.


   
Top

Категории