From 8218f7134f7e62a3e0fae4f49ee126121bd96bfa Mon Sep 17 00:00:00 2001 From: Jason Michalski Date: Sun, 18 Nov 2007 00:38:40 -0600 Subject: [PATCH] Video Descriptions Changed the files list to a list of dict that describe the videos. So we don't have to add all the functions in to the template's namespace. --- plugins/video/templates/container.tmpl | 19 ++++++++++--------- plugins/video/video.py | 32 ++++++++++++++++++++++++++++---- 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/plugins/video/templates/container.tmpl b/plugins/video/templates/container.tmpl index a7f231e..a957e17 100644 --- a/plugins/video/templates/container.tmpl +++ b/plugins/video/templates/container.tmpl @@ -1,24 +1,24 @@ $start - #echo len($files) # + #echo len($videos) #
$escape($name) x-container/tivo-videos x-container/folder $total
- #for $file in $files - #if $isdir($file) + #for $video in $videos + #if $video.is_dir
- $escape($file) + $escape($video.name) x-container/folder x-tivo-container/tivo-dvr
- /TiVoConnect?Command=QueryContainer&Container=$quote($name)/$quote($file) + /TiVoConnect?Command=QueryContainer&Container=$quote($name)/$quote($video.name) x-tivo-container/folder @@ -26,17 +26,18 @@ #else
- #echo $escape('.'.join(file.split('.')[:-1])) # + #echo $escape('.'.join(video['name'].split('.')[:-1])) # video/x-tivo-mpeg video/x-ms-wmv - $est_size($file) - $duration($file) + $video.size + $video.duration + $video.description
video/x-tivo-mpeg No - /$quote($name)/$quote($file) + /$quote($name)/$quote($video.name) video/* diff --git a/plugins/video/video.py b/plugins/video/video.py index eab6ac3..ad24486 100644 --- a/plugins/video/video.py +++ b/plugins/video/video.py @@ -66,6 +66,13 @@ class video(Plugin): videoBPS = strtod(Config.getVideoBR()) bitrate = audioBPS + videoBPS return int((duration(file)/1000)*(bitrate * 1.02 / 8)) + + def description(file): + full_path = os.path.join(path, file + '.txt') + if os.path.exists(full_path): + return open(full_path).read() + else: + return '' def VideoFileFilter(file): full_path = os.path.join(path, file) @@ -74,14 +81,31 @@ class video(Plugin): return True return transcode.suported_format(full_path) + + files, total, start = self.get_files(handler, query, VideoFileFilter) + + videos = [] + for file in files: + video = {} + + video['name'] = file + video['is_dir'] = isdir(file) + if not isdir(file): + video['size'] = est_size(file) + video['duration'] = duration(file) + video['description'] = description(file) + + videos.append(video) + + print videos + handler.send_response(200) handler.end_headers() t = Template(file=os.path.join(SCRIPTDIR,'templates', 'container.tmpl')) t.name = subcname - t.files, t.total, t.start = self.get_files(handler, query, VideoFileFilter) - t.duration = duration - t.est_size = est_size - t.isdir = isdir + t.total = total + t.start = start + t.videos = videos t.quote = quote t.escape = escape handler.wfile.write(t) -- 2.11.4.GIT