From pyTivo - Wiki
Note: Usually it is better to have some experience in coding before you start to make a plugin.
Another note: DON'T FOLLOW THIS GUIDE TOO CLOSELY! It is based on the video plugin so it might be different with music or other.
[Container] path = C:\Videos type = WHAT EVER YOU WANT
This is a container in the pyTivo.conf file. This guide helps you in making the type be "what ever you want"
First it is probably best that you have some experience in coding preferably the Python language. If not you may want to read some other guide on coding like: the wiki.python.org beginners guide
Following this should let you make a plugin:
- download pyTivo.
- use some sort of python ide. (any will do even notepad)
- open up the pyTivo folder. You will see that pyTivo has three folders and some files.
- open up the folder with the name: plugins. Now you should see 2 folders named music and video.
- copy the video folder and paste it in the plugins folder.
- rename that folder something like video.dev or whatever you want your plugin to be named.
- Now we will start to look at that folder. It has some files and folders. The Templates folder is the folder that it uses to communicate with the server.
- Video.py is the main file.
- Transcode.py is a tool that video.py uses to transcode.
- ffmpeg_mp2.exe is the transcoding utility and i assume that pthreadGC2.dll is also part of ffmpeg.
- If your tool doesn't need transcoding you can delete transcode.py, ffmpeg_mp2.exe, and pthreadGC2.exe.
- Now open up video.py in your IDE (if you don't know what that is just use notepad).
- First off is a list of import the file uses. Probably you shouldn't change anything except the transcode one if you chose to delete transcode.py earlier. Then there are some things I haven't been able to define. I assume ScriptDir is the base directory for your files and CLASS_NAME is the name of the type that you need to set in the config file.
- You should probably change the CLASS_NAME to the name of your plugin.
- Change Video(Plugin) to $name$(Plugin) $name$ being the name of your plugin. The (Plugin) part means that it extends Plugin.py.
- Content_Type is the kind of files your plugin has. If it has music change it to "x-container/tivo-music".
- Now you can see send_file. It is what the plugin does if tivo asks for a file.
Now you can see a little bit how to make a plugin. I should add more later but that's all for now.
What will your plugin need to do?
- At module level, define CLASS_NAME, with the name of the class in your plugin.
- In your class, define CONTENT_TYPE -- this is what httpserver will say is in your containers.
- Any command that takes a Container parm will be dispatched to <YourClass>.<Command>. ""/TiVoConnect?Command=QueryContainer&Container=MyMovies Laptop/My Plugin"" will call QueryContainer.
- The plugin is singleton to you can cache values at class level.
The real work
- Implement a QueryContainer method -- this is how the TiVo requests a directory listing.
- Implement send_file if the default static file content will not work for you.
What can the Plugin base class do for you?
- Serve static files (urls under /<Share Name>/<Path On File System>)
- Parse a QueryContainer like request and return the a list of files. self.get_files. Can also take a filter function so that random files will not show up.
- Map urls to server paths get_local_base_path, get_local_path.