ONLamp.com    
 Published on ONLamp.com (http://www.onlamp.com/)
 See this if you're having trouble printing code examples


O'Reilly Book Excerpts: TiVo Hacks

Hacking TiVo

Related Reading

TiVo Hacks
100 Industrial-Strength Tips & Tools
By Raffi Krikorian

by Raffi Krikorian

Editor's note: O'Reilly recently released TiVo Hacks, opening the proverbial door to the inner workings of the TiVo service. The book shows users and addicts alike how to get even more out of their TiVo, and to give you a taste of what you'll find, we've excerpted a sample hack here. If you're proud of your couch potato status, this is just the hack for you.

Hack #58: Using the TiVo Control Station

Control the various hacks you have installed on your TiVo and populate your TV screen with sports scores, weather forecasts, stock quotes, Closed Captioning, and more.

For some, TiVo — not the computer — is the central repository of all knowledge in the universe. You waste . . . uh, spend . . . many an hour seated in front of it, soaking up its bounty like a sponge. Television programming is simply not enough — you want more?

You can already browse your email [see Hack #57 of TiVo Hacks] onscreen. If you have a DirecTivo, you have caller ID information [see Hack #43] at your heads-up disposal. How much more do you want?

Much more.

The TiVo Control Station (TCS), available at http://www.zirakzigil.net/tivo, is a metahack, encompassing various other hacks applied to the Series 1 TiVo. Think of it as a backdoor hack [see Hack #8], only a lot more powerful. In fact, the TCS has access to those backdoor hacks.

The TCS runs as a service on your TiVo, listening for special remote control sequences. One sequence turns on tivovbi [see Hack #42], while others display sports scores on the screen, check the weather forecast — as if you have any intention of going outdoors any time soon ;-) — or look up stock quotes.

Setting up the TCS is a little involved, so let's go through it carefully. First, you'll need newtext2osd [Hack #41] and JPEGwriter [Hack #40] installed on your TiVo. Once you have those set up, grab a copy of the TCS at http://www.zirakzigil.net/download/TCS_1.0.0.tar.gz, and drop it into your /var/hack directory [Hack #52], and install as follows:

bash-2.02# gzip -d TCS_1.0.0.tar.gz
bash-2.02# cpio -i -H tar --make-directories < TCS_1.0.0.tar
bash-2.02# rm TCS_1.0.0.tar

This leaves you with a new /var/hack/tcsdirectory, containing all the bits of the TCS you'll need. Perfect. Now, let's make sure that everything is configured properly.

Fire up your favorite text editor (Section 3.11) on TiVo and edit /var/hack/tcs/config/IPAddresses. The first three lines provide the IP addresses of three DNS name servers for the TCS to use for domain name resolution; replace the xxx.xxx.xxx.xxx, yyy.yyy.yyy.yyy, and zzz.zzz.zzz.zzz with the DNS server addresses used by your home network and computers. Save the modified file when you're done.

TIP: If you're not sure where to find your local DNS servers, contact your local Internet provider and ask them for the IP addresses of their domain name servers.

Next, open the /var/hack/tcs/config/prefs file. This is a really long file that contains every configuration option the TCS needs. Somewhere in the file you'll notice a block of lines that look something like this:

telnet TelnetCommand /sbin/tnlited 23 /bin/bash -login
ftp FtpCommand /tivo-bin/tivoftpd
tivoweb TivowebCommand /var/hack/tivoweb-tcl/tivoweb tcsrestart
serialbash SerialbashCommand /bin/bash </dev/ttyS3 >& /dev/ttyS3
tivovbi TivovbiCommand /var/hack/bin/tivovbi -oc
newtext2osd Newtext2osdCommand /var/hack/bin/newtext2osd
jpegwriter JpegWriterCommand /var/hack/bin/jpegwriter
text2osd Text2osdCommand /tvbin/text2osd
grep GrepCommand /bin/grep
bash BashCommand /bin/bash
ps PsCommand /var/hack/bin/ps
mkehfiles ElseedMakeFilesCommand /var/hack/tcs/bin/mkehfiles

These lines tell the TCS where to find all the programs it's going to control for you. All but one of these lines point to the places we've suggested you put the support programs; alter the ftp line to read:

ftp FtpCommand /var/hack/bin/tivoftpd

Hold your breath and run the TCS:

bash-2.02# /var/hack/tcs/startcs

This command should return you to the prompt immediately and — despite no confirmation at all — the TCS should be running in the background, awaiting remote control sequences.

To shut down the TCS at any time, issue the following sequence on your TiVo remote control:

99Clear

WARNING: Do not simply kill the TCS processes. The TiVo Control Station is built on top of tivosh, the underlying shell that controls most interapplication messaging in the TiVo. tivosh does not take well to being interrupted, so simply killing the TCS on the command line will force your TiVo to reboot itself.

So, what can the TCS do for you? The list (http://www.zirakzigil.net/tivo/TCSreadme.html) is about as long as your arm — as long as mine at least. In addition to being able to stop and restart your TiVo's FTP, telnet, tivovbi, and tivoweb daemons, activate/deactivate other hacks, and sort the Now Playing list, you can check the weather forecast, display the latest sports scores, and look up stock quotes.

Weather Forecasts

You may recall entering your ZIP code during TiVo's initial guided setup. TiVo used that information to determine which phone numbers your TiVo should call to download programming information and software updates. The TiVo Control Station co-opts this information for determining your geographical location and finding out what the weather is like in your area.

Whilst either playing a recorded program or watching live television, point your remote control at your TiVo and hit:

82Clear

Don't worry that your TiVo thinks it is going to be changing channels; it will forget all about that once you hit Clear. While TiVo summarily ignores the seemingly useless sequence, the TCS uses your TiVo's network access to retrieve and — after a few seconds — display the current weather map, as shown in Figure 4-18.


Figure 4-18. A 600-mile weather map, as displayed by the TCS

If, instead, you issue the following remote control sequence, the TCS will retrieve and display a national weather map like the one shown in Figure 4-19:


Figure 4-19. The national weather on this very rainy day in the northeast, as displayed by the TCS

83Clear

I hope you're having as nice as a day as I am.

Sports Scores

You're sitting with your significant other, watching his favorite show, and are just itching to know the final score on that Red Sox game you're missing. You could send him for a snack and flick to ESPN for a moment, but the show you're watching is live and you'd lose some of the time-slipping you've accumulated.

TiVo Control Station to the rescue! Table 4-3 lists all the sports scores the TCS can make available to you, along with their associated remote control sequences.

Table 4-3. TCS remote control commands for displaying sports scores

TCS remote control sequence

Sports scores displayed

60Clear

All the available sports scores

61Clear

Major League Baseball scores

62Clear

National Football League scores

63Clear

NCAA College Football scores

64Clear

National Hockey League scores

65Clear

National Basketball Association scores

For example, if you hit 64Clear while watching live television or a prerecorded program, you'll be fed all the current NHL standings, as shown in Figure 4-20.


Figure 4-20. Current NHL standings, as displayed by the TCS

The one caveat on all this TCS fun is that the fun is not free — at least when it comes to computing cycles, that is. All the processing devoted to keeping these modules running is being taken away from TiVo's primary job: being a personal video recorder (PVR). If you ask it to do too much, it won't be a very good PVR, because its recording and playbacks will start stuttering.

Therefore, if you are an NFL nut but don't really care much for hockey, it's a good idea to disable the NFL scores module. The modules are just files located in /var/hack/tcs/modules, so deleting what you don't want is simply a matter of deleting a file:

bash-2.02# rm /var/hack/tcs/modules/NHL.tcl

In fact, if you don't care to have any sports information available, remove all the modules:

bash-2.02# cd /var/hack/tcs/modules
bash-2.02# rm MLB.tcl NBA.tcl NCAAF.tcl NFL.tcl NHL.tcl SportsCommands.tcl

If you deleted the modules while the TCS was running, you'll have to restart the TCS before any of this will have any effect. Hit 99Clear to shut down the TCS. You will have to telnet back in [Hack #33] and start the system from the command line before you can use it again.

Stock Quotes

Stocks more your game? Display the latest stock scores — quotes, that is — on your television set. Entering the remote control sequence Clear7Clear provides you with a screen filled with the latest stocks and indexes. Page up and down using the Channel Up and Channel Down buttons on your remote.

The indexes and stocks you see in Figure 4-21 are the default set preconfigured in the TiVo Control Station bundle.


Figure 4-21. Stock quotes, brought to you by TCS

If, instead, you have some specific ones in mind that you want to keep track of, open /var/hack/tcs/config/tickers in your text editor:

^DJI Dow30
^IXIC Nasdaq
^N225 Nikkei
^FTSE FTSE
...
AGRA
AGRB
AV
AAPL Apple
CSCO Cisco

Feel free to alter this file as you wish, listing only the stocks you're interested in tracking. The first few lines — prepended with a ^ (caret) — are indexes; those without the caret character are stocks. Put the ticker symbol first on the line, followed by a human-readable version if you prefer. For example, AAPL Apple looks up the AAPL stock symbol but displays "Apple" onscreen.

WARNING: Do not list the same ticker symbol more than once in the /var/hack/tcs/config/tickers configuration file. If you do so, "bad things will happen," as the author puts it.

The stock quotes are probably one of the most intensive modules in the entire TCS lineup, because it grabs updates for each and every quote, every minute, Monday through Friday, 7:00 a.m. to 4:30 p.m. Ouch! If you're not planning on ever checking your stocks, disable the module by deleting the Quotes.tcl file:

bash-2.02# rm /var/hack/tcs/modules/Quotes.tcl

Be sure to check back to this space next week for TiVo Hacks on scheduling a recording with TiVoWeb, and on streaming video directly from TiVo.


Return to ONLamp.com.

Copyright © 2009 O'Reilly Media, Inc.