# Downloading shows using wget



## rlyacht (Mar 22, 2008)

I would like to download shows on my home network using wget. I know about the browser interface, which I can use, but I want something I can automate with a perl script. I've tried everything I can think of, but am obviosly getting the parameters wrong somehow.

I am able to get a listing of what's on the Tivo like this:

wget --no-check-certificate --http-user=tivo --http-password=XXXXX -O /tmp/tivoroll.xml "https://192.168.0.102/TiVoConnect?Command=QueryContainer&Container=%2FNowPlaying&Recurse=No"

But I can't download shows. Here's an example (XXXXX... is my MAK). Note that I am using wget 1.10.2. I've tried variants, like putting tivo:$MAK in the URL. Help!!!!!

[email protected] ~/src/tivo $ wget --verbose --no-check-certificate --http-user=tivo --http-password=XXXXXXXXXX "https://192.168.0.102/download/Futurama.TiVo?Container=%2FNowPlaying&id=2119921"
--13:58:17-- https://192.168.0.102/download/Futurama.TiVo?Container=/NowPlaying&id=2119921
=> `Futurama.TiVo?Container=%2FNowPlaying&id=2119921'
Connecting to 192.168.0.102:443... connected.
WARNING: Certificate verification error for 192.168.0.102: self signed certificate
WARNING: certificate common name `XXXXXXXXXXXXXXXX' doesn't match requested host name `192.168.0.102'.
HTTP request sent, awaiting response... 401 Digest Authorization Required
Reusing existing connection to 192.168.0.102:443.
HTTP request sent, awaiting response... 401 Authorization Failed (invalid response)
Authorization failed.


----------



## gonzotek (Sep 24, 2004)

I banged my head on this for quite a while when the feature was first released.  I feel your pain.

The listing is done on the secure connection(http*s*://), but the files themselves are only available on the standard web connection(http://). Try making the request over http. It should work. Also, you may want to edit your post, altering the line ending "...doesn't match requested host name `192.168.0.102'." It has your TSN in it, and that isn't supposed to be shared.


----------



## rlyacht (Mar 22, 2008)

Thanks, I think I edited out the right thing from my post. I'll give it a try over http, and post my results.


----------



## rlyacht (Mar 22, 2008)

Over http I get a 400 error, i.e. it thinks my url is no good. I tried it both with including the id and password in the url as below, and also passing them as parameters to wget.

[email protected] ~/src/tivo $ wget --verbose "http://tivo:[email protected]:80/download/Futurama.TiVo?Container=%2FNowPlaying&id=2119922"
--20:01:38-- http://tivo:*password*@192.168.0.102/download/Futurama.TiVo?Container=/NowPlaying&id=2119922
=> `Futurama.TiVo?Container=%2FNowPlaying&id=2119922'
Connecting to 192.168.0.102:80... connected.
HTTP request sent, awaiting response... 401 Digest Authorization Required
Reusing existing connection to 192.168.0.102:80.
HTTP request sent, awaiting response... 400 Bad Request
20:01:39 ERROR 400: Bad Request.


----------



## moyekj (Jan 24, 2006)

You can use "curl" instead of "wget". That's what I use in my kmttg Perl program to both retrieve NowPlayingList and download programs and it works great:

```
curl --anyauth --user tivo:MAK --insecure --cookie-jar cookies --url "http://192.168.0.102/download/Futurama.TiVo?Container=&#37;2FNowPlaying&id=2119922" --output outputFileName.TiVo
```
 You should check your url with a browser to make sure it's correct.


----------



## rlyacht (Mar 22, 2008)

Thanks! I've never used curl - I will check it out.

Also, I managed to download something finally, using the WWW::Mechanize perl module. Oddly, LWP didn't work!


----------



## McMike (Oct 30, 2007)

Here's how to do it with wget:

1) Download the index page, and save the cookie you're given:

wget --save-cookies cookies.txt --no-check-certificate --http-user=tivo --http-password=MAK 'https://tivo'

2) Now get whatever it was you wanted, using the cookie saved from step #1:

wget --load-cookies cookies.txt --no-check-certificate --http-user=tivo --http-password=MAK 'http://tivo/download/My%20Show.TiVo?Container=%2FNowPlaying&id=477880'

With both curl and wget, I find that unless you already have the sid cookie stashed in your cookie file, it's a two-step process.

On edit: Eh, don't use wget. From an unmentionable reference:


> Message for WGet users
> 
> Note: Due to improper chunked-encoding handling in wget and/or the tivo web server, using wget to download .TiVo files will result in them being corrupt and they will not decode. Please use curl, or if you are a wget developer, please fix wget.


----------

