Changeset 8218f7134f7e62a3e0fae4f49ee126121bd96bfa
- Timestamp:
- 11/18/07 00:38:40
(1 year ago)
- Author:
- Jason Michalski <armooo@armooo.net>
- git-committer:
- Jason Michalski <armooo@armooo.net> 1195367920 -0600
- git-parent:
[8e278119bfa61c6b675976ab7dae17da95a85eef]
- git-author:
- Jason Michalski <armooo@armooo.net> 1195367920 -0600
- Message:
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.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r303570a |
r8218f71 |
|
| 2 | 2 | <TiVoContainer> |
|---|
| 3 | 3 | <ItemStart>$start</ItemStart> |
|---|
| 4 | | <ItemCount>#echo len($files) #</ItemCount> |
|---|
| | 4 | <ItemCount>#echo len($videos) #</ItemCount> |
|---|
| 5 | 5 | <Details> |
|---|
| 6 | 6 | <Title>$escape($name)</Title> |
|---|
| … | … | |
| 9 | 9 | <TotalItems>$total</TotalItems> |
|---|
| 10 | 10 | </Details> |
|---|
| 11 | | #for $file in $files |
|---|
| 12 | | #if $isdir($file) |
|---|
| | 11 | #for $video in $videos |
|---|
| | 12 | #if $video.is_dir |
|---|
| 13 | 13 | <Item> |
|---|
| 14 | 14 | <Details> |
|---|
| 15 | | <Title>$escape($file)</Title> |
|---|
| | 15 | <Title>$escape($video.name)</Title> |
|---|
| 16 | 16 | <ContentType>x-container/folder</ContentType> |
|---|
| 17 | 17 | <SourceFormat>x-tivo-container/tivo-dvr</SourceFormat> |
|---|
| … | … | |
| 19 | 19 | <Links> |
|---|
| 20 | 20 | <Content> |
|---|
| 21 | | <Url>/TiVoConnect?Command=QueryContainer&Container=$quote($name)/$quote($file)</Url> |
|---|
| | 21 | <Url>/TiVoConnect?Command=QueryContainer&Container=$quote($name)/$quote($video.name)</Url> |
|---|
| 22 | 22 | <ContentType>x-tivo-container/folder</ContentType> |
|---|
| 23 | 23 | </Content> |
|---|
| … | … | |
| 27 | 27 | <Item> |
|---|
| 28 | 28 | <Details> |
|---|
| 29 | | <Title>#echo $escape('.'.join(file.split('.')[:-1])) #</Title> |
|---|
| | 29 | <Title>#echo $escape('.'.join(video['name'].split('.')[:-1])) #</Title> |
|---|
| 30 | 30 | <ContentType>video/x-tivo-mpeg</ContentType> |
|---|
| 31 | 31 | <SourceFormat>video/x-ms-wmv</SourceFormat> |
|---|
| 32 | | <SourceSize>$est_size($file)</SourceSize> |
|---|
| 33 | | <Duration>$duration($file)</Duration> |
|---|
| | 32 | <SourceSize>$video.size</SourceSize> |
|---|
| | 33 | <Duration>$video.duration</Duration> |
|---|
| | 34 | <Description>$video.description</Description> |
|---|
| 34 | 35 | </Details> |
|---|
| 35 | 36 | <Links> |
|---|
| … | … | |
| 37 | 38 | <ContentType>video/x-tivo-mpeg</ContentType> |
|---|
| 38 | 39 | <AcceptsParams>No</AcceptsParams> |
|---|
| 39 | | <Url>/$quote($name)/$quote($file)</Url> |
|---|
| | 40 | <Url>/$quote($name)/$quote($video.name)</Url> |
|---|
| 40 | 41 | </Content> |
|---|
| 41 | 42 | <CustomIcon> |
|---|
| r5bf1bd3 |
r8218f71 |
|
| 67 | 67 | bitrate = audioBPS + videoBPS |
|---|
| 68 | 68 | return int((duration(file)/1000)*(bitrate * 1.02 / 8)) |
|---|
| | 69 | |
|---|
| | 70 | def description(file): |
|---|
| | 71 | full_path = os.path.join(path, file + '.txt') |
|---|
| | 72 | if os.path.exists(full_path): |
|---|
| | 73 | return open(full_path).read() |
|---|
| | 74 | else: |
|---|
| | 75 | return '' |
|---|
| 69 | 76 | |
|---|
| 70 | 77 | def VideoFileFilter(file): |
|---|
| … | … | |
| 75 | 82 | return transcode.suported_format(full_path) |
|---|
| 76 | 83 | |
|---|
| | 84 | |
|---|
| | 85 | files, total, start = self.get_files(handler, query, VideoFileFilter) |
|---|
| | 86 | |
|---|
| | 87 | videos = [] |
|---|
| | 88 | for file in files: |
|---|
| | 89 | video = {} |
|---|
| | 90 | |
|---|
| | 91 | video['name'] = file |
|---|
| | 92 | video['is_dir'] = isdir(file) |
|---|
| | 93 | if not isdir(file): |
|---|
| | 94 | video['size'] = est_size(file) |
|---|
| | 95 | video['duration'] = duration(file) |
|---|
| | 96 | video['description'] = description(file) |
|---|
| | 97 | |
|---|
| | 98 | videos.append(video) |
|---|
| | 99 | |
|---|
| | 100 | print videos |
|---|
| | 101 | |
|---|
| 77 | 102 | handler.send_response(200) |
|---|
| 78 | 103 | handler.end_headers() |
|---|
| 79 | 104 | t = Template(file=os.path.join(SCRIPTDIR,'templates', 'container.tmpl')) |
|---|
| 80 | 105 | t.name = subcname |
|---|
| 81 | | t.files, t.total, t.start = self.get_files(handler, query, VideoFileFilter) |
|---|
| 82 | | t.duration = duration |
|---|
| 83 | | t.est_size = est_size |
|---|
| 84 | | t.isdir = isdir |
|---|
| | 106 | t.total = total |
|---|
| | 107 | t.start = start |
|---|
| | 108 | t.videos = videos |
|---|
| 85 | 109 | t.quote = quote |
|---|
| 86 | 110 | t.escape = escape |
|---|