Changeset ba90f24843c7c942b001b46fb707cbc0d409f90d

Show
Ignore:
Timestamp:
12/02/07 21:04:02 (1 year ago)
Author:
Jason Michalski <armooo@armooo.net>
git-committer:
Jason Michalski <armooo@armooo.net> 1196651042 -0600
git-parent:

[8b942de2822ae69316152244f6c6d807e2bd4bd3]

git-author:
Jason Michalski <armooo@armooo.net> 1196538173 -0600
Message:

Updated music plugin to suport the full paths

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/music/music.py

    r214a148 rba90f24  
    1414     
    1515    CONTENT_TYPE = 'x-container/tivo-music' 
     16 
     17    AUDIO = 'audio' 
     18    DIRECTORY = 'dir' 
     19 
    1620    playable_cache = {} 
    1721    playable_cache = LRUCache(1000) 
     
    2226        subcname = query['Container'][0] 
    2327        cname = subcname.split('/')[0] 
     28        local_base_path = self.get_local_base_path(handler, query) 
    2429          
    2530        if not handler.server.containers.has_key(cname) or not self.get_local_path(handler, query): 
     
    2833            return 
    2934         
    30         path = self.get_local_path(handler, query) 
    31         def isdir(file): 
    32             return os.path.isdir(os.path.join(path, file)) 
     35        def AudioFileFilter(file, filter_type = None): 
    3336 
    34         def AudioFileFilter(file): 
    35             full_path = os.path.join(path, file) 
     37            if filter_type: 
     38                filter_start = filter_type.split('/')[0] 
     39            else: 
     40                filter_start = filter_type 
    3641 
    37             if full_path in self.playable_cache: 
    38                 return self.playable_cache[full_path] 
    39             if os.path.isdir(full_path) or eyeD3.isMp3File(full_path): 
    40                 self.playable_cache[full_path] = True 
    41                 return True 
    42             else: 
    43                 self.playable_cache[full_path] = False 
    44                 return False  
     42            if file not in self.playable_cache: 
     43                if os.path.isdir(file): 
     44                    self.playable_cache[file] = self.DIRECTORY 
     45                     
     46                elif eyeD3.isMp3File(file): 
     47                    self.playable_cache[file] = self.AUDIO 
     48                else: 
     49                    self.playable_cache[file] = False 
     50             
     51            if filter_start == self.AUDIO: 
     52                if self.playable_cache[file] == self.AUDIO: 
     53                    return self.playable_cache[file] 
     54                else: 
     55                    return False 
     56            else:  
     57                return self.playable_cache[file] 
     58 
    4559 
    4660        def media_data(file): 
    4761            dict = {} 
    4862            dict['path'] = file 
    49  
    50             file = os.path.join(path, file) 
     63            dict['part_path'] = file.replace(local_base_path, '') 
     64            dict['name'] = os.path.split(file)[1] 
     65            dict['is_dir'] = os.path.isdir(file) 
    5166 
    5267            if file in self.media_data_cache: 
    5368                return self.media_data_cache[file] 
    5469         
    55             if isdir(file) or not eyeD3.isMp3File(file): 
     70            if os.path.isdir(file) or not eyeD3.isMp3File(file): 
    5671                self.media_data_cache[file] = dict 
    5772                return dict 
     
    8095        t = Template(file=os.path.join(SCRIPTDIR,'templates', 'container.tmpl')) 
    8196        t.name = subcname 
     97        t.container = cname 
    8298        t.files, t.total, t.start = self.get_files(handler, query, AudioFileFilter) 
    8399        t.files = map(media_data, t.files) 
    84         t.isdir = isdir 
    85100        t.quote = quote 
    86101        t.escape = escape 
  • plugins/music/templates/container.tmpl

    r6ab8361 rba90f24  
    1010    </Details> 
    1111    #for $file in $files 
    12     #if $isdir($file['path']) 
     12    #if $file['is_dir'] 
    1313    <Item> 
    1414        <Details> 
    15             <Title>$escape($file.path)</Title> 
     15            <Title>$escape($file.name)</Title> 
    1616            <ContentType>x-container/folder</ContentType> 
    1717            <SourceFormat>x-container/folder</SourceFormat> 
     
    1919        <Links> 
    2020            <Content> 
    21                     <Url>/TiVoConnect?Command=QueryContainer&amp;Container=$quote($name)/$quote($file.path)</Url> 
     21                    <Url>/TiVoConnect?Command=QueryContainer&amp;Container=$quote($name)/$quote($file.name)</Url> 
    2222                    <ContentType>x-tivo-container/folder</ContentType> 
    2323            </Content> 
     
    2727    <Item> 
    2828        <Details> 
    29             <Title>#echo '.'.join(file['path'].split('.')[:-1]) #</Title> 
     29            <Title>#echo '.'.join(file['name'].split('.')[:-1]) #</Title> 
    3030            <ContentType>audio/*</ContentType> 
    3131            <SourceFormat>audio/mpeg</SourceFormat> 
     
    4040                <ContentType>audio/*</ContentType> 
    4141                    <AcceptsParams>No</AcceptsParams> 
    42                     <Url>/$quote($name)/$quote($file.path)</Url> 
     42                    <Url>/$quote($container)$quote($file.part_path)</Url> 
    4343                </Content> 
    4444        </Links>