# Installing PyTiVo on Mac for New User



## Tagno (Aug 5, 2019)

I have experience with Python, but hardly ever have had to use anything more complex than pip to install libraries on my Mac. I now have a TiVo Bolt OTA and am thinking about a few things I can probably do with PyTiVo (according to what I've heard).

How difficult or tricky is installing and using PyTiVo on a Mac?

(At this point I have a lot going on and not much time to deal with things, but I'd like to write a short program that will work like rsync for copying TiVo recordings to my own server, so I can stream them to other devices with Plex instead of buying a TiVo Mini VOX. I don't mind doing leg work on something like this, but I'm just trying to assess whether this is something I can do now or if I should just spend the money on a Mini VOX to use for the next 9-12 months, when I'll have time to dig in deeper.)

--------
Sorry - on first post I meant to include I tried installing PyTiVo with pip and got this:

Downloading/unpacking pytivo
Downloading pytivo-0.0.2.tar.gz
Running setup.py (path:/private/tmp/pip_build_root/pytivo/setup.py) egg_info for package pytivo
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/private/tmp/pip_build_root/pytivo/setup.py", line 5, in <module>
with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f:
TypeError: 'encoding' is an invalid keyword argument for this function
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

File "<string>", line 17, in <module>

File "/private/tmp/pip_build_root/pytivo/setup.py", line 5, in <module>

with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f:

TypeError: 'encoding' is an invalid keyword argument for this function

----------------------------------------
Cleaning up...


----------



## Allanon (Nov 2, 2005)

You might want to try pyTivo Desktop. It's pyTivo but with a desktop GUI for easier use.


----------



## Mikeguy (Jul 28, 2005)

Allanon said:


> You might want to try pyTivo Desktop. It's pyTivo but with a desktop GUI for easier use.


^ This. With pyTivo Desktop, you're up and running in minutes.

pyTivo Desktop discussion thread here: Easier to use pyTivo


----------



## Tagno (Aug 5, 2019)

Thanks! I’ll try that.

I know I can look some of this up, right now, as I think you saw, I just want a quick solution. Later I want to explore the library and write a few programs that use it. But for most of the next year, I just need a quick solution.


----------



## Mikeguy (Jul 28, 2005)

Tagno said:


> Thanks! I'll try that.
> 
> I know I can look some of this up, right now, as I think you saw, I just want a quick solution. Later I want to explore the library and write a few programs that use it. But for most of the next year, I just need a quick solution.


pyTiVo Desktop--minutes, literally (and single digit minutes).


----------



## Tagno (Aug 5, 2019)

The hardest part was copying my MAK - and that was a nightmare. I found a bug in the Epson Home Cinema 1450 Home Theater Projector. Somehow, when TiVo goes from standby to active, and the Epson projector is being turned on, if it's not done in the right sequence, the TiVo Bolt gets the wrong display info and tries to display things in the wrong resolution - AND it makes almost everything green!

I'll have to report this. I sent back my first Bolt because of this, but now that I see it happening on my BD player, I know it's the TV, not TiVo. (Although I suspect it's TiVo that sets the wrong mode, though.)

Once I got that figured out, it was no problem and it's copying over files now.

When I get time, I'll have to read up on the API. I'll write something like rsync, so I can leave it running in the background and automatically sync recordings periodically throughout the day. That way the version on the HD is up to date with the TiVo.


----------



## Dan203 (Apr 17, 2000)

FYI you can get your MAK by logging in to your account on TiVo.com


----------



## Tagno (Aug 5, 2019)

Am I right that installing PyTiVo Desktop also installs PyTiVo, so I don't have to worry about that? I can just read up on the API for it when I have time?

I noticed when PyTiVo Desktop lists my recordings on my TiVo, the files have different icons by them - a blue circle, yellow circle, yellow with a exclamation point, and red. I've looked over the PiTiVo's info on GitHub, but I can't find anything that documents what these icons mean.


----------



## Mikeguy (Jul 28, 2005)

Tagno said:


> Am I right that installing PyTiVo Desktop also installs PyTiVo, so I don't have to worry about that? I can just read up on the API for it when I have time?


Yep--a reason it's so nice.  (And no reading-up is needed.)


> I noticed when PyTiVo Desktop lists my recordings on my TiVo, the files have different icons by them - a blue circle, yellow circle, yellow with a exclamation point, and red. I've looked over the PiTiVo's info on GitHub, but I can't find anything that documents what these icons mean.


The TiVo "when this show may go away" indicators.


----------



## Dan203 (Apr 17, 2000)

Tagno said:


> Am I right that installing PyTiVo Desktop also installs PyTiVo, so I don't have to worry about that? I can just read up on the API for it when I have time?


It's 100% self contained.



Tagno said:


> I noticed when PyTiVo Desktop lists my recordings on my TiVo, the files have different icons by them - a blue circle, yellow circle, yellow with a exclamation point, and red. I've looked over the PiTiVo's info on GitHub, but I can't find anything that documents what these icons mean.


They're the same icons shown on the TiVo itself for the recordings. I mainly did it because I wanted to show an icon for Suggestions and it looked weird when the other recordings didn't have an icon at all. So just to fill the space I put the same icons that TiVo uses in their UI.


----------



## Dan203 (Apr 17, 2000)

P.S. I am the developer of pyTivo Desktop. So if you have any trouble you can contact me directly and I can help you out.


----------



## Tagno (Aug 5, 2019)

Thank you!



Dan203 said:


> It's 100% self contained.


So it's all in one package, and installing it did not automatically also install PyTiVo on my Mac?



> They're the same icons shown on the TiVo itself for the recordings. I mainly did it because I wanted to show an icon for Suggestions and it looked weird when the other recordings didn't have an icon at all. So just to fill the space I put the same icons that TiVo uses in their UI.


I just set my TiVo up on Saturday (or maybe Friday night) and haven't had time to actually sit down and enjoy it - so I had not seen the icons yet. But that also makes it puzzling why something might be marked as close to deletion when everything was recorded this weekend.

It looks like pyTiVo Desktop is mainly for a simple way to copy files over to a hard drive. Is there a way to copy just the new files over? Or to "refresh" by deleting any recordings on the hard drive that have been deleted on TiVo and copy only new files/


----------



## Dan203 (Apr 17, 2000)

Tagno said:


> So it's all in one package, and installing it did not automatically also install PyTiVo on my Mac?


It does not install python. It uses a program called pyInstaller to package the PyTivo code and the python needed to run it into a single executable. When you run that executable it extracts everything to a temp directory so that it can run. When you exit the app it cleans up the temp directory so it can't be used for anything else.



Tagno said:


> It looks like pyTiVo Desktop is mainly for a simple way to copy files over to a hard drive. Is there a way to copy just the new files over? Or to "refresh" by deleting any recordings on the hard drive that have been deleted on TiVo and copy only new files/


No it doesn't have any advanced functionality like that. Do those sorts of things on a TiVo requires an advanced API that is not exposed in PyTivo. If you want functionality like that you'll have to use kmttg.


----------



## Tagno (Aug 5, 2019)

Dan203 said:


> It does not install python. It uses a program called pyInstaller to package the PyTivo code and the python needed to run it into a single executable. When you run that executable it extracts everything to a temp directory so that it can run. When you exit the app it cleans up the temp directory so it can't be used for anything else.


So if I want to use the pyTiVo library, then I have to install that separately?



> No it doesn't have any advanced functionality like that. Do those sorts of things on a TiVo requires an advanced API that is not exposed in PyTivo. If you want functionality like that you'll have to use kmttg.


Okay. I'm a bit confused. I thought PyTiVo Desktop was basically a nice GUI to use for basic copying with the PyTiVo library, and that the library is still something I can install on its own.


----------



## Dan203 (Apr 17, 2000)

Tagno said:


> So if I want to use the pyTiVo library, then I have to install that separately?


When the little tray app is running pyTivo is running. You can still access it via the UI just like the various pyTivo guides show. In fact all the Desktop app is is a fancy webpage using the pyTivo API, with some minor additions from me. So if you want to use the web UI, or even send http requests directly, you can.



Tagno said:


> Okay. I'm a bit confused. I thought PyTiVo Desktop was basically a nice GUI to use for basic copying with the PyTiVo library, and that the library is still something I can install on its own.


The purpose of pyTivo Desktop was to make pyTivo easier to install and use. The first iteration was just the installer and a few simple dialogs for changing the settings and setting up shares. The fancy Desktop UI came along when I wanted to learn Angular and needed something to apply it to.


----------



## Tagno (Aug 5, 2019)

Dan203 said:


> The purpose of pyTivo Desktop was to make pyTivo easier to install and use. The first iteration was just the installer and a few simple dialogs for changing the settings and setting up shares. The fancy Desktop UI came along when I wanted to learn Angular and needed something to apply it to.


I'm thinking I must have misunderstood things. I thought pyTiVo would be a library with an API to access TiVo recording and transfer them. So basically it's a GUI app, but not as slick and easy to use as PyTiVo Desktop?

So what should I download and install if I want a library that lets me:
- Read what recordings are currently on my TiVo
- Get metadata from those recordings, including full titles
- Copy those recordings to my hard drive (and, if necessary, transcode them) in a form that works with Plex so I can stream them with Roku or other streaming boxes?


----------



## Dan203 (Apr 17, 2000)

Tagno said:


> I'm thinking I must have misunderstood things. I thought pyTiVo would be a library with an API to access TiVo recording and transfer them. So basically it's a GUI app, but not as slick and easy to use as PyTiVo Desktop?
> 
> So what should I download and install if I want a library that lets me:
> - Read what recordings are currently on my TiVo
> ...


There are APIs there if you really want to use them. They're not really documented though. They're based entirely on the TiVo HTPP API used for TiVo Desktop, which you might be able to find documentation for somewhere if you search.

For the functionality you're requesting you should try kmttg. It uses a newer API called mind/RPC that has access to more features of the TiVo.


----------



## Tagno (Aug 5, 2019)

Dan203 said:


> There are APIs there if you really want to use them. They're not really documented though. They're based entirely on the TiVo HTPP API used for TiVo Desktop, which you might be able to find documentation for somewhere if you search.


Okay. Thanks. I wasn't clear if everything was using the TiVo API or if there were libraries written as wrappers around whatever TiVo had.



> For the functionality you're requesting you should try kmttg. It uses a newer API called mind/RPC that has access to more features of the TiVo.


Got it. (I was hoping for something in Python, not Java, but I can handle Java. Oh, well.)


----------



## Dan203 (Apr 17, 2000)

All of the extra API functionality I added to support the Desktop UI still uses the HTPP request format. 

If you're a software developer there is a guy who's reverse engineered the TiVo mind/RPC API in python, if that's better than java for you. However there is still a bit of a process getting it working as that API requires use of a certificate. The developer of kmttg has been hacking the certificate from the iOS app using a jail broken iPhone. But apparently it's getting harder and harder to do and it expires every couple years, so there could be a day when that just stops working.

I tried contacting TiVo and asking for an official certificate, which they offered at one time via their developer program, but the person that set up the developer program no longer works there and no one else can figure out who, if anyone, is capable of creating these certificates. That's what put me off from adding it to pyTivo. I didn’t want to put work into an API that may stop working as soon as the certificate expired and it was no longer possible to hack it out of the app.


----------



## Tagno (Aug 5, 2019)

So kmttg can break at any time due to certificate issues. I did see one page, somewhere, on the TiVo website, where I could sign up as a developer, but I was hoping not to have to pay fees to access the API.

From what you're saying, it sounds like you need a certificate to do that.

It sounds like, basically, unless TiVo actually comes out with the apps they promised in January, accessing the recordings on the device is not easy. (And one of those apps was promised for the 2nd quarter and hasn't showed up and the other for the 3rd quarter.)

On pyTiVo Desktop, since you're using HTTP, is that easy to use and is that the standard TiVo API? And are you accessing it without a certificate?


----------



## Dan203 (Apr 17, 2000)

Tagno said:


> So kmttg can break at any time due to certificate issues. I did see one page, somewhere, on the TiVo website, where I could sign up as a developer, but I was hoping not to have to pay fees to access the API.
> 
> From what you're saying, it sounds like you need a certificate to do that.
> 
> ...


The certificate is good for another year or so, but no telling if they'll be able to get a new one when it expires.

The developer program is dead. That's what I tried to use to get a certificate and no one could figure out how to help me. (I even tried personal contacts inside TiVo and no one could figure it out)

Yes. It was published by TiVo at one time. It uses your MAK for authorization, not a certificate, so it should work as long as TiVo doesn't disable the HTTP server on the TiVo itself. (which is possible, but hasn't happened yet)


----------



## Tagno (Aug 5, 2019)

Dan203 said:


> The certificate is good for another year or so, but no telling if they'll be able to get a new one when it expires.
> 
> The developer program is dead. That's what I tried to use to get a certificate and no one could figure out how to help me. (I even tried personal contacts inside TiVo and no one could figure it out)
> 
> Yes. It was published by TiVo at one time. It uses your MAK for authorization, not a certificate, so it should work as long as TiVo doesn't disable the HTTP server on the TiVo itself. (which is possible, but hasn't happened yet)


So the best bet is HTTP and hope they don't disable it. I went to my TiVo's IP address with an HTTPS connection. I see the full listing of shows. I can use that to compare to what's on my hard drive and easily keep them in sync. Parsing the HTML isn't hard. (And I bet they haven't updated that HTML in years, right?)

I see there are two files for each recording and they're downloadable, a -TS file and a -PS file. The .tivo file extension is added to the filenames when I download. When I play the PS file in VLC, it's bad video, but behaves like when I play a video downloaded from pyTiVo Desktop. So do the .tivo files still need to be converted to be used? Or can a program like Plex use them as-is?


----------



## Dan203 (Apr 17, 2000)

The .tivo files are encrypted. pyTiVo desktop includes a program that can decrypt them called tivo-libre. If you want to play them in VLC or convert them to another format, like for Plex, you'll need to decrypt them.

If you want to do automated comparison of shows pyTivo can supply the list as json data or XML, which would be easier to parse than the HTML page TiVo shows. The TiVo page also has issues with pagination. When they added One Passes, which are essentially shows that might not actually have and recordings, it confused that page and makes it nearly impossible to get past page 1 if you have any streaming only 1Ps.


----------



## Tagno (Aug 5, 2019)

Okay, here's what I've got for the HTTP interface. I don't know how much more there is, but this is from multiple pages, including a few on this forum. (I'm putting this here for my future use, if I forget, and for completeness for anyone following this thread.

Use "tivo" for the user name and your MAK for the password. Always use https:// instead of just http://

The one thing I have not yet figured out is how to include your username and MAK in the URL as parameters.

Note that some lines have been split up for formatting. There are no spaces or return characters in the URLS.

You can get a list of your programs, in HTML, from this URL:


> https://<your tivo IP address>/nowplaying/index.html


You can get the same, in XML, with this:


> https://<your tivo IP address>/TiVoConnect?Command=QueryContainer&Container=/NowPlaying


The problem is that only gives a limited listing of your shows, so, to get a full listing, use this for the first page of XML listings. I was using a count of 10 for testing purposes (to make it easy to count and track show titles). You can use other numbers. I think I had trouble with getting more than 16 items at a time.


> https://<your tivo IP address>/TiVoConnect?Command=QueryContainer&Container=/NowPlaying&ItemCount=10


And use this for the next. Just keep incrementing the AnchorOffset for each page as you step through.


> https://<your tivo IP address>/TiVoConnect?Command=QueryContainer&Container=/NowPlaying&ItemCount=10&AnchorOffset=10


If you want to go into folders, add "&Recurse=Yes" and, of course, for the 2nd and following pages, add the "&AnchorOffset=10" (Or whatever you need the offset to be.)


> https://<your tivo IP address>TiVoConnect?Command=QueryContainer&Container=/NowPlaying&ItemCount=10&Recurse=Yes


Then:


> https://<your tivo IP address>/TiVoConnect?Command=QueryContainer&Container=/NowPlaying&ItemCount=10&AnchorOffset=10&Recurse=Yes


----------



## Dan203 (Apr 17, 2000)

It's been a while since I wrote this, so my memory is a bit fuzzy, but that looks right. If you really want to break it down the source for pyTivo is available on github.

Dan203/pytivo


----------



## Tagno (Aug 5, 2019)

I'm combing through the Python code and have been looking at the Java code for kmttg. At this point, I'm rather frustrated because I'm not even clear just what routine, in what library, I call just to make the initial call when connecting to the TiVo. That's an issue because, at this point, I'm not sure how to handle the login credentials. (I've tried using them as parameters on the URL, but I can't get that to work.) I know I can do this with a one line command using wget, but that isn't transparent enough to show me just what is happening in the login process.


----------



## Dan203 (Apr 17, 2000)

If you're using pyTivo you don’t have to do the authentication manually. It does it for you.

Think of pyTivo as a sort of proxy server. You send http commands to it, and it talks to the TiVo.

The commands you can send to pyTivo use the same URL syntax as the TiVo, but they are actually unique to pyTivo itself. The easiest way to see how it works is just to play with the web UI in a browser. That will put the URLs right in the browser address bar.

Another option is to run pyTivo Desktop in a browser and then use the developer console to look at the URLs it sends. You can do this by going to....

localhost:9032/Desktop

That will load the same Desktop UI you get in the app right into the browser. (it's all just Angular) You can then click the buttons and look at the network tab in the Chrome developer console and see the calls it makes.


----------



## Tagno (Aug 5, 2019)

I'll try with PTD in my browser. I've having trouble getting PyTiVo to install on my Mac. I got PTD to install, but, from what you said, that's a frozen file binary. I had to try to wrestle with PyTiVo.
------------------------------------------
Okay, used the PyTiVo that came with PTD - I hadn't looked into the folder in /Applications. So I am able to access through localhost:9032. I'm learning the URLs by playing with it. They're definitely different. I was hoping to just step through the list of shows in XML format, but I don't see how to get that.

Does PTD install FFMpeg along with PyTiVo?


----------



## Dan203 (Apr 17, 2000)

Look at the calls PTD makes. Those all return json data which is very easy to use in many languages. If you don’t know json it's very easy to learn. It's basically a collection of name value pairs where the value can be one of four types.... string, int, array or object. Objects are basically just nested collections of more name value pairs. So it's simple to understand.

The json retutrned by pyTivo is minimized, but if you copy and paste it into an IDE or text editor that understands json it's structure will be a lot more clear.

FYI: All of the mind/rpc functions that kmttg, and TiVo's own apps, use also return json. XML is only used for the very old APIs like the one used for TiVoToGo.


----------



## Tagno (Aug 5, 2019)

Dan203 said:


> Look at the calls PTD makes. Those all return json data which is very easy to use in many languages. If you don't know json it's very easy to learn. It's basically a collection of name value pairs where the value can be one of four types.... string, int, array or object. Objects are basically just nested collections of more name value pairs. So it's simple to understand.
> 
> The json retutrned by pyTivo is minimized, but if you copy and paste it into an IDE or text editor that understands json it's structure will be a lot more clear.
> 
> FYI: All of the mind/rpc functions that kmttg, and TiVo's own apps, use also return json. XML is only used for the very old APIs like the one used for TiVoToGo.


So if I just go to the normal links, like I listed above, for the XML, I'm using an older interface and TiVo now uses json formatted data instead, so that's probably the best to use at this point? (Since TiVo is using it, it's less likely to be deprecated soon.)

I haven't been programming for a while and really didn't want to dive in for a while, since I'm dealing with a lot going on right now, but I jumped in anyway. I thought, at first, that pyTiVo would be a library, so it took me a while to grasp that it's more a service and to send it URLs directly. So I'm working on dealing with that.

You mentioned the certificate issue for kmttg. There's nothing similar for pyTiVo, is there?


----------



## Dan203 (Apr 17, 2000)

pyTivo uses the old API for everything. When I was doing Desktop I added code to convert to json because it’s easier to parse in Angular. But it’s also easier to parse in other languages so it might be easier to deal with.


----------

