# pytivo ported to python3



## itsayellow (Jan 15, 2020)

Over thanksgiving break I decided to port pytivo (wmcbrine's version) completely to python3. In the process I also tried to clean up some of the code.

If you're interested, here it is:
itsayellow/pytivo

It is installable as a python package via pip or pipx, which makes installation a little nicer and a little more portable.

For some help text, execute:
pytivo --help

I may not be super available for supporting end users, but the code is pretty solid and I've been using it for some months now without problem.

The main difference from the original pytivo is probably where it searches for pyTivo.conf. Here are the new locations:

/etc/pyTivo.conf
In your home directory: .config/pytivo/pyTivo.conf
In the directory you started pytivo from: pyTivo.conf
You can also specify the full path to your desired pyTivo.conf using the -c option.
For developers, it may be of note that the entire code is also statically typed with python type hints and can be verified using mypy.

Since python 2 is EOL this year, hopefully this is also useful going forward for other developers.


----------



## Allanon (Nov 2, 2005)

I can finally remove python 2 from my computer, this was the only thing holding me back!


----------



## Allanon (Nov 2, 2005)

Am I missing something, where is the pyTivo.py file?


----------



## itsayellow (Jan 15, 2020)

Allanon said:


> Am I missing something, where is the pyTivo.py file?


That's another change from the old pytivo I guess.

The best way of running this is to install this using pipx. Once you do that, you should have a command on your path called 'pytivo' executable from anywhere.

Installation example if you downloaded pytivo to directory <Some_Directory>/pytivo (replace <Some_Directory> with whatever directory is the parent of your pytivo directory.)

python -m pip install --user pipx
pipx install <Some_Directory>/pytivo
pipx will install pytivo (or pytivo.exe on Windows) in your home directory to: .local/bin/ . If this is in your PATH, then pytivo will be executable anywhere. You can also run it explicitly from that path.

The more technical answer is, there are a number of python packages that need to be installed to make this new pytivo work. The installation method above handles this automatically. If you know what you're doing and install all the python packages needed yourself, then to run pytivo you can also execute:
python src/pytivo/main.py​


----------



## itsayellow (Jan 15, 2020)

I just updated the install directions on the main page for my fork of pytivo:
itsayellow/pytivo

I tried to find the right balance of enough information but not too much! But that balance is a little tricky. Hopefully those instructions are complete enough without being overwhelming.


----------



## Allanon (Nov 2, 2005)

Got it working, thanks.


----------



## eherberg (Feb 17, 2011)

Forum user @mlippert also did this a couple of years ago, I think (ported to python 3). Just an FYI in case the 2 of you want to compare notes.


----------



## itsayellow (Jan 15, 2020)

Thanks for the note, that's good to know! I looked, but I couldn't find any python3 pytivo ports on my own...might have saved me some work


----------



## mlippert (Apr 3, 2010)

itsayellow said:


> Thanks for the note, that's good to know! I looked, but I couldn't find any python3 pytivo ports on my own...might have saved me some work


It sounds like we focused on different things for our ports, and there are things you've done that I'd definitely want, but I don't have the bandwidth now to look at merging. I've never even heard of pipx. 
You can find my port at mlippert/pytivo

[edit] for instance I added some config functionality to allow defining how you want shows and movie files named, and I added a .syncerr.yaml file to show where the errors occurred when doing ts downloads, based on @Dan203's changes to wmcbrine's base code.


----------



## itsayellow (Jan 15, 2020)

@mlippert , I also don't have a ton of bandwidth, but was happy to see another python3 port.

I will say I was pleasantly surprised how much benefit using type hints gave me. Not only did it make porting much faster in the end, but I believe I may have found some bugs that had been hiding in pytivo for a while. It certainly eased tracking down all the str/bytes bugs that popped up in the transition from python2 to python3.


----------



## mlippert (Apr 3, 2010)

@itsayellow Adding type hints is something I definitely wanted to do, but I didn't know nearly enough when I started about how to format them and actually lint them, so I left that for later. I did restructure many parts of the code, and I've been using it ever since I did this. I run it on linux though, and I didn't go the extra step to make it easier for others to install that it sounds like you did.
I know it runs on linux (if you get the required pre-reqs installed, and that's not hard, I use a virtual env and the requirements.txt), and I think I got it running on Windows a long time ago. I have no idea how/if it runs on a Mac.

If I get some time in the future I'll check out your port and if that happens I'm sure I'll have questions so you may hear from me!


----------



## Dan203 (Apr 17, 2000)

So is there any real advantage to using 3 vs 2? I'm not really a python developer. I faked my way through the additions I made to my fork by a lot of goggling and trial and error. Would there be any advantages to using 3 in my pyTivo Desktop app?


----------



## itsayellow (Jan 15, 2020)

Dan203 said:


> So is there any real advantage to using 3 vs 2? I'm not really a python developer. I faked my way through the additions I made to my fork by a lot of goggling and trial and error. Would there be any advantages to using 3 in my pyTivo Desktop app?


Well, I think the main thing is that Python 2 will not be supported anymore (EOL). "...January 1, 2020, will be the day that we sunset Python 2. That means that we will not improve it anymore after that day, even if someone finds a security problem in it."
Sunsetting Python 2

Going forward, there won't be many libraries that still support python 2.

Other than that, I find python 3 much more pleasant to program in, it has a lot of nice features and syntax than python 2. Python 2.7 was released in 2010, a lot of nice stuff has happened since then in Python 3.


----------



## mlippert (Apr 3, 2010)

Dan203 said:


> So is there any real advantage to using 3 vs 2? I'm not really a python developer. I faked my way through the additions I made to my fork by a lot of goggling and trial and error. Would there be any advantages to using 3 in my pyTivo Desktop app?


So basically what @itsayellow said.

If you really were going to continue supporting/developing your pytivo desktop, then yes you probably should use python 3 and I would suggest you at least look at my fork because I've got your changes through 1.6.7 incorporated. But the effort involved isn't small, and what you have is working just fine.


----------



## Lurker1 (Jun 4, 2004)

Is @wmcbrine pyTivo still "generally considered the stable mainline development branch" as it states in the pyTivo Wiki? Is anyone considering to update this to a Python 3 mainline, or at least to document all these other forks in the Wiki so we might know that they exist and which one to choose? I'm wondering if the "New users are recommended to start here" section is still good advice to follow?

Current Releases - pyTivo - Wiki


----------



## wmcbrine (Aug 2, 2003)

pyTivo is very nearly dead. That particularly describes my involvement with it, but it's true in the general case as well. TE4 breaks the core of pyTivo, PC to TiVo transfers. The Edge, IIRC, breaks TiVo to PC. And it's probably the last TIVo DVR anyway. The pyTivo forum is broken since KRKeegan abandoned it, I dunno how to fix it, and I'm not particularly motivated to figure it out. And then there's "pyTivo Desktop"...

The one thing that I really do feel is unfinished, is 4K. Since re-subscribing to Fios, I finally have some real 4K recordings to work with, and I'd like to get that going for the PC to TiVo side, if I can. I'll look into the Python 3 ports at that time. And then... that's probably it.

I do still use it, now and then. I probably will for as long as my TiVos keep working. But that time no longer seems unlimited.


----------



## HerronScott (Jan 1, 2002)

wmcbrine said:


> The Edge, IIRC, breaks TiVo to PC.


This was reported to have been fixed with the last update.

Scott


----------



## Dan203 (Apr 17, 2000)

wmcbrine said:


> The one thing that I really do feel is unfinished, is 4K. Since re-subscribing to Fios, I finally have some real 4K recordings to work with, and I'd like to get that going for the PC to TiVo side, if I can. I'll look into the Python 3 ports at that time. And then... that's probably it.


Does 4K download?


----------



## wmcbrine (Aug 2, 2003)

Dan203 said:


> Does 4K download?


Yes, no problem. And it decrypts.


----------



## mickrussom (Dec 21, 2007)

itsayellow said:


> Over thanksgiving break I decided to port pytivo (wmcbrine's version) completely to python3.


noticed this was recently upgraded to 0.5.0 - thanks for maintaining this code.


----------



## UID0 (Mar 5, 2021)

I would like to say a BIG THANK YOU, to WMCBRINE and to ITSAYELLOW, and all the other people that have made pytivo a thing over the years.
I have been using it for many years, and it is still going strong for me with a Tivo bolt.
I started with an original Tivo, and have had a couple between then and now.
It will be a sad day when the Tivo and PyTivo bite the dust.

I have tried, and am disgusted by AppleTV, FireTV, ROKU...
The user interface is horrible...
To be honest I liked the old classic TIVO interface and the webTiVO (I think that might be what it was called)
I hacked my first Tivo, installed an internal network card instead of using the modem, and modified the hard drive to load a WEB interface on it.
I miss that... I could manage everything from my PC without using the remote!


----------



## ojfl (Feb 15, 2016)

I like that this has been ported to Python3. I am new to pyTiVo but I was just wondering if there is a way for the program to automatically download shows without having to go to the web interface. I tried finding it on the web but could not. I know TiVo may be on its last legs but we are still using both of our Premiere.


----------



## Dan203 (Apr 17, 2000)

No. It was something I started working on at one point, but I got side tracked with other stuff and never picked it back up. And with TiVos current trajectory I don’t think I'll ever bother.


----------



## Wil (Sep 27, 2002)

UID0 said:


> I liked the old classic TIVO interface and the webTiVO (I think that might be what it was called)


TivoWebPlus. Still runs fine on my Tivo HDs.

I also still sometimes use a variation of mfs_ftp.tcl instead of kmttg or whatever to get my shows off the HD. I do that because sometimes I read about all the errors people are getting on downloads and I think the old method is cleaner. But then after awhile I go back to kmttg because I've really never seen those errors anyway.

The days are numbered though, my friend.


----------



## ojfl (Feb 15, 2016)

Dan203 said:


> No. It was something I started working on at one point, but I got side tracked with other stuff and never picked it back up. And with TiVos current trajectory I don't think I'll ever bother.


Thank you. I am at the edge of my seat just waiting for TiVo to pull the plug on the platform. Maybe in two years, if that long.


----------

