Sign In/My Account | View Cart  
advertisement


Listen Print Discuss

Hacking the XML in Your TiVo
by Bob DuCharme | Pages: 1, 2, 3

Let's review the steps by looking at the Linux shell script that drives it. (To run it yourself, first substitute your appropriate values for your-TiVoIP-here and your-MAK-here in the shell script. This zip file stores all the scripts and stylesheets used to make this happen. It includes Windows batch file equivalents of the tivoroll.sh and nowplaying.sh files.)

#! /bin/sh

export TiVoIP=your-TiVoIP-here
export MAK=your-MAK-here

# pull the TiVoRoll XML down from the TiVo
wget --no-check-certificate --http-user=tivo --http-password=$MAK \
-O /tmp/tivoroll.xml "https://$TiVoIP/TiVoConnect?Command=QueryContainer\
&Container=%2FNowPlaying&Recurse=No"

# Convert it to HTML markup
xsltproc -o /tmp/tivoroll.html tivoroll2p.xsl /tmp/tivoroll.xml

# FTP the result to a public web server
ftp -n snee.com < tivoroll.l.ftp

The wget utility pulls down the XML we want, the libxslt XSLT processor xsltproc creates HTML from the XML, and ftp uses a script to automate the process of putting the HTML into the right directory on the snee.com server where my weblog resides.

My application that creates an Atom feed of the Now Playing list of saved episodes is almost identical to the one that creates a TiVoRoll for my weblog. The driver shell script passes a Recurse=Yes version of the URL to wget to get the details about the stored episodes, then calls xsltproc with an XSLT stylesheet that creates an Atom 1.0 file, and it finishes by using an FTP script that puts the result of the XSLT pass into a different directory on the web server (http://www.snee.com/rss/nowplaying.atom, in case you're interested in seeing what's on our TiVo). A cron job on my home Linux box runs both scripts before I get up each morning.

Querying the TiVo Desktop

The TiVo Desktop is a Windows program that, when run on your home network, lets you use your TiVo to display pictures and play music on your TV that it retrieves from the computer running the TiVo Desktop. Computers on your network can talk to the TiVo Desktop using URLs like those shown above to find out what pictures and music are available.

Because you'll be sending your queries to the Windows machine and not to the TiVo, you must first find out its IP address. The ipconfig command-line utility that comes with Windows shows you this and related information. For mine, it was 192.168.2.102, so the following URL retrieved XML that listed the high-level containers:

http://192.168.2.102:8080/TiVoConnect?Command=QueryContainer

(Note that the URL scheme prefix is http and not https and that a port number of 8080 is included in the URL.) Here is the XML that it retrieved:


<?xml version="1.0" encoding="ISO-8859-1" ?>
<TiVoContainer>
  <Details>
    <Title>BLACKDELL</Title>
    <ContentType>x-container/tivo-server</ContentType>
    <SourceFormat>x-container/folder</SourceFormat>
    <TotalItems>2</TotalItems>
  </Details>

  <Item>
    <Details>
      <Title>Bob's Music on BLACKDELL</Title>
      <ContentType>x-container/tivo-music</ContentType>
      <SourceFormat>x-container/folder</SourceFormat>
      <LastChangeDate>0x43BB4121</LastChangeDate>

    </Details>
    <Links>
      <Content>
        <Url>/TiVoConnect?Command=QueryContainer&Container=%2FTivoMusic</Url>
        <ContentType>x-container/tivo-music</ContentType>
      </Content>
    </Links>

  </Item>
  <Item>
    <Details>
      <Title>Bob's Photos on BLACKDELL</Title>
      <ContentType>x-container/tivo-photos</ContentType>
      <SourceFormat>x-container/folder</SourceFormat>
      <LastChangeDate>0x43D40340</LastChangeDate>

    </Details>
    <Links>
      <Content>
        <Url>/TiVoConnect?Command=QueryContainer&Container=%2FTivoPhotos</Url>
        <ContentType>x-container/tivo-photos</ContentType>
      </Content>
    </Links>

  </Item>
  <ItemStart>0</ItemStart>
  <ItemCount>2</ItemCount>
</TiVoContainer>
<!-- Copyright (c) 2003-2005 TiVo Inc. All rights reserved.-->

I had given that computer the name of blackdell to distinguish it from our older, off-white Dell that is now running Ubuntu Linux, which is the machine I used to test these queries. Because I had shared the My Music and My Photos folders from my "Bob" account on the blackdell computer, the two containers listed by the URL above had titles of "Bob's Music on BLACKDELL" and "Bob's Photos on BLACKDELL." Below these titles you can see relative URLs that point to the contents of these containers. The following URL (split into two lines here) showed that the TivoPhotos container had containers named My Photos.lnk and My Pictures.lnk:

http://192.168.2.102:8080/TiVoConnect?Command=QueryContainer
&Container=%2FTivoPhotos

Those have their own URLs too, and using those and the same technique you can drill down to your actual listings of photos. These image files will have URLs that let you retrieve them; for example, the following URL retrieved I102_0248.JPG and displayed it on the Ubuntu machine's screen:

http://192.168.2.102:8080/TiVoConnect/TivoPhotos/IMy%20Pictures.lnk
/F326/F466/I102_0248.JPG

The API documention lists additional parameters to control the display of the image. For example, this URL displays the I102_0248.JPG image rotated 90 degrees:

http://192.168.2.102:8080/TiVoConnect/TivoPhotos/IMy%20Pictures.lnk
/F326/F466/I102_0248.JPG?Rotation=90

The ability to see directory listings and to retrieve JPEG and MP3 files from one home network machine to another is not in itself exciting. It's ironic that the documentation explaining how do to this with the TiVo Home Media Option API holds the key to querying the TiVo box itself, which is much more interesting. The fact that we can do this with a REST API makes it simple to play with, and makes it that much easier to script the integration of your personal TiVo data into the other metadata of your life.


Comment on this articleShare your experience in our forums.
(* You must be a
member of XML.com to use this feature.)
Comment on this Article


Titles Only Titles Only Newest First
  • How do you get the MAK?
    2007-02-27 19:31:10 BigGrizzlyBear [Reply]

    I looked in the TIVO menu for the MAK and it said that it is temporary unavailable. I use the three day free scheduling option but want to use the Home Media option with the TIVO so I can download stuff via the internet. I really want to use the new home media software that can download movies to my Video Ipod... Any help would be appreciated. BigGrizzlyBear

    • How do you get the MAK?
      2007-02-28 12:58:52 Bob DuCharme [Reply]

      There's a mailing list out there (I can't remember where right now, but it shouldn't be difficult to find) dedicated to TiVo http server hacking, so you'd probably get a quicker answer if you asked there.


      Bob

  • Updated the Windows scripts.
    2006-03-02 17:22:29 raianoat [Reply]

    Due to some problems I was having with the Windows scripts, I've updated them and posted them on my site:


    http://www.tivoblog.com/archives/2006/03/02/getting-the-tivo-roll-on-windows-to-work/

  • Is this possible from VB.Net without wget?
    2006-03-01 01:18:15 gpstefansson [Reply]

    Hi,
    I am doing a similar thing (not with Tivo) but I would like to accomplish this via .NET.


    Is it possible?




    • Is this possible from VB.Net without wget?
      2006-03-01 05:45:51 Bob DuCharme [Reply]

      The key thing that make this all possible is that the (TiVo brand) Digital Video Recorder has a built-in HTTP (i.e. web) server, accessible from a computer in your home when your TiVo is on your home network, that can deliver both HTML and XML. It delivers the XML using a REST interface, and I chose to use the wget tool to retrieve it, but anything that can do an HTTP GET can do so. I did it from both a Linux box and a Windows box; the platform you're retrieving from doesn't matter. (A Google search on 'vb.net "http get" ' gets over 59,000 hits.)


      So, if your DVR has an HTTP server, look at its documentation or do some web searches to find out how to get access to whatever data it has to offer.

  • logging in
    2006-02-16 11:27:43 robertfantini [Reply]

    Hello


    I tried to log in using https:// and the mac address.


    I could not get thru to my tivo.


    I tried using and not using the ':' in the mac address, and upper and lowercase for the letters.


    Any advise on getting thru?



    thanks
    Rob

    • logging in
      2006-02-26 18:58:05 freelancer [Reply]

      The article is incorrect - the MAC ID is not the Media Access Key and is not the password. To get the Media Access Key, go to Messages & Settings, Account & System Information, Media Access Key. Use that as the password and you're in.


      • logging in
        2006-02-26 19:14:54 Bob DuCharme [Reply]

        That's right, sorry. The similarity of the names confused me. The Media Access Key is what you use as the password, and is available on the screen described here.


        Bob


    • logging in
      2006-02-16 18:01:42 MegaZone [Reply]

      It isn't the MAC address, it is the TiVo MAK - Media Access Key.


      Login: tivo
      Passwork: [Your MAK]


    • logging in
      2006-02-16 11:37:02 Bob DuCharme [Reply]

      Are you sure it's on your home network, e.g. is it getting programming information from your wireless network? Can you ping it from one of the machines on the network?


      To get detailed help on certain problems, I found the TiVo Home Media Features & TiVoToGo forum at tivocommunity.com (
      http://www.tivocommunity.com/tivo-vb/forumdisplay.php?f=35) to be a great resource. People there walked me through several problems I had as I tried various ideas in my research for the article.


      Bob