From ae0b9b35097c476bde6d089bce3c093b21e5b507 Mon Sep 17 00:00:00 2001 From: William McBrine Date: Sun, 3 Feb 2008 11:26:29 -0500 Subject: [PATCH] Extension-based video_file_filter -- massive speedup The first version I'm committing. --- plugins/video/video.ext | 10 ++++++++++ plugins/video/video.py | 13 +++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 plugins/video/video.ext diff --git a/plugins/video/video.ext b/plugins/video/video.ext new file mode 100644 index 0000000..91ed04d --- /dev/null +++ b/plugins/video/video.ext @@ -0,0 +1,10 @@ +.tivo .mpg .avi .wmv .mov .flv .vob .3g2 .3gp .3gp2 .3gpp .3mm .60d .aep +.ajp .amv .asf .asx .avb .avs .bik .bix .box .byu .camrec .cvcc .d2v +.dat .dce .dif .dir .divx .dmb .dpg .dv .dvr-ms .dxr .eye .fcp .flc .fli +.flx .gl .grasp .gvi .gvp .ifo .imovieproji .imovieprojecti .ivf .ivs +.izz .izzy .lsf .lsx .m1v .m21 .m2v .m4e .m4u .m4v .mjp .mkv .mod .moov +.movie .mp21 .mp4 .mpe .mpeg .mpv2 .mqv .msh .mswmm .mvb .mvc .nsv .nvc +.ogm .pds .piv .playlist .pro .prproj .prx .qt .qtch .qtz .rm .rmvb .rp +.rts .rts .sbk .scm .scm .sfvidcap .smil .smv .spl .srt .ssm .str .svi +.swf .swi .tda3mt .ts .vdo .veg .vf .vfw .vid .viewlet .viv .vivo .vp6 +.vp7 .vro .w32 .wcp .wm .wmd .wmx .wvx .yuv diff --git a/plugins/video/video.py b/plugins/video/video.py index 5fec0a4..7740121 100644 --- a/plugins/video/video.py +++ b/plugins/video/video.py @@ -12,6 +12,12 @@ SCRIPTDIR = os.path.dirname(__file__) CLASS_NAME = 'Video' +extfile = os.path.join(SCRIPTDIR, 'video.ext') +try: + extensions = file(extfile).read().split() +except: + extensions = None + class Video(Plugin): CONTENT_TYPE = 'x-container/tivo-videos' @@ -19,7 +25,10 @@ class Video(Plugin): def video_file_filter(self, full_path, type=None): if os.path.isdir(full_path): return True - return transcode.supported_format(full_path) + if extensions: + return os.path.splitext(full_path)[1].lower() in extensions + else: + return transcode.supported_format(full_path) def send_file(self, handler, container, name): if handler.headers.getheader('Range') and \ @@ -32,7 +41,7 @@ class Video(Plugin): handler.wfile.write("\x30\x0D\x0A") return - tsn = handler.headers.getheader('tsn', '') + tsn = handler.headers.getheader('tsn', '') o = urlparse("http://fake.host" + handler.path) path = unquote(o[2]) -- 2.11.4.GIT