O'Reilly logo

TiVo Hacks by Raffi Krikorian

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 4. Bring the Internet to TiVo

Hacks #47-62

While playing with the Bash prompt [Hack #30] on your TiVo is a nice adventure, it’s quite limited in terms of real functionality. In the age of the networking, what we really want is all our devices linked together on the network. We want remote access, not just from a serially connected PC, but from anywhere on the Internet. We want our devices to jack into and talk to one another. And our TiVo should be no less than a first-class citizen.

Your TiVo should be part of your home network. Your desktop computer should be talking to and making requests of your TiVo. Your office computer, a couple of miles down the road, should be doing the same. Even on the go, your laptop—sitting at a WiFi access point in an airport halfway across the world—should be able to call up your TiVo.

Bringing the Internet all the way to your TiVo is not as difficult as it sounds. In fact, if you have a Series 2 Standalone TiVo, it’s as simple as plugging a USB-Ethernet adapter. Things are a little more complex if you have a Series 1, but there’s a gain in hackability.

Running PPP over TiVo’s Serial Port

Make a PPP connection over that serial cable plugged into your TiVo [Hack #33], and make your daily call over the Internet.

In this age of broadband cable and DSL connections, it may well have been a while since you heard the squawks of a modem. Cast your mind back a bit—circa 1994 through 1999 should about do it—and try recall how it all worked. Your computer was connected via serial cable to a modem, which was, in turn, connected to your phone line. To get online, your computer instructed your modem to dial your Internet Service Provider (ISP). The call was answered by a modem at the other end. After a few seconds of whistling and screaming at one-another, a connection was established between your computer and your ISP and, by association, the Internet. Primitive, but effective.

The language spoken between your computer and the ISPs was the Point-to-Point Protocol (PPP).

PPP is also used by your TiVo to make its daily call over its internal modem to TiVo, Inc. to download programming information, software updates, and other assorted bits. Surely your TiVo (a computer) can be coerced into making a PPP call to somewhere other than TiVo, Inc? Indeed it can—sort of. While getting TiVo’s modem to make its daily call to another modem would be a neat trick, it’s not particularly useful, is it? What we’re actually after is using a spare PC as an intermediary for fulfilling your TiVo’s needs over the Internet via your broadband connection and taking the phone call out of the equation.

Thankfully, TiVo has built-in functionality for making a serial PPP connection to another computer. Plug the TiVo serial control cable into its serial port. We’ll get to the other side of the equation (your PC) [Hack #48] in just a moment.

Navigate TiVo’s menu system to Messages & Setup Recorder & Phone Setup Phone Connection Change Dialing Options under TiVo OS 3.x. Under OS 4.x, that’s TiVo Messages & Setup Settings Phone & Network Setup. Set your Dial Prefix to ,#296 using the numeric buttons on your TiVo remote control. Use the Enter button for # (“pound” or “hash”) and the

image with no caption

button for , (comma).

Tip

Your TiVo unit, version of the TiVo operating system, or remote control may use different buttons for special characters. Consult the onscreen instructions for the appropriate buttons to press.

A dial prefix of ,#296 instructs TiVo to establish a PPP connection at a speed of 9,600 baud over its serial port each time it makes its daily call. (No 9,600 baud isn’t exactly speedy.) Table 4-1 provides a list of dial prefixes and their associated baud rates. It behooves you to try the slowest speed first and work your way up as you get this hack working with your PC.

Table 4-1. TiVo dialing prefixes and associated PPP connection baud rates

TiVo dialing prefix

PPP baud rate

,#296

9,600

,#238

38,400

,#257

57,600

,#211

115,200

Go To

You won’t get very far without configuring your PC [Hack #48] to accept the PPP connection from your TiVo.

Accept a PPP Connection from TiVo on Your PC

Just getting the TiVo to run PPP over its serial port is not quite enough—you need your PC to accept the call and route it to the Internet.

PPP requires two computers for the communication to work, hence the Point-to-Point moniker. We’ve already set TiVo up [Hack #47] as the initiating end. Now we need to get the PC to answer the call, as it were, on the receiving end and route data between TiVo and the Internet.

Assuming you already have a PC with Internet access over some sort of broadband connection (cable modem, DSL, dedicated connection, etc.), and that computer has a free serial port, you’re just about there. All that’s left is a little configuration.

Configuring Windows

Windows XP already has all the software it needs to make this magic happen. We are, however, going to have to coerce it to interoperate properly with TiVo.

Tip

These instructions are close, but not identical, to those necessary for Windows 2000. Reading through these Windows XP instructions should provide enough insight into how it’s done to extrapolate to Windows 2000.

Just hooking the two machines—your TiVo and PC—together doesn’t magically set up a PPP connection between the two. The base question is, how are these two computers going to know when to start talking to each other? Windows egotistically assumes that anybody connecting to it is going to say CLIENT over the serial line to get its attention. TiVo has no intention of doing so, instead preferring to send a ~ (tilde) to announce itself. One of the two is going to have to alter its expectations, and Windows is the pushover, so we’ll make the appropriate adjustments there.

Launch Notepad, the simple Windows text editor, and open c:\windows\inf\mdmhayers.inf for editing. Scroll down (quite a way) until you run into a section that looks something like this:

[M2700Reg] ; Null-Modem
HKR, Init, 1,, "None"
HKR, Init, 2,, "NoResponse"
HKR, Monitor, 1,, "None"
HKR, Answer, 1,, "CLIENTSERVER"
HKR, Answer, 2,, "NoResponse"
HKR, Settings, DialPrefix,, "CLIENT"
HKR,, Properties, 1, 00,00,00,00, 00,00,00,00, 00,00,00,00, 
00,00,00,00,00,00,00,00, 30,00,00,00, 00,c2,01,00, 00,c2,01,00
HKR, Responses, "CLIENT",    1, 08, 00, 00, 00, 00, 00, 00,00,00,00 ; Server 
side - the client is requesting a connection
HKR, Responses, "<h00>CLIENT", 1, 08, 00, 00, 00, 00, 00, 00,00,00,00 ; 
Server side - the client is requesting a connection
HKR, Responses, "CLIENTSERVER", 1, 02, 00, 00, 00, 00, 00, 00,00,00,00 ; 
Client side - the server has acknowledged

Slip the following between the last two lines in the block:

HKR, Responses, "~", 1, 08, 00, 00, 00, 00, 00, 00,00,00,00 ; Server side - 
the client is requesting a connection
HKR, Responses, "<h00>~", 1, 08, 00, 00, 00, 00, 00, 00,00,00,00 ; Server
side - the client is requesting a connection

It should now look like this (inserted lines are called out in bold):

[M2700Reg] ; Null-Modem
HKR, Init, 1,, "None"
HKR, Init, 2,, "NoResponse"
HKR, Monitor, 1,, "None"
HKR, Answer, 1,, "CLIENTSERVER"
HKR, Answer, 2,, "NoResponse"
HKR, Settings, DialPrefix,, "CLIENT"
HKR,, Properties, 1, 00,00,00,00, 00,00,00,00, 00,00,00,00, 
00,00,00,00,00,00,00,00, 30,00,00,00, 00,c2,01,00, 00,c2,01,00
HKR, Responses, "CLIENT",    1, 08, 00, 00, 00, 00, 00, 00,00,00,00 ; Server 
side - the client is requesting a connection
HKR, Responses, "<h00>CLIENT", 1, 08, 00, 00, 00, 00, 00, 00,00,00,00 ; 
Server side - the client is requesting a connection
HKR, Responses, "~", 1, 08, 00, 00, 00, 00, 00, 00,00,00,00 ; Server side - 
the client is requesting a connection
               HKR, Responses, "<h00>~", 1, 08, 00, 00, 00, 00, 00, 00,00,00,00 ; Server 
side - the client is requesting a connection
HKR, Responses, "CLIENTSERVER", 1, 02, 00, 00, 00, 00, 00, 00,00,00,00 ; 
Client side - the server has acknowledged

Save the changed file, and you have convinced your Windows machine to expect the ~ (tilde) character TiVo is planning to send.

Next, launch Windows XP’s Control Panel, and from there the Phone and Modem Options. Select the Modems tab and click the Add button to launch the Add Hardware Wizard. You’ll be asked whether you wish the Wizard to detect your modem, as shown in Figure 4-1.

The Add Hardware Wizard asking whether or not it should detect your modem
Figure 4-1. The Add Hardware Wizard asking whether or not it should detect your modem

Since we’re not actually using a modem, check the “Don’t detect my modem; I will select it from a list” checkbox and click the Next button to move on.

Your computer should chug away awhile as it compiles a list of modems from which to make your selection. When it’s good and ready, the wizard will show you a list of all the modems it knows (see Figure 4-2). Under Manufacturer, select “Standard Modem Types,” and select “Communications cable between two computers”—that’s our null modem connection—under Models. Click Next.

Selecting a “Communication cable between two computers”
Figure 4-2. Selecting a “Communication cable between two computers”

You’ll be prompted for a COM (read: serial) port, as shown in Figure 4-3. To the question “On which ports do you want to install it?,” choose “Selected ports.” Then highlight the COM port to which you wired your TiVo. Click Next, and Windows will set up the connection. It should report that all went well, leaving you to click the Finish button to leave the Wizard.

Making sure that you have the right COM port setup
Figure 4-3. Making sure that you have the right COM port setup

The Wizard’s only capable of taking care of the broad strokes; you still need to tweak and fine-tune the connection a little. Back at Phone and Modem Options, select the new “Communications cable between two computers” connection the Wizard created and click Properties to get to all its fine-tuning knobs. Select the Modem (see Figure 4-4) tab, where you’ll need to make sure that the Maximum Port Speed matches the baud rate at which TiVo is set to talk [Hack #47], then click OK.

Confirming the connection’s baud rate
Figure 4-4. Confirming the connection’s baud rate

The modem is now set up, so you can go ahead and click the OK button back at Phone and Modem Options.

With the physical connection configured, you’ll now create a network connection. From the Control Panel, select Network Connections. Up comes the Network Connections window, shown in Figure 4-5. In the Network Tasks box in the left column, click “Create a new connection” to bring up the New Connection Wizard. Click Next to begin creating a new network connection.

Network Connections, listing all the valid network interfaces currently configured
Figure 4-5. Network Connections, listing all the valid network interfaces currently configured

When asked what type of network connection you want, select “Set up an advanced connection.” If you read the small print, you’ll see you’re offered a direct connection via a serial port, which is precisely what you’re trying to do. Select the option and click Next.

A dialog box asks what kind of connection you want—whether the PC is going to be receiving or sending data. Since TiVo is going to want to make an outgoing connection when it needs to make its daily call, select “Accept incoming connections” and click Next.

When asked to choose Devices for Incoming Connections (Figure 4-6), check the “Communications cable between two computers” box. That’s the “modem” you just configured. Click Next again.

Configuring the proper “modem” for use with this connection
Figure 4-6. Configuring the proper “modem” for use with this connection

You’re not going to be setting up any kind of Virtual Private Connection (VPN), so tell Windows not to allow VPNs and click—you guessed it!—Next.

The Wizard will ask you what users are allowed to connect. Since your TiVo is only using your PC as a proxy to the Net and won’t be needing any kind of user privileges on the PC, just allow the Guest user. Click Next.

Now it’s time to set up Networking Software and configure the PPP interface to please TiVo. Select Internet Protocol and click Properties to bring up the Incoming TCP/IP Properties dialog box shown in Figure 4-7.

Setting up Incoming TCP/IP Properties for TiVo’s direct connection
Figure 4-7. Setting up Incoming TCP/IP Properties for TiVo’s direct connection

Your TiVo is expecting to use the serial connection to access your home network and the Internet. To make this possible, check “Allow callers to access my local area network.” Don’t worry, this isn’t opening your PC to just any vagabond on the network; only the TiVo is coming in via that serial cable, nobody else.

If you have a DHCP server on your network—everybody on your home network is being assigned IP addresses by your DSL router or cable modem—then allow for TCP/IP addressing to be done automatically using DHCP by clicking the appropriate radio button. That takes the burden of configuring the TCP/IP connection off your shoulders. If you don’t have a DHCP server, just select “Specify TCP/IP addresses” and put in a range of addresses that are not already being used on your network.

Chances are, if you set up your networking as shown in Figure 4-7, you’ll be fine. Click OK to close the dialog box. Then click Next and Finish to dispatch the wizard, and you’re almost done.

Go back to the Network Connections window, and you should now see a shiny new incoming connection. Right-click on the connection and select Properties to bring up the Incoming Connections Properties. Select the Users tab and check the “Always allow directly connected devices such as palmtop computers to connect without providing a password” checkbox, as shown in Figure 4-8. The TiVo has no notion of a password.

Allowing directly connected devices to connect without a password
Figure 4-8. Allowing directly connected devices to connect without a password

Last step—I promise. Select the General tab in the Incoming Connections Properties dialog, select “Communications cable,” and click the Properties button to bring up the dialog box shown in Figure 4-9. Turn off flow control (select “None”), as TiVo’s serial port does not have the extra lines needed for any kind of hardware flow control, nor does it bother with software flow control.

Turning off the flow control on the new direct connection
Figure 4-9. Turning off the flow control on the new direct connection

Click OK and OK again, and you’re done. Whew!

Configuring Linux

While this may be hard for Windows users to believe, Linux configuration for accepting a PPP connection from TiVo is considerably less involved.

Edit your /etc/rc.d/rc.local file, appending:

echo "Enabling IP forwarding."
echo 1 > /proc/sys/net/ipv4/ip_forward

echo "Setting up TiVo connection"
/sbin/ipchains -P forward DENY
/sbin/ipchains -A forward -i eth0 192.168.1.2 -j MASQ
/usr/sbin/pppd /dev/ttyS0 9600 noauth debug proxyarp nocrtscts nobsdcomp \
nodeflate persist local lcp-max-configure 28800 192.168.1.1:192.168.1.2

Note that this configuration makes a couple of assumptions, both easily changeable. First, we’re assuming your Internet-enabled interface is eth0 (bolded); if it’s something different, change it as appropriate. Second, we’re assuming 9600 baud over serial interface /dev/ttyS0; this should reflect the serial port you chose, and the baud rate should match that of the TiVo side [Hack #47]. We’re assigning your Linux box a private IP address of 192.168.1.1 and your TiVo gets 192.168.1.2—at least as far as this interface is concerned.

For further guidance, consult the Home Networking mini-HOWTO (http://www.ibiblio.org/pub/Linux/docs/HOWTO/mini/other-formats/html_single/Home-Network-mini-HOWTO.html), the Linux IP Masquerade HOWTO (http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/html_single/IP-Masquerade-HOWTO.html), and the Linux IPCHAINS-HOWTO (http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/html_single/IPCHAINS-HOWTO.html).

Testing Your PPP-over-Serial Connection

Now that you’ve wired up your TiVo to the Internet via your PC, let’s make sure that it all works as expected.

Unplug your phone line from your TiVo; you won’t be needing that anymore. Get TiVo to make a test call by selecting Make Test Call from Messages & Setup Recorder & Phone Setup Phone Connection on OS 3.x and TiVo Messages & Setup Settings Phone & Network Setup Test connection under OS 4.0 After a few seconds, you should see the usual messages indicating a successful connection; only this time the call’s routed over the Internet. TiVo will now use this connection each time it makes its daily call.

After a successful trial at 9,600 baud, take things up a notch or two on both the TiVo and PC ends (they must match to work) and see if you can work your way up to downloading program data at a top speed of 115,200 baud (see Table 4-1 for the associated TiVo dial prefixes).

—“Otto”

Getting Your TiVo Series 1 Online

The Series 1 TiVo was not designed with networking in mind. But being the most hack-worthy of TiVo units means it didn’t take long for some crafty hackers to get it online.

While the Series 2 was designed from the start with networking in mind—albeit via the USB port—the earlier Series 1 units simply were not built for a networked world. Case closed, right? Not by a long shot! A bunch of inventive Australian TiVo hackers, who simply wouldn’t take “no” for an answer, came up with a rather crafty solution: the TiVoNET.

The TiVoNET (http://www.9thtee.com/tivonet.htm) provides a bridge between a PCI-shaped adapter on the Series 1’s motherboard and a standard ISA slot into which you can plug in a standard Ethernet card. The TiVoNET board has since been superceded by the TurboNET (http://www.9thtee.com/turbonet.htm). Just like its predecessor, the TurboNET plugs directly into the edge connector on a Series 1 box. Unlike the TiVoNET, the new board does not need external power, grabbing juice right from your TiVo itself, as one would certainly hope it would. Nor do you need an additional Ethernet card to plug into it; the TurboNET board is all-in-one, plugging right into your home network via its on-board Ethernet port.

To install the TiVoNET or the TurboNET, you are going to have to mutilate your Series 1 to some degree—but only the case, mind you. As it stands, the Series 1 provides no hole through which to get an Ethernet cable out of the box. The solution: a garden-variety hack saw. I’m not kidding! Just pop the top [Hack #20], take a hack saw to the back, and open up a small port that you can sneak a cable through, as shown in Figure 4-10.

Opening up one of the mounting holes through which to snake an Ethernet cable
Figure 4-10. Opening up one of the mounting holes through which to snake an Ethernet cable

That done, fit your the board to the edge connector toward the front of the TiVo and push. You might need to apply a little force, as this is going to be a really tight fit. The TurboNET is a mite smaller. See Figure 4-11.

The TurboNET, fitted snugly inside the TiVo on the edge connector
Figure 4-11. The TurboNET, fitted snugly inside the TiVo on the edge connector

Finally, plug an Ethernet cable into your new network card, snake it out of your TiVo, and plug it into your wired home network or an Ethernet-to-WiFi bridge (the Linksys WET11 works nicely).

Some users optionally mount an Ethernet jack on the outside of their boxes (see Figure 4-12) to clean up the design of their boxes. You can grab one of these TurboNET Connect Kits from 9thtee (http://www.9thtee.com/turbonet.htm). Just remove the piece of double-stick tape, position the jack, press it to affix the jack to the case, and run a cable from the jack, through your hole, to the network card.

An Ethernet jack mounted on the outside of the case
Figure 4-12. An Ethernet jack mounted on the outside of the case

If you have a Bash shell enabled on your TiVo’s serial port [Hack #30], you’ll do all the configuration once you shut your box; its easier that way. If you don’t have Bash setup, you should do so now, as we’ll walk more than halfway down that road anyway.

Don’t worry if you think it’s redundant to have Bash and telnet running. Think of it as a failsafe; if for any reason you can’t get into your TiVo through one of those means, chances are the other one will still work.

Now that wasn’t so bad, was it? Before TiVo OS Version 3.0, various configuration scripts had to be mangled and a permanent IP address had to be put into the startup scripts. All that’s left nowadays is to utter a magic incantation to tell TiVo not to use its onboard modem and the phone line for its daily calls. Navigate TiVo’s menu system to Messages & Setup Recorder & Phone Setup Phone Connection Change Dialing Options, and set your Dial Prefix to ,#40 using the numeric buttons on your TiVo remote control. Use the Enter button for # (“pound” or “hash”) and the

image with no caption

button for , (comma).

Tip

Your TiVo unit, version of the TiVo operating system, or remote control may use different buttons for special characters. Consult the on-screen instructions for the appropriate buttons to press.

Somewhere on your home network you’re bound to have a DHCP server handing out IP addresses to new devices coming online. Your broadband cable modem or DSL router should be providing this functionality to all the other computers in your house. It’ll hand TiVo an IP address and consider it part of the family. Also, unlike running PPP [Hack #47], this connection is permanent; it’s always on.

Getting Your TiVo Series 2 Online

The TiVo Series 2 comes with online access baked in. Plug in a USB-to-Ethernet or USB-to-WiFi adapter, and your TiVo’s a first-class citizen on your home network.

While it might be useful to have your TiVo online via another computer [Hack #47], purists are sure to find it quite frustrating to see a fledgling Linux box not be able to spread its wings. Owners of the Series 2 Standalone TiVo are in luck. TiVo, Inc. has partnered with Linksys (http://www.linksys.com/), makers of networking and WiFi equipment for work and home, to take its users’ TiVos online. TiVo recommends two adapters: the WUSB11 Version 2.6 (a WiFi 802.11b adapter from Linksys’ “Instant Wireless Series”) and the USB100TX USB-to-Ethernet (10/100 BaseT) adapter from their “Instant Etherfast Series.”

Users have also reported success using non-TiVo USB-to-Ethernet adapters, such as these:

Linksys USB100M
Linksys USB200M
NetGear FA101
NetGear FA120
Belkin F5D5050
3Com 3C460B
Microsoft MN-110
Hawking UF200
Hawking UF100
D-Link DSB-650TX
D-Link DUB-E100
Siemens SS1001
SMC SMC2208

On the WiFi front, Table 4-2 lists non-TiVo-recommended USB-to-802.11b adapters and the TiVo service numbers with which they are most likely to work. You can find your service number with a quick trip to TiVo Messages & Setup System Information. Look for it a couple of lines down from the top.

Table 4-2. Non-TiVo-recommended USB-to-802.11b adapters and associated TiVo service numbers

Initial digits of TiVo service number

Alternative USB-to-802.11b adapters

110, 130, 140

NetGear MA101 V.A, D-Link DWL-120 V.A

230, 240

D-Link DWL-120 V.D, Linksys WUSB12, Hawking WU250, Microsoft MN-510

Any

NetGear MA101 V.B, D-Link DWL-120 V.E, SMC 2662W V.2, Belkin F5D6050

That said, unless you have one of the unsupported adapters lying about your house, I’d recommend just going with one of the recommended ones.

Simply plug the adapter into the back of your Series 2 running TiVo OS 4.0 or later, and follow the onscreen directions to get it onto the network.

Figuring Out Your TiVo’s IP Address

Before you can even get to your now-network-enabled TiVo—let alone do anything interesting to it—you need to figure out just where it is on your home network.

All devices on the Net are ultimately accessible by IP address: a set of four numbers providing it with a unique (at least in the realm at hand) ID. Just as the postman must know the address of your house before being able to deliver your latest Amazon.com goodies, so too must you know TiVo’s address on the network before you can do anything interesting with it.

Figuring out a TiVo’s IP address differs by series and depends on just how you brought it online.

Series 1

As you might expect, given the hackish way in which it was made network-aware, determining the IP address on a Series 1 is a little tricky.

Nowhere in TiVo’s menu system is it simply going to tell you its IP address, so let’s ask nicely at the Bash prompt [Hack #30]. The ifconfig (“interface configuration”) command reports on and configures a computer’s network interfaces: Ethernet, WiFi, modem—anywhere the computer jacks itself into the network. In TiVo’s case, usually the only interface of interest is the phone line (which we are no longer using). And now that TurboNET Ethernet card [Hack #49] we popped into place on the motherboard.

Using the ifconfig command, ask for information on eth0, the first (“zeroth” actually) Ethernet interface, like so:

bash-2.02# /sbin/ifconfig eth0
eth0   Link encap:Ethernet HWaddr 00:C0:F0:51:90:E9 
     inet addr:192.168.0.3 Bcast:192.168.0.255 Mask:255.255.255.0
     UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
     RX packets:6725 errors:0 dropped:0 overruns:0 frame:97
     TX packets:3953 errors:0 dropped:0 overruns:0 carrier:0 coll:0
     Interrupt:29 Base address:0x300

There’s a lot of useful information in that output. Most importantly, TiVo does indeed recognize the TurboNET card as providing an Ethernet connection with a hardware address of 00:C0:F0:51:90:E9, as evidenced by the first line. Knowing the hardware, or MAC, address of your network card can be helpful if you’re going to be bridging your TiVo onto a WiFi network that restricts access by hardware address, or if you want to configure your DHCP server to always hand the TiVo the same IP address. The second line contains the golden ticket, your TiVo’s IP address: 192.168.0.3. Both the hardware and IP addresses above are for my TiVo; your numbers will obviously be different.

Series 2

Surf TiVo menus to TiVo Messages & Setup Settings Phone & Network Setup (see Figure 4-13). There, take a look at the top right and you should see some text that reads “IP address.” The number after it—192.168.0.7 in my case—is your TiVo’s IP address.

The Phone & Network Setup screen under TiVo OS 4.0, showing the IP address
Figure 4-13. The Phone & Network Setup screen under TiVo OS 4.0, showing the IP address

Ping!

With that IP address in hand, you can give it a ping to see if your TiVo is alive—at least as far as the network’s concerned. The term “pinging” borrows from the world of ships and submarines, which use sonar to locate underwater objects (usually one-another); they send out a loud “ping” sound and watch their instruments carefully, noting how the sound waves echo and bounce about and providing a virtual picture of their environment.

  • Pinging your TiVo (or any other computer on the network) means sending a small chunk of data and waiting for it to echo the data back. The ping utility is available to just about any computer operating system with a network heartbeat. Get to the command line (Applications Utilities Terminal on Mac OS X, Start Run... command on Windows) and type (replacing 192.168.0.7 with the IP address of your TiVo):

    $ ping 192.168.0.7
                         
    PING 192.168.0.7 (192.168.0.7): 56 data bytes
    64 bytes from 192.168.0.7: icmp_seq=0 ttl=64 time=7.131 ms
    64 bytes from 192.168.0.7: icmp_seq=1 ttl=64 time=3.116 ms

Press Control-C to stop pinging.

As long as you see echoed responses (e.g., 64 bytes from...), you can be sure your TiVo’s online. If nothing comes back, your ping sitting endlessly at PING 192.168.0.7 (192.168.0.7): 56 data bytes, your TiVo’s not responding and you should go back and check to make sure you’re using the right IP address and took the right steps to getting your Series 1 [Hack #49] or Series 2 online [Hack #50].

Getting Telnet to Your Ethernet-Enabled TiVo

Now that our Series 1 TiVo is using Ethernet [Hack #49] and is online, let’s get a telnet prompt on it.

It’s time to forget that primitive Bash over serial [Hack #30] connection you set up to bootstrap command-line access to your TiVo. While it will remain useful as a backup, let’s face it: that connection is slow and being tied to a host PC is more hand holding than your TiVo needs. This is the age of ubiquitous networking, after all.

But before you say goodbye to that old standby, you’ll use it one last time to turn on telnet, remote login capabilities from anywhere on the network. Using your serial prompt, edit Section 3.11 your rc.sysinit to accept telnet connections by adding the following line at the end:

tnlited 23 /bin/bash -login &

Here, I’m being a little lazy and using the echo command to append the line to rc.sysinit without need of a text editor:

bash-2.02# mount -o remount,rw /
bash-2.02# echo 'tnlited 23 /bin/bash -login &' >> /etc/rc.d/rc.sysinit
bash-2.02# mount -o remount,ro /

Restart your TiVo and wait for it to pass the “A few more moments please...” message on your television set. Once all appears to be up and running, use your favorite telnet application to connect to the IP address of your TiVo [Hack #51], and you’re in like Flynn.

Note

There is absolutely no security when telnetting to your TiVo. Not only are all your commands flowing over the network in the clear, but TiVo doesn’t even ask you for a username and password.

If, for some reason, your home network isn’t behind some sort of firewall, whether provided by your broadband modem or otherwise, you’ll be the wiser for putting some sort of firewall in place—not just for your TiVo, but for the safety of all your computers. Until your network is reasonably protected, you won’t want to open your TiVo to telnet or any other kind of network connection.

Fetching Files from the Web

Now that TiVo has high-speed Internet access, let’s download some files from the Web.

While we now have our TiVo online [Hack #49] and can telnet to the box [Hack #52], there’s still no good way to move files to and from TiVo without doing so via the serial interface using rz/sz [Hack #36].

Tip

While rz/sz [Hack #36] will happily move files over the serial line, they don’t play nicely with non-8-bit connections like the telnet interface.

Let’s think about this for a bit. How does TiVo itself download stuff? Those software updates, for instance. It sets up a dialup-PPP connection to TiVo, Inc. and downloads files over HTTP. Why, then, can’t we simply use the same mechanism over our higher-class permanent network connection? Well, we can.

TiVo sports a little application called http_get, which, as its name suggests, grabs files remotely using HTTP as its transport mechanism. One caveat is that http_get can’t do any domain name resolution.

On top of requiring the IP address, http_get is actually quite finicky. Let’s fiddle a bit and see what we can learn, shall we?

Let’s say, for instance, you wanted to download a copy of the TiVoWeb server [Hack #65]. You’d invoke http_get like so:

bash-2.02# http_get -T 0 -C 0 -D /var/hack -U http://199.240.141.102:80/
tivoweb-tcl-1.9.4.tar.gz

This command asks TiVo to download the file at http://199.240.141.102:80/tivoweb-tcl-1.9.4.tar.gz (-U is for URL) to the local /var/hack [Hack #36] directory (-D is for directory). Because http_get was originally designed for the TiVo to use exclusively when connecting to TiVo, Inc., it also requires the -T and the -C flags, representing the serial number of the unit and the ID of the call, respectively. Simply set both to 0. Be sure to specify the URL fully. You’ll get the following error if you leave off the :80 specifying the default HTTP port number:

connect failed, reason = Connection refused
Segmentation fault

You’ll get the following error if you try to specify a DNS name instead of an IP address:

connect failed, reason = Network is unreachable
Segmentation fault

Not being able to specify a DNS name turns out to be more problematic than you’d think. Many web servers do something called “virtual hosting” these days. This means that many domain names actually map to the same IP address, since specifying the host name specified onboard is the only way to tell two requests for two different domains apart. Take oreilly.com and oreillynet.com, for example—for both, one of their IP addresses is 209.201.239.37. The server at that IP address knows which site you mean to visit only because your browser passes along the domain name portion of the URL as part of the HTTP request. If you don’t specify a host name, the web server is either going to pick one or attempt to redirect you—the latter being something http_get doesn’t like at all.

About the only way around this shortcoming is to download the file you’re after to a machine that is accessible by IP address—one on your local network or a server out there on the Internet—and instruct TiVo to grab it from there. Of course, you can still pass files back and forth serially [Hack #36] as a last resort.

wget Things from the Web

Bring the power of GNU wget, the ubiquitous file fetcher, to your TiVo.

http_get [Hack #53] is quite limited in what it can do. It’s biggest limitation is that it can’t talk to virtual hosts. As more and more web hosting shifts away from the one web server per IP address model, this can be an impediment.

The main reason that http_get can’t talk to virtual hosted servers is because it can’t do DNS resolution, relying instead on hard-coded IP addresses in the scripts that call it. In fact, the Linux installation running on the Series 1 TiVo doesn’t have support for name resolution at all.

If you desperately must have a tool that can do name resolution for the Series 1, take a look at my wget.tcl (http://www.bitwaste.com/tivo/wget-tcl.tar.gz). The archive is packaged in a similar way. Just upload it to your TiVo, put it in /var, and extract it:

bash-2.02# gzip -d wget-tcl.tar.gz
bash-2.02# cd /
bash-2.02# cpio -i -H tar --make-directories < /var/wget-tcl.tar.gz
bash-2.02# chmod 755 /var/hack/bin/wget.tcl

This script and its supporting libraries are built upon the DNS support in the Tcllib (http://tcllib.sourceforge.net), enabling it do DNS resolution completely in Tcl. If you point the script at hacks.oreilly.com as in the previous command, it’ll download index.html as before.

My wget.tcl, as of yet, does not handle FTP-based URLs.

Setting Up an FTP server

Transfer files to and from your TiVo with the ease of FTP.

FTP used to be the de facto way to move files around the Net, but HTTP is quickly catching up. However, despite the efforts of WebDAV (http://www.webdav.org/) and the like, an FTP server is still about the easiest way to push things to a computer. There’s a plethora of client software out there for Mac, Windows, Unix, you name it. And, thanks to “sorphin,” there’s an FTP server for your TiVo, part of the TiVo Utilities project (http://tivoutils.sourceforge.net/).

Grab the FTP server for your TiVo from http://prdownloads.sourceforge.net/tivoutils/tivoftpd.ppc.gz?download. With that in hand, you’re faced with a classic chicken-and-egg problem: how are you to get the FTP server over to TiVo without FTP access? Hopefully you left your serial port running with Bash, because you are going to use rz [Hack #36].

With the downloaded file on your TiVo, unpack the daemon (read: server) and drop it into your /var/hack/bin [Hack #36] directory as tivoftpd.

bash-2.02# gzip -d /var/hack/bin/tivoftpd.ppc.gz
bash-2.02# mv /var/hack/bin/tivoftpd.ppc.gz /var/hack/bin/tivoftpd

Finally, mark the program executable and start the server with:

bash-2.02# chmod 755 /var/hack/bin/tivoftpd
bash-2.02# /var/hack/bin/tivoftpd

The program will return you to your prompt immediately, with the server running quietly in the background. To test it, point your favorite FTP program at your TiVo’s IP address [Hack #51].

If you are coming in from a command-line FTP program, the start of your session will look something like this:

Connected to tivo (192.168.0.3).
220 You are in TiVo Mode. 220 Login isn't necessary.       
220 Please hit ENTER at the login/password prompts.
Name (tivo:r):
331 No Auth required for TiVo Mode.
Password:
230 Running in TiVo Mode.
Remote system type is UNIX.
ftp>

Warning

Like TiVo’s telnet access, there is no security on the FTP daemon. Anybody can get in, upload, download, and delete files at will. Make sure that your TiVo is behind a pretty strong firewall if you plan to leave FTP running all the time.

I recommend you don’t run the FTP server all the time, preferring to run it only when you need it and kill it when you’re done. There is no pretty, built-in way to shut down the FTP daemon, so you’ll have to do it the Unix way. Figure out the process ID of the FTP server (tivoftpd) and kill it:

bash-2.02# ps auxw | grep tivoftpd
root   1220 0.0 0.0   0   0 ? SW  01:21  0:00 /var/hack/bin/tivoftpd 
root   1233 0.0 0.0   0   0 p0 SW  01:21  0:00 grep tivoftpd
bash-2.02# kill -9 1220

That should take it down. If you want to check, issue the ps auxw | grep tivoftpd again, and you should no longer see any mention of the tivoftpd process.

Using the Same Filesystem

Rather than all this passing about of files back and forth between TiVo and your PC, mount an NFS share on your TiVo and access that networked partition as if it were local to your TiVo.

Rather than uploading MP3s [Hack #46] to your TiVo to play, or FTPing in to grab the latest version of that Now Playing List for incorporation into your web site [Hack #90], NFS-mount your PC’s drive on your TiVo, and read and write files as if the drive were local to TiVo.

Just as we inserted a kernel module to give TiVo access to Closed Captioning [Hack #42], we can do the same to get network filesystem (NFS) support loaded into TiVo’s OS. Download a copy of the kernel module (http://themurrays.homeip.net/downloads/tivo/for_tivo/nfs-kernelmod_tivo25-1.zip) and unzip it on your local PC. Upload the nfs-tivo25.o file contained therein to your TiVo and drop it into /var/hack/modules.

Tip

While these instructions should work about the same on Series 1 and 2 TiVos, at the time of this writing there is no NFS module for the Series 2.

To activate the kernel extension, type the following at TiVo’s Bash prompt:

bash-2.02# /sbin/insmod -f /var/hack/modules/nfs-25.o

You now have the ability to mount and talk to NFS servers on your network from your TiVo. Now, let’s move on to the PC side of things.

Serving NFS from Windows

There are a plethora of NFS servers out there for Windows, but one of the more popular ones is the XLink NFS Server (http://www.xlink.com/eval.htm). It’s a breeze to setup and get working with your TiVo.

Bring up the XLink NFS Server (see Figure 4-14), and click the New button to create a new mount point. The NFS Server Export tool shown in Figure 4-15 lets you configure and set up the directory for remote mounting.

The XLink NFS Server interface
Figure 4-14. The XLink NFS Server interface
The XLink NFS Server Export tool
Figure 4-15. The XLink NFS Server Export tool

Setting up security on an NFS mount can be a really tricky thing. But since you are supposed to be working behind your home network’s firewall, we can just ignore all that. Give all clients read/write access to the directory. This will let the TiVo mount the directory, get files, and put files over the network.

Click OK. The new mount should show up in the main XLink NFS Server window (see Figure 4-16).

The XLink server exporting the “C:\Documents and Settings\r\Desktop\tv” directory
Figure 4-16. The XLink server exporting the “C:\Documents and Settings\r\Desktop\tv” directory

Serving NFS from Linux

There is no graphical tool to set up NFS mounts on Linux. On a Red Hat box, make sure that you have the nfs-utils RPM installed on your system; then edit your /etc/exports file, adding the directory that you wish to allow your TiVo to mount. Such a configuration directive should look something like this:

/tivodir tivo.homenetwork.net(rw,no_root_squash)

This command will export /tivodir over NFS, restricting access to only tivo.homenetwork.net. But when the TiVo does connect, it has full read/write access to that directory.

Restart nfs to export the NFS share, ready for remote mounting:

[root@localhost r]# /etc/rc.d/init.d/nfs restart
Shutting down NFS mountd:                 [ OK ]
Shutting down NFS daemon:                 [ OK ]
Shutting down NFS quotas:                 [ OK ]
Shutting down NFS services:               [ OK ]
Starting NFS services:                    [ OK ]
Starting NFS quotas:                      [ OK ]
Starting NFS daemon:                      [ OK ]
Starting NFS mountd:                      [ OK ]

Mounting an NFS Share on Your TiVo

Let’s assume you have an NFS server running on a PC named nfs.homenetwork.net, which shares a /for_tivo directory to be mounted by your TiVo. Create a /var/mnt directory under which to keep NFS-mounted directories. Create a subdirectory named appropriately for the machine and directory you are going to mount:

bash-2.02# mkdir /var/mnt
bash-2.02# mkdir /var/mnt/
               
                  homenetwork
               
bash-2.02# mount nfs.homenetwork.net
               
               :
               
                  /for_tivo 
               
               /var/mnt/
               
                  homenetwork
               

That’s all there is to it. Now, whatever files you place into the /var/mnt/homenetwork directory on your TiVo or the for_tivo directory on your PC will be accessible to the other.

Reading Email on Your TiVo

What’s the point of a network connection if you can’t read your email?

For many people these days, reading email is like breathing itself. The first thing they do with a network connection is grab their email. Why should your networked TiVo [Hack #49] be any different?

It shouldn’t, or so answers Douglas Mayle with TPOP (http://www.networkhackers.com/tpop/), his POP3 email client for TiVo. TPOP queries a standard POP3 email server over your network connection, slurping new mail messages into TiVo’s built-in message queue (Messages & Setup Read New Messages), which is reasonably well-suited to repurposing in this way.

Tip

As the name suggests, TPOP doesn’t do IMAP. That’s a pity, given that IMAP seems better suited for the task, keeping its message store on the mail server rather than locally on your TiVo.

Grab a copy of TPOP (http://www.networkhackers.com/tpop/tpop.tar.gz), transfer it to your TiVo [Hack #36], expand it, and put it into place under your /var/hack directory:

bash-2.02# cd /var/hack
bash-2.02# gzip -d tpop.tar.gz
bash-2.02# cpio -i -H tar < tpop.tar
bash-2.02# rm tpop.tar
bash-2.02# chmod 755 tpopd.tcl
bash-2.02# mv tpopd.tcl bin
bash-2.02# mv tpopd.conf etc 

All that remains is to configure TPOP to know where and how to retrieve your email. Thankfully, Mayle has built all this in, allowing you to build a new configuration file from the command-line, like so:

bash-2.02# tpopd.tcl -c /var/hack/etc/tpopd.conf -S -s 192.168.0.1 -P 110 -u
raffi -p 
            
               my_password
            

You should replace 192.168.0.1 with the IP address of your POP3 email server (sorry, TiVo doesn’t do DNS resolution), 110 with the appropriate port specification (it’s usually 110), and raffi and my_password with your email account’s username and password. The script will overwrite the configuration file (/var/hack/etc/tpopd.conf) with the specified values.

Once configured, launch TPOP:

bash-2.02# tpopd.tcl -c /var/hack/etc/tpopd.conf

The script will start running in the background, checking your email every 10 minutes. Send yourself an email message from your usual email application, come back in a few minutes (Messages & Setup Read New Messages), and read email right on your very own television screen (see Figure 4-17).

Personal email incorporated into TiVo’s message queue
Figure 4-17. Personal email incorporated into TiVo’s message queue

The TiVo interface doesn’t provide any real way to respond to that email, and TPOP keeps itself to downloading new messages and injecting them into the queue. This means that email on the TiVo is relegated to read-only. Still, it’s a rather nice trick at that!

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 [Hack #57] onscreen. If you have a DirecTivo, you have caller ID information [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 [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 [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/tcs directory, 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:

9 9 Clear

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:

8 2 Clear

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.

A 600-mile weather map, as displayed by the TCS
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:

8 3 Clear

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

6 0 Clear

All the available sports scores

6 1 Clear

Major League Baseball scores

6 2 Clear

National Football League scores

6 3 Clear

NCAA College Football scores

6 4 Clear

National Hockey League scores

6 5 Clear

National Basketball Association scores

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

The national weather on this very rainy day in the northeast, as displayed by the TCS
Figure 4-19. The national weather on this very rainy day in the northeast, as displayed by the TCS
Current NHL standings, as displayed by the TCS
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 9 9 Clear 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 Clear 7 Clear 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.

Stock quotes, brought to you by TCS
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

Turning Your TV into a Virtual Window

It’s raining in Boston, and you’re stuck inside for the day. Take a virtual trip to a far-off tropical locale, without ever leaving your recliner.

It’s winter time, and you’re sitting at home, freezing, and wishing desperately that you could be some place warmer. While your TiVo is not going to beam you up to a tropical locale, perhaps it can provide some virtual heat.

The TiVo Home Media Option (HMO) [Hack #63] allows you to display a slideshow of your digital photos right on your television set. What about putting up live pictures from the Web, perhaps of some place you would rather be? Thanks to the dual miracles of webcams and wget [Hack #54], you can do just that.

Find your favorite Internet webcam—I personally like http://www.mauimanakai.com/webcam.htm—and figure out the URL of the image itself. You can easily do so by opening up the source of the web page on which it’s displayed and doing some hunting and pecking.

Grab a copy of wget for your PC. Windows users will find a port at http://space.tin.it/computer/hherold/, while Mac OS X users will find theirs at http://www.apple.com/downloads/macosx/unix_open_source/wget.html. Install wget using the instructions provided with the application. Next, instruct it to download an image from the webcam and place it into a directory you’re sharing with your TiVo through the HMO. On my Mac, I type:

$ wget -O /Users/r/Desktop/TiVo/webcam/image.jpg http://www.mauimanakai.com/
panasonic.jpg
            

Take a gander at the image using your TiVo’s HMO Photo viewer. If all goes to plan, you should be transported—in mind at least—to your tropical paradise.

But a static picture won’t satisfy you for long; you’ll want to keep up the illusion by having a fresh version download every 5 minutes or so.

Automating Webcam Downloads with Windows

Your first instinct may be to use the Windows Task Scheduler. However, the smallest time interval it can work with is 1 hour. That just won’t do! Thankfully, WinCron from DWG Software (http://www.dwgsoftware.com) is just the ticket.

Download, install, and start WinCron. If you’ve ever seen the command-line Unix version of cron [Hack #44], you’ll find WinCron (shown in Figure 4-22) rather familiar, albeit slightly prettier.

The WinCron interface
Figure 4-22. The WinCron interface

Click the Add button to bring up an interface to adding a new scheduled task (see Figure 4-23).

Add a new job to WinCron
Figure 4-23. Add a new job to WinCron

Use the same wget command line that I used to grab the webcam image and paste it into the Command field. Make sure to specify the right path to wget (wget.exe, in this case) and pass it the right command-line arguments for output and download. Once you have all that squared away, set it up to run the command every five minutes. Click the Apply button, and that’s that.

Automating Webcam Downloads with Mac OS X

Setting up this repeating task in OS X is easy using cron [Hack #44]. At the Terminal (Applications Utilities Terminal), type:

$ crontab -e

Up comes your existing (or a new) crontab—in the vi text editor, most likely. Set the last line of your crontab to:

*/5 * * * * wget -O /Users/r/Desktop/TiVo/webcam/image.jpg http://www.
mauimanaki.com/panasonic.com

Of course, you should replace the URL with the URL appropriate for the webcam that you are accessing, and you should also replace the download directory with the one on your Mac that the TiVo is going to be accessing. Save the updated crontab file and your Mac will, once every 5 minutes, download a fresh image and put it into the shared HMO directory.

Watching Time (and the Waves) Roll By

Go back to the image on your TiVo and select it as a slideshow running with repeats, as shown in Figure 4-24. This way, you’ll constantly have something to look at. And just leave it. As more and more images come in, the slideshow loop will get longer and longer, making it more possible for you to dream that you are actually there.

Start the slideshow of the webcam images
Figure 4-24. Start the slideshow of the webcam images

Streaming Internet Audio Broadcasts to TiVo

Stream SHOUTcast Internet audio alongside your own MP3s to your HMO-enabled TiVo.

TiVo’s Home Media Option (HMO) [Hack #63] allows you to stream MP3 music from your home PC through your TiVo to your television and home audio system speakers. But what of those online music broadcasts, streamed talk shows, and specials? The HMO can handle those too, thanks to Tobias Hoellrich’s m3ugen.pl (http://www.kahunaburger.com/blog/archives/000054.html).

m3ugen.pl is a simple Perl (http://www.perl.com) script that generates .m3u files from SHOUTcast playlists. These .m3u files are what TiVo uses to stream music from PCs and Macs in your house to TiVo.

The Code

Save the following code to a file named m3ugen.pl somewhere on your PC or Mac’s hard drive:

#!c:\perl\bin\perl.exe

use strict;
use HTML::LinkExtor;
use LWP::Simple;
use URI::URL;
use constant PROVIDER => qq{http://www.shoutcast.com/};
use constant DIRECTORY => PROVIDER.qq{directory/};

my $genre=$ARGV[0];
my $results=$ARGV[1];
my $outfile=$ARGV[2];
unless (defined($genre) &&
    defined($results) && $results && $results <= 25 &&
    defined($outfile)) {
  die qq{Usage:\t$0 [genre] [numresults] [outfile]\n}.
    qq{\tgenre=TopTen,House,Blues,Punk,...\n}.
    qq{\tnumresults=1..25\n}.
    qq{\toutfile=m3u output file\n};
}

my @playlists=getPlaylists(DIRECTORY.
qq{?sgenre=$genre&numresult=$results},PROVIDER);
unless (scalar(@playlists)) {
  die "No results found - unable to create playlist\n";
  exit(0);
}
@playlists=mapForTiVo(@playlists);

open(OUT,">".$outfile) or die "Unable to create output file - $!";
print OUT qq{#EXTM3U\n};

foreach my $entry (@playlists) {
  my($url,$title)=%$entry;
  print OUT qq{#EXTINF:,$title\n$url\n};
}
close(OUT);

sub getPlaylists {
  my($url,$base)=@_;
  my(@results);
  my $content=get($url);

  unless (defined($content) && length($content)) {
    warn qq{Unable to fetch "$url"\n};
    return @results;
  }

  my $parser=HTML::LinkExtor->new(sub {
    my($t,%a)=@_;
    return if $t ne 'a';
    push(@results,$a{href}) if($a{href}=~/filename\.pls$/i);
  });

  $parser->parse($content);
  @results = map {$_=url($_,$base)->abs;} @results;
  return @results;
}

sub mapForTiVo {
  my(@list)=@_;
  my(@results);

  foreach my $url (@list) {
    my $content=get($url);
    next unless(defined($content) && length($content));

    my($file);
    foreach my $line (split(/[\n\r]/,$content)) {
      if ($line =~ /^File\d+=(.*)$/i) {
        my $u=URI::URL->new($1);
        $u->path(""),$file=$u->abs if($u->path eq '/' || $u->path eq '');
      } elsif ($line =~ /^Title\d+\s*=(.*)$/i && defined($file)) {
        push(@results,{$file => $1});
        last;
      }
    }
  }
  return @results;
}

Mac OS X should alter the first line to point to the proper location of Perl:

#!/usr/bin/perl

Running the Hack

Let’s say I share the path c:\tivo\mp3\ on my Windows PC with my TiVo’s HMO Music option. Let’s also say that I want the top 15 Punk stations from SHOUTcast (http://www.shoutcast.com), so I can listen to the music broadcasts of these stations through my TiVo. I’d invoke the m3ugen.pl at my PC’s DOS prompt (Start Run... command), like so:

C:\> perl m3ugen.pl Punk 15 c:\tivo\mp3\Punk.m3u

Tip

If you don’t have a copy of the Perl programming language on your system, download and install a copy of ActivePerl from ActiveState (http://www.activestate.com/Products/ActivePerl/).

On a Mac, sharing the path ~/tivo/mp3/Punk.m3u, I’d run m3ugen.pl from the Terminal (Applications Utilities Terminal), as follows:

% perl m3ugen.pl Punk 15 ~/tivo/mp3/Punk.m3u

The script will visit www.shoutcast.com, look up the Punk category, extract the playlists of the 15 most popular Punk stations, download each individual playlist, find TiVo-compatible server entries, and generate a Punk.m3u file.

Note

The HMO only likes streams with URLs of the format:

http://hostname:port

It doesn’t work with more “involved " URLs like:

http://hostname:port/dir/dir

When asked to play a stream at such a URL, the HMO will simply fail to do so.

You’ll then magically find a Punk.m3u section under Music and Photos Music section of your HMO-enabled TiVo. Select it and listen to some of the finest punk music streamed over the Net. See Figure 4-25.

The top 15 Punk SHOUTcast stations brought to your TiVo
Figure 4-25. The top 15 Punk SHOUTcast stations brought to your TiVo

Tip

The HMO doesn’t buffer streamed Internet-audio. If the stream pauses due to traffic congestion or any other problem, the HMO will just punt it and move on.

If Punk’s not quite your cup of tea, visit http://www.shoutcast.com and choose a more appropriate genre from the “—Choose a genre —” pull-down list on the right side of the page. The page will refresh, and you’ll end up on a page whose URL begins with http://www.shoutcast.com/directory/?sgenre=. The word after the = (equals sign) is what you should feed m3ugen.pl on the command line to find the most popular streams of that genre.

—Tobias Hoellrich

Watching Your Email

Is a picture indeed worth a thousand words? That depends on how many words are in the picture. Render your email as PNG images, suitable for viewing via the TiVo HMO’s photo sharing.

Series 2 users may not be able to check their email on their TiVo using TPOP [Hack #57], but this is nothing a little Perl scripting can’t fix. Tobias Hoellrich comes through again with mailrender.pl (http://www.kahunaburger.com/blog/archives/000052.html). The script runs every so often, fetches any new mail from your POP3 mail server, and renders email as PNG image files for display via TiVo’s Home Media Option (HMO) [Hack #63] on your TV.

In addition to Perl (http://www.perl.com) itself, you’ll need the following Perl modules, all freely downloadable from the Comprehensive Perl Archive Network (CPAN) at http://www.cpan.org:

GD (http://search.cpan.org/author/LDS/)

An interface to the GD graphics library

Mail::Internet (http://search.cpan.org/author/MARKOV/)

For manipulating Internet mail messages

Mail::POP3Client (http://search.cpan.org/author/SDOWD/)

An interface for talking to POP3 mail servers

File::Path (http://search.cpan.org/author/JHI/)

For manipulating directory trees

File::Spec (http://search.cpan.org/author/JHI/)

For fiddling with file names

Tip

Windows users will probably find it easiest to install these modules using PPM (http://aspn.activestate.com/ASPN/Reference/Products/ActivePerl/faq/ActivePerl-faq2.html), ActivePerl’s package manager. Mac users, use the CPAN module (http://search.cpan.org/author/ANDK/CPAN-1.70/lib/CPAN.pm).

The Code

Save the following code to a file named mailrender.pl somewhere on your PC or Mac’s hard drive:

#!c:\perl\bin\perl.exe
use strict;
use File::Path;
use File::Spec;
use GD;
use Mail::POP3Client;
use Mail::Internet;

use constant DESTINATION  => q{d:\DigitalPhotos\Tivo\EMail};
use constant PREVIEW_LINES => 100;
use constant WIDTH     => 640;
use constant HEIGHT    => 480;
use constant HEADER_FONT  => gdMediumBoldFont;
use constant BODY_FONT   => gdLargeFont;

my @accounts = (
 {
 DESC   => q{
               
                  thoellri@foobar.com
               
               },
               USER   => "
               
                  thoellri
               
               ",
               AUTH_MODE => "PASS",
               PASSWORD => "
               
                  password
               
               ",
               HOST   => "
               
                  pop3.foobar.com
               
               "
               },
                {
                DESC   => q{
               
                  tobias@somewhere.com
               
               },
               USER   => "tobias",
                AUTH_MODE => "PASS",
               PASSWORD => "
               
                  password
               
               ",
               HOST   => "
               
                  mail.somewhere.com
               "
 },
);

for my $account (@accounts) {
 # erase existing messages
  rmtree([ File::Spec->catfile(DESTINATION, $account->{DESC}) ], 0, 0);
  my $pop = new Mail::POP3Client (%$account);
  unless ($pop) { warn "Couldn't connect\n"; next; }
  my $count = $pop->Count;
  if ($count <0) { warn "Authorization failed"; next; }
  next if($count == 0); # no new messages
 # create new directory for messages
  mkpath([ File::Spec->catfile(DESTINATION, $account->{DESC}) ], 0, 0711);
  for my $num (1..$count) {
    my @preview=$pop->HeadAndBody($num,100);
    my $mail=Mail::Internet->new(\@preview);
    my $header=$mail->head;
    my $image=render($mail);
    my $out=File::Spec->catfile(DESTINATION, $account->{DESC},qq{message-}.
                  sprintf("%02d",$num).qq{.png});
    open(OUT, qq{>$out});
    binmode OUT;
    print OUT $image->png;
    close(OUT);
  }
  $pop->Close;
}
sub render {
  my($m)=@_;
  my $header=$m->head(  );
  my $im = new GD::Image(WIDTH, HEIGHT);
  # allocate some colors
  my $white = $im->colorAllocate(255,255,255);
  my $black = $im->colorAllocate(0,0,0);
  my $gray = $im->colorAllocate(20,20,20);
  my $red = $im->colorAllocate(255,0,0);
  my $blue = $im->colorAllocate(0,0,255);
  my $y=2;
  $im->string(HEADER_FONT, 5,$y, "Date:  ".$header->get('Date'),[RETURN]
  $black);$y+=10;
  $im->string(HEADER_FONT, 5,$y, "From:  ".$header->get('From'),[RETURN]
  $black);$y+=10;
  $im->string(HEADER_FONT, 5,$y, "To:   ".$header->get('To'),[RETURN]
  $black);$y+=10;
  $im->string(HEADER_FONT, 5,$y, "Subject: ".$header->get('Subject'),[RETURN]
  $blue);$y+=10;
  $im->string(HEADER_FONT, 5,$y, "-" x 80, $black);$y+=8;
  foreach my $line (@{$m->body(  )}) {
    chomp($line);
    $im->string(BODY_FONT, 5, $y, $line, $gray);
    $y+=13; last if($y>=HEIGHT);
  }
  return $im;
}

Mac OS X should alter the first line to point to the proper location of Perl:

#!/usr/bin/perl

Tip

If you don’t have a copy of the Perl programming language on your Windows system, download and install a copy of ActivePerl from ActiveState (http://www.activestate.com/Products/ActivePerl/).

You’ll want to set the DESTINATION variable (highlighted in bold in the previous script) to an appropriate directory into which the script should place those generated PNG images:

               use constant DESTINATION  => q{
               
                  d:\DigitalPhotos\Tivo\EMail
               
               };

For example, on my Mac, I might choose a space somewhere in my Pictures folder that I configured my HMO to read:

               use constant DESTINATION  => q{
               
                  /Users/raffi/Pictures/Hacks/Tivo/Email
               
               };

Next, configure the script for your email particulars by changing the default settings in the @accounts array (called out in bold in the previous script). For each account, set the DESC to a reasonable description of the email account, set USER and PASSWORD to your email username and password, and set HOST to the name of my POP3 mail server.

For example, here is my setup:

my @accounts = (
 {
 DESC   => q{
               
                  raffi@bitwaste.com
               
               },
                USER   => "
               
                  raffi
               
               ",
               AUTH_MODE => "PASS",
               PASSWORD => "
               
                  my_password
               
               ",
               HOST   => "
               
                  pop.bitwaste.com
               
               "
 },
);

Notice that I have only one account listed. To add more, simply paste in another copy of the account settings—starting with { and ending with }—and be sure to put a , between each.

You want to set the DESC to be a description of the email account, and setting it to your email address is just fine. USER and PASSWORD are self-explanatory, and HOST is the name of your POP3 server.

Running the Hack

Run the script from the DOS prompt (Start Run... command) on your Windows PC or from the Terminal (Applications Utilities Terminal) under Mac OS X, like so:

               perl mailrender.pl

The script will download (but not delete) your email and render a slew of PNG image files like the one shown in Figure 4-26.

An email message rendered as a PNG image by the mailrender.pl script
Figure 4-26. An email message rendered as a PNG image by the mailrender.pl script

Tip

You can have mailrender.pl regularly render your email into PNG files automatically by using Scheduled Tasks on your Windows PC (Start Programs Accessories System Tools Scheduled Tasks) or cron on your Mac (see O’Reilly’s Mac OS X Hacks).

Pictures placed in your HMO-shared images directory will be snatched up by the HMO, ready to be displayed along with those family photos, as shown in Figure 4-27.

An email message in the TiVo HMO’s gallery
Figure 4-27. An email message in the TiVo HMO’s gallery

Have fun reading—or watching, to be precise—your email.

—Tobias Hoellrich

Listen to Your Email

Listen to your email as an MP3 audio stream—just because you can.

Just when you thought pictures of your email [Hack #61] was over the top, someone had to go and take it even further. Instead of rendering your email to a PNG image, let’s render it to audio.

A combination of the script from [Hack #61] and the Microsoft Speech Object Library (http://www.microsoft.com/speech/) reads the first few lines of each email message, rendering them as a temporary WAV audio file. That WAV file can then be converted using bladeenc (http://bladeenc.mp3.no/) or the like to an MP3 file that TiVo can understand and play. If all goes well, we can move the MP3 into an area that can be “seen” by the TiVo Media Desktop.

Tip

Version 5 of the Microsoft Speech Object Library is installed by default under Windows XP Professional, so you won’t need to install it again if you’re running XP Pro.

The Code

Save the following code to a file named mail2mp3.pl somewhere on your PC hard drive, and follow the configuration instructions from [Hack #61]:

#!c:\perl\bin\perl.exe

use strict;
use Cwd;
use File::Copy;
use File::Path;
use File::Spec;
use Mail::POP3Client;
use Mail::Internet;
use LWP::Simple;
use Win32;
use Win32::OLE;
use Win32::OLE::Const qq{Microsoft Speech Object Library};

use constant DESTINATION  => q{D:\MP3\TiVo};
use constant PREVIEW_LINES => 30;

my @accounts = (
 {
 DESC   => q{thoellri@foobar.com},
 USER   => "thoellri",
 AUTH_MODE => "PASS",
 PASSWORD => "password",
 HOST   => "pop3.foobar.com"
 },
 {
               DESC   => q{tobias@somewhere.com},
 USER   => "tobias",
 AUTH_MODE => "PASS",
 PASSWORD => "password",
 HOST   => "mail.somewhere.com"
 },
);

for my $account (@accounts) {
 # erase existing messages
  rmtree([ File::Spec->catfile(DESTINATION, qq{Email}, $account->{DESC}) ],[RETURN]
    0, 0);
  my $pop = new Mail::POP3Client (%$account);
  unless ($pop) { warn "Couldn't connect\n"; next; }
  my $count = $pop->Count;
  if ($count <0) { warn "Authorization failed"; next; }
  next if($count == 0); # no new messages
 # create new directory for messages
  mkpath([ File::Spec->catfile(DESTINATION, qq{Email}, $account->{DESC}) ],[RETURN]
    0, 0711);
  for my $num (1..$count) {
    my @preview=$pop->HeadAndBody($num,100);
    my $mail=Mail::Internet->new(\@preview);
    my $mp3file=mail2mp3($mail);
    next unless defined($mp3file);
    my $out=File::Spec->catfile(DESTINATION, qq{Email}, $account->{DESC},
                  qq{message-}.sprintf("%02d",$num).qq{.mp3});
    copy($mp3file,$out);
    unlink($mp3file);
  }
  $pop->Close;
}

sub mail2mp3 {
  my($m)=@_;
  my $header=$m->head(  );
  my $type=Win32::OLE->new('SAPI.SpAudioFormat');
  $type->{Type}=SAFT32kHz16BitMono;
  my $stream=Win32::OLE->new('SAPI.SpFileStream');
  $stream->{Format}=$type;
  $stream->Open("output$$.wav",SSFMCreateForWrite,undef);
  my $speech=Win32::OLE->new('SAPI.SpVoice');
  $speech->{AudioOutputStream}=$stream;
  $speech->Speak(qq{From: }.$header->get('From'),SVSFDefault);
  $speech->Speak(qq{Subject: }.$header->get('Subject'),SVSFDefault);
  my($lines);
  foreach my $line (@{$m->body(  )}) {
    chomp($line);
    $speech->Speak($line." ",SVSFDefault);
    last if($lines++>= PREVIEW_LINES);
  }
  $speech->WaitUntilDone(-1);
  $stream->Close(  );
  return undef unless (-f "output$$.wav");
 # here we call out to the command line mp3 encode
  system(qq{bladeenc -quiet -nocfg -quit output$$.wav output$$.mp3});
  unlink(qq{output$$.wav});
  return undef unless (-f "output$$.mp3");
  return File::Spec->catfile(getcwd,qq{output$$.mp3});
}

Running the Hack

Run the script from the DOS prompt (Start Run... command) on your Windows PC or from the Terminal (Applications Utilities Terminal) under Mac OS X, like so:

perl mail2mp3.pl

With this magic running, your email will be downloaded but not deleted. Your computer will start silently talking to itself and recording itself (see Figure 4-28). It’ll then compress all the sounds down to a basket-full-o'-MP3s that your TiVo would be content to sit and play all day and night.

An email message as MP3 audio through the TiVo Home Media Option
Figure 4-28. An email message as MP3 audio through the TiVo Home Media Option

See Also

—Tobias Hoellrich

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required