Changeset 8218f7134f7e62a3e0fae4f49ee126121bd96bfa

Show
Ignore:
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
  • plugins/video/templates/container.tmpl

    r303570a r8218f71  
    22<TiVoContainer> 
    33    <ItemStart>$start</ItemStart> 
    4     <ItemCount>#echo len($files) #</ItemCount> 
     4    <ItemCount>#echo len($videos) #</ItemCount> 
    55    <Details> 
    66        <Title>$escape($name)</Title> 
     
    99        <TotalItems>$total</TotalItems> 
    1010    </Details> 
    11     #for $file in $file
    12     #if $isdir($file) 
     11    #for $video in $video
     12    #if $video.is_dir 
    1313    <Item> 
    1414        <Details> 
    15             <Title>$escape($file)</Title> 
     15            <Title>$escape($video.name)</Title> 
    1616            <ContentType>x-container/folder</ContentType> 
    1717            <SourceFormat>x-tivo-container/tivo-dvr</SourceFormat> 
     
    1919        <Links> 
    2020            <Content> 
    21                     <Url>/TiVoConnect?Command=QueryContainer&amp;Container=$quote($name)/$quote($file)</Url> 
     21                    <Url>/TiVoConnect?Command=QueryContainer&amp;Container=$quote($name)/$quote($video.name)</Url> 
    2222                    <ContentType>x-tivo-container/folder</ContentType> 
    2323            </Content> 
     
    2727    <Item> 
    2828        <Details> 
    29             <Title>#echo $escape('.'.join(file.split('.')[:-1])) #</Title> 
     29            <Title>#echo $escape('.'.join(video['name'].split('.')[:-1])) #</Title> 
    3030            <ContentType>video/x-tivo-mpeg</ContentType> 
    3131            <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> 
    3435        </Details> 
    3536        <Links> 
     
    3738                <ContentType>video/x-tivo-mpeg</ContentType> 
    3839                    <AcceptsParams>No</AcceptsParams> 
    39                     <Url>/$quote($name)/$quote($file)</Url> 
     40                    <Url>/$quote($name)/$quote($video.name)</Url> 
    4041                </Content> 
    4142                <CustomIcon> 
  • plugins/video/video.py

    r5bf1bd3 r8218f71  
    6767                bitrate =  audioBPS + videoBPS 
    6868                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 '' 
    6976 
    7077        def VideoFileFilter(file): 
     
    7582            return transcode.suported_format(full_path) 
    7683 
     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 
    77102        handler.send_response(200) 
    78103        handler.end_headers() 
    79104        t = Template(file=os.path.join(SCRIPTDIR,'templates', 'container.tmpl')) 
    80105        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 
    85109        t.quote = quote 
    86110        t.escape = escape