Changeset 51b0b5e0861235af31b4eb5f82a1543bc61be6ba

Show
Ignore:
Timestamp:
02/11/08 22:56:50 (9 months ago)
Author:
KRKeegan <kevin@krkeegan.com>
git-committer:
KRKeegan <kevin@krkeegan.com> 1202792210 -0800
git-parent:

[aa91faa2cce73f966ccb3265a27177d58db24f8c]

git-author:
KRKeegan <kevin@krkeegan.com> 1202792210 -0800
Message:

New: PreCache? Files so TiVo Loads Faster

This will cause pyTivo parse all files recursivly in a share to load them into the cache. Currently this only works in the video plugin, but incorporation into other plugins that use a cache is very easy.

In the video plugin this causes pyTivo to run ffmpeg on EVERY video file in that share and stores that information in the cache.

Benefits: This greatly decreases the load time while browsing on the TiVo. For me a folder with 50 videos would take 18 seconds to load the first time I viewed it. Now it takes less than 2 seconds.
Drawbacks: This will create a delay in the startup of pyTivo while processing the files. For me I experienced a delay of nearly 2 minutes to parse 757 video files.

Usage:
Set the precache=true under any share. If the plugin does not support the precache setting it is ignored.

Example:
In the following conf file the share "Old TV" would be precached while "Movies" and "Photos" would not be.

[Old TV]
type = video
path = /store/TV
precache=true

[Movies]
type = video
path = /store/Movies

[Photos]
type = photo
path = /store/Photos

[Server]
debug = true
ffmpeg = /usr/bin/ffmpeg
hack83 = true
port = 9032

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/video/video.py

    rfaf826f r51b0b5e  
    4343    count = 0 
    4444    request_history = {} 
     45 
     46    def pre_cache(self, full_path): 
     47        if Video.video_file_filter(self, full_path): 
     48            return transcode.supported_format(full_path) 
     49        return False 
    4550 
    4651    def video_file_filter(self, full_path, type=None): 
  • pyTivo.py

    ra49222f r51b0b5e  
    33import beacon, httpserver, os, sys 
    44import config 
     5from plugin import GetPlugin 
    56 
    67port = config.getPort() 
     
    1011for section, settings in config.getShares(): 
    1112    httpd.add_container(section, settings) 
     13    #Precaching of files: does a recursive list of base path 
     14    if settings.get('precache', 'False').lower() == 'true': 
     15        plugin = GetPlugin(settings.get('type')) 
     16        if hasattr(plugin,'pre_cache'): 
     17            pre_cache_filter = getattr(plugin, 'pre_cache') 
     18             
     19            def build_recursive_list(path): 
     20                files = [] 
     21                for file in os.listdir(path): 
     22                    file = os.path.join(path, file) 
     23                    if os.path.isdir(file): 
     24                        files.extend(build_recursive_list(file)) 
     25                        continue 
     26                    pre_cache_filter(file) 
     27                return files 
     28 
     29            files = build_recursive_list(settings.get('path')) 
    1230 
    1331b = beacon.Beacon()