Changeset 51b0b5e0861235af31b4eb5f82a1543bc61be6ba
- 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
| rfaf826f |
r51b0b5e |
|
| 43 | 43 | count = 0 |
|---|
| 44 | 44 | 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 |
|---|
| 45 | 50 | |
|---|
| 46 | 51 | def video_file_filter(self, full_path, type=None): |
|---|
| ra49222f |
r51b0b5e |
|
| 3 | 3 | import beacon, httpserver, os, sys |
|---|
| 4 | 4 | import config |
|---|
| | 5 | from plugin import GetPlugin |
|---|
| 5 | 6 | |
|---|
| 6 | 7 | port = config.getPort() |
|---|
| … | … | |
| 10 | 11 | for section, settings in config.getShares(): |
|---|
| 11 | 12 | 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')) |
|---|
| 12 | 30 | |
|---|
| 13 | 31 | b = beacon.Beacon() |
|---|