[QPKG] pyTivo

This is the best place for community developers to publish their genius work. Your Apps enrich the QNAP Turbo NAS.
kisonay
Getting the hang of things
Posts: 82
Joined: Sat Dec 22, 2012 3:45 am
Location: New York, USA

[QPKG] pyTivo

Post by kisonay »

[Description]
pyTivo is both an HMO and GoBack server. Similar to TiVo Desktop, pyTivo loads many standard video compression codecs and outputs mpeg2 video to the TiVo. However, pyTivo is able to load many more file types than TiVo Desktop. pyTivo is in no way affiliated with TiVo, Inc.

[Disclaimer]
This package is provided as is, it's free and it doesn't include any kind of support, use it at your own risk. I am relatively new at this and just wanted to package up my install so that I can easily reinstall if needed and figured I would share with the community. This package only copies the files required to run pyTivo. It does not install any missing dependencies so please make sure they are all installed beforehand. It is confirmed working on my TS-269L (x86, firmware v3.8.1). Transcoding may not be feasible on some models (ARM) so you will want to make sure that you have your files in mpeg2 (or compatible mp4 if using push.) With my x86 I get around 40fps transcoding on SD files and on 720p files around 18fps.

[Requirements]
Python2.7

[Release information]
V2.0 (2-13-2014)
- new icon
- upgraded pyTivo to the latest lucasnz fork

lucasnz fork improvements:
- togo and video share UI improvements
- Mobile web UI (by ngarcia001)
- ability to specify a temp share on local drive to reduce amount of traffic on network during a file remux
- mpeg-ts togo support. Put ts = on in the server section of pytivo.conf

V1.0 (1-29-2013)
- fixed dependencies (reported that Optware was require when it wasn't)
- stopped pyTivo logging as it could create rather large log files

V.5 (1-26-2013)
- total rework of start and stop script
- removed Optware and procps requirements

V.1b (01-05-2013)
- Initial release (possibly only release)

[Source]
http://pytivo.sourceforge.net/
I am not the author of this app. I have only packaged it into a QPKG installer.

[Download Link]
Link (Version 2)
Link (Version 1)
Last edited by kisonay on Tue Jul 29, 2014 8:47 pm, edited 7 times in total.
roughana
Starting out
Posts: 20
Joined: Sun Oct 09, 2011 5:35 am

Re: [QPKG] pyTivo

Post by roughana »

Firstly, Thank you very much for doing this.

I haven't tried it yet as I have rolled my own as per http://forum.qnap.com/viewtopic.php?t=40937
However, I wanted to ask how you did it and what it includes. Did you follow the above thread or deviate from it?
What version of ffmpeg is used?
Does this install handle DVD VIDEO_TS folders?
Where does it get installed so we can modify the configuration file?

Regards,
Andrew
kisonay
Getting the hang of things
Posts: 82
Joined: Sat Dec 22, 2012 3:45 am
Location: New York, USA

Re: [QPKG] pyTivo

Post by kisonay »

I actually configured it myself as I was having difficulties with all how-tos I found.

There is really nothing special about this install, at all. I literally downloaded the files from sourceforge, unziped them and placed them in a folder on the NAS. I then created a script to start and stop the application and quickly packaged everything in a qpkg when I confirmed I had it working.

ffmpeg version 0.8.10 and if it wasn't already on the NAS then I had installed it via ipkg. (I will make a note of this in my original post.)

The config file is fully configurable via the web interface so there would be no reason to open it in a "raw" format. The link to the web interface is in the QPKG install list. That being said, if you wanted to modify it yourself, all files are located in /share/MD0_DATA/.qpkg/pyTivo/
Paull24
New here
Posts: 4
Joined: Mon Jan 21, 2013 11:24 am

Re: [QPKG] pyTivo

Post by Paull24 »

Thanks for this QPKG, was hoping to have something like this for Tivo when I bought my QNAP. Just to share my experience and notes for anyone else below. I'm using firmware 3.8.1.

I had trouble with this QPKG after installing it as it did not autostart. I had to ssh into my QNAP SS-439 Pro and manually run pyTivo.py to get the WebConfiguration to launch. For whatever reason (not sure why) the pyTivo.sh* autostart script would not work for me.

After further searching, I found a way online to run the pyTivo as a service manually. Via SSH I did the following.
1. I had to at the command line enter: chmod +x /share/MD0_DATA/.qpkg/pyTivo/pyTivo.py
2. Then: chmod 777 /share/MD0_DATA/.qpkg/pyTivo/pyTivo.py
3. Then: daemon_mgr pyTivo start "/share/MD0_DATA/.qpkg/pyTivo/pyTivo.py &"
Or could have done I believe to run in background: python pyTivo.py &

I have to run this command manually every time I reboot my QNAP for some reason. None of the different things I tried to get the pyTivo to autorun worked. Could someone help on this point? I'm a noob with Linux.

Thanks again to kisonay above for posting the QPKG.
kisonay
Getting the hang of things
Posts: 82
Joined: Sat Dec 22, 2012 3:45 am
Location: New York, USA

Re: [QPKG] pyTivo

Post by kisonay »

Thank you for the feedback. I'm not really sure what is going on with the autostart script.

Did you try to run pyTivo.sh via SSH and what was the output?

Code: Select all

./pyTivo.sh start
I am also posting the code for the pyTivo.sh script to see if someone sees something wrong with it as I am pretty new at this.

Code: Select all

#!/bin/bash
# chkconfig: 2345 99 05
# description: pyTivo server

### INIT INFO
# Provides: pytivo
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-description: pyTivo server
# Description: Start and stop the pyTivo server.
### END INIT INFO

RETVAL=0


start() {
echo -n "Starting pyTivo: "
pgrep -f pyTivo.py
RETVAL=$?
[ $RETVAL -eq 0 ] && echo "pyTivo already running: Exiting" && exit 1

# this call actually starts pyTivo.
python /share/MD0_DATA/.qpkg/pyTivo/pyTivo.py > /dev/null 2>&1 &
RETVAL=$?
[ $RETVAL -eq 0 ] && echo -n "done"
echo
return $RETVAL
}

stop() {
echo -n "Stopping pyTivo: "
pid=$(pgrep -f pyTivo.py)
echo $pid
kill -9 $pid
echo
[ $RETVAL -eq 0 ] && echo -n "done"
echo
return $RETVAL
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
sleep 1
start
RETVAL=$?
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit $RETVAL
kisonay
Getting the hang of things
Posts: 82
Joined: Sat Dec 22, 2012 3:45 am
Location: New York, USA

Re: [QPKG] pyTivo

Post by kisonay »

OK, now, after this has been working great for a month (through many reboots) I am now having an issue were this will no longer autostart.

I can manually start the package by running sh /share/MD0_DATA/.qpkg/pyTivo/pyTivo.sh start

I need to look into why this won't start anymore. If anyone has any ideas or knows how I can debug the startup, please let me know.
kisonay
Getting the hang of things
Posts: 82
Joined: Sat Dec 22, 2012 3:45 am
Location: New York, USA

Re: [QPKG] pyTivo

Post by kisonay »

Paul,

I believe I found the issue. You will need to update the pyTivo.sh script with the following:

Code: Select all

#!/bin/sh
# chkconfig: 2345 99 05
# description: pyTivo server

RETVAL=0

start() {
	echo -n "Checking pyTivo... "
	if ps ax | grep -v grep | grep -v $0 | grep pyTivo.py > /dev/null
	then
	    echo "pyTivo is running, everything is fine" && exit 1
	else
		/usr/bin/python /share/MD0_DATA/.qpkg/pyTivo/pyTivo.py > /dev/null 2>&1 &
		RETVAL=$?
		echo "initiating pyTivo... "
		[ $RETVAL -eq 0 ] && echo "done"
		return $RETVAL	
	fi
}

stop() {
	echo -n "Stopping pyTivo... "
	kill $(ps -ef | grep pyTivo.py | grep -v grep | awk '{print $1}')
	echo "done"
	return $RETVAL
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
sleep 1
start
RETVAL=$?
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac
exit $RETVAL
I reworked a lot of it but the important change was the first line. My original script was calling in #!/bin/bash which seemed to be causing issues. I updated this to #!/bin/sh and it seems to have correct my issue that appeared.

Can you give this a try and see if disable/enable the package in the admin works? If it work I will go ahead and update my first post with this new package.
Paull24
New here
Posts: 4
Joined: Mon Jan 21, 2013 11:24 am

Re: [QPKG] pyTivo

Post by Paull24 »

Just had a chance to look at this and thanks for looking into it.

I tried the updated script and the disable/enable via the admin console did not auto-start the pyTivo service.
I then tried the

Code: Select all

./pyTivo.sh start
command and even though it returned that it was done, when I tried to launch the web config, it did was not started and I could not reach the web config screen.

I then tried replacing the statement right after the "else" section under the start portion with the following:

Code: Select all

daemon_mgr pyTivo start "/share/MD0_DATA/.qpkg/pyTivo/pyTivo.py &" > null 2>&1 &
This is how I have been manually starting the service. I saved the script and ran the

Code: Select all

./pyTivo.sh start
again and this time it returned the done message and when I tried the web config launched the screen.

However when I tried the next step of doing the disable/enable via the admin console, that still did not auto-start the service and I could not reach the web config. I then had to start the service manually. The main thing is the

Code: Select all

./pyTvo.sh start
command works for me now where it did not at first and returned an error about not recognizing the start command. Also not sure if there is some difference between the 39 series I have versus your 69 series.
kisonay
Getting the hang of things
Posts: 82
Joined: Sat Dec 22, 2012 3:45 am
Location: New York, USA

Re: [QPKG] pyTivo

Post by kisonay »

can you log into your nas via SSH and run the following commands (please stay in the default root directory) and copy the result here?

Code: Select all

[~] # /share/MD0_DATA/.qpkg/pyTivo/pyTivo.sh
Paull24
New here
Posts: 4
Joined: Mon Jan 21, 2013 11:24 am

Re: [QPKG] pyTivo

Post by Paull24 »

I get the following:

Code: Select all

Usage: /share/MD0_DATA/.qpkg/pyTivo/pyTivo.sh {start|stop}
kisonay
Getting the hang of things
Posts: 82
Joined: Sat Dec 22, 2012 3:45 am
Location: New York, USA

Re: [QPKG] pyTivo

Post by kisonay »

OK,

I am totally reworking the pyTivo.sh script to hopefully improve compatibility. Will let you know when the first post is updated with it.
kisonay
Getting the hang of things
Posts: 82
Joined: Sat Dec 22, 2012 3:45 am
Location: New York, USA

Re: [QPKG] pyTivo

Post by kisonay »

Paul, give version .5 a try (in the first post) and let me know how you make out.

I also just wanted to mention that after the NAS reboots, once the admin interface starts to respond it will take a few minutes for pyTivo to kick in. I guess it is still running through processes after the web admin starts to respond.
Paull24
New here
Posts: 4
Joined: Mon Jan 21, 2013 11:24 am

Re: [QPKG] pyTivo

Post by Paull24 »

WORKING!
Awesome, thanks for reworking the startup script. It works directly from enabling the QPKG and also upon reboot of the QNAP.

Otherwise, cool you removed the dependencies but upon trying to manually install the qpkg, it still said I needed the Optware QPKG. I disabled it first to test things out. No big deal as I disabled Optware after I installed this updated pyTivo qpkg and everything works fine with the Optware one disabled.

Much thanks again,
kisonay
Getting the hang of things
Posts: 82
Joined: Sat Dec 22, 2012 3:45 am
Location: New York, USA

Re: [QPKG] pyTivo

Post by kisonay »

good catch, I forgot to remove the Optware dependency from the config file. Will do that and some other cleanup and then post new version.
kisonay
Getting the hang of things
Posts: 82
Joined: Sat Dec 22, 2012 3:45 am
Location: New York, USA

Re: [QPKG] pyTivo

Post by kisonay »

Version 1.0 released
Post Reply

Return to “Community Apps”