# HOWTO download TTG using "curl"



## Mr Markus (Dec 6, 2005)

This provides information on how you can use `curl` from the command prompt to download TivoToGo. I'm working on a simple Perl & curl script to get the XML feed and queue up downloads. Why? Because I can (& I have only 1 40hr TiVo). Besides, I don't like doing routine things, I prefer non-gui automation, and I like very thin apps.

This information is also applicable to those working with BSD/Linux/Unix, Macintoshes (Mac OS X), Windows with Cygwin (or Services For Unix), or scripting languages like Perl/PHP/Python/Shell etc. I've seen some PHP posts around the internet of people trying to set the right `curl` options for it to work. This should help.

First, you need to be using a version of curl that supports SSL. Issue the command `curl --version` to see if SSL has been compiled in.

Here's an example of a successful TTG curl request:

curl --digest -k -u tivo:YourTivoMAK -c cookies.txt -o Brainiac.tivo "http://192.168.1.40/download/Brainiac.TiVo?Container=%2FNowPlaying&id=448614"

Let's break down the options so you know what's going on.

--digest Use HTTP Digest Authentication (H)

The TiVo built-in web server is using Digest Authentication so this must be used.

-k/--insecure Allow connections to SSL sites without certs (H)

Since the TiVo built-in web server has a self-signed certificate for the secure connections, it's considered "insecure" -- as in non-registered with Internet Security companies like Verisign.

-u/--user <user[assword]> Set server user and password

This is self evident. Your password is your 10 digit MAK. FYI ... There could be a slim possibility your 4 digit parental PIN may need to be tacked on it. I've not had a problem with just the MAK and we use a parental PIN on our TiVo. Some community technical articles mentioned this possibility somewhere before.

-c/--cookie-jar <file> Write cookies to this file after operation (H)

The built-in web server keeps track of the download using a Session ID. This means you have use cookies. `curl` will need to store this information for the current transfer only. However, there's a side effect of the cookie file being written to disk. So make sure you have the file created where you have read/write permissions.

-o/--output <file> Write output to <file> instead of stdout

Obviously, you are wanting to save your TTG files. Give it a name. Beware ... if the name already exists, it will be over-written.

And lastly, the URL.

It's best to use double quotes as most Unix like environments will think you're trying to send this process to the background. I happen to use the local static address of 192.168.1.40 - you should place yours there. In fact, if you pull down the Now Playing XML feed, you'll see this long preformed URL with every listed program. Here's another tip ... the Episode name in the URL is used for sending back to the browsers for the saved name of the download file. You could use any URIencoded text here or just "tv.tivo". It's everything after the "?" that's important. Curl's -o option is what the file will be saved as.

Now what can you do with this?

If you're somewhat adventurous using Windows and the TiVo Desktop, you can install a minimal Cygwin ( http://cygwin.com ) with `curl`, write and place a script in a scheduler to download files automatically into your "My TiVo Recordings" folder. (If you scripting challenged, I recommend http://galleon.tv )

Myself, I'll be posting my Perl script once I'm finished with it. It downloads the current listings in XML, identifies those available downloads I want that I've not downloaded yet, and downloads them.

I'm currently writing it to use with my Linksys NSLU2 network storage device ( http://nslu2-linux.org ) I currently have byRequest running on it to serve up Pictures and MP3s. I'm hoping to work up a daemon/server & script (or enhance byRequest) to advertise back to the TiVo all available TTG files. We'll see. The download Perl script is so easy I can write it in my sleep. I've new baby girl about to arrive so the beacon advertisement may have to wait until later this summer. 

Later, Markus.


----------



## bmgoodman (Dec 20, 2000)

Did you ever make any progress in using your NSLU2 with TivoToGo? Please let us know! Thanks.


----------

