Changeset 65ec512fb94a11243e34f62a7c9d7fe282080802

Show
Ignore:
Timestamp:
01/09/07 22:47:12 (2 years ago)
Author:
Jason Michalski <armooo@armooo.net>
git-committer:
Jason Michalski <armooo@armooo.net> 1168404432 +0000
git-parent:

[11a926a2b7308d9b0bd37102508ac1a8873b640d]

git-author:
Jason Michalski <armooo@armooo.net> 1168404432 +0000
Message:

pyTivo
- plugins/music/music.py, plugins/video/video.py using lrucache
- plugin.py should no longer fall of this file list

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • httpserver.py

    r29ad0eb r65ec512  
    5353                #Dispatch to the container plugin 
    5454                for name, container in self.server.containers.items(): 
    55                     print name, query['Container'][0] 
    5655                    if query['Container'][0].startswith(name): 
    5756                        plugin = GetPlugin(container['type']) 
  • plugin.py

    r11a926a r65ec512  
    113113                index = index +  int(query['AnchorOffset'][0]) 
    114114                 
     115        #foward count 
    115116        if index < index + count: 
    116             files = files[max(index, 0):index + count ] 
     117            files = files[index:index + count ] 
    117118            return files, totalFiles, index 
     119        #backwards count 
    118120        else: 
    119             files = files[max(index + count, 0):index] 
     121            print 'index, count', index, count 
     122            print index + count 
     123            #off the start of the list 
     124            if index + count < 0: 
     125                print 0 - (index + count) 
     126                index += 0 - (index + count) 
     127            print index + count 
     128            files = files[index + count:index] 
    120129            return files, totalFiles, index + count 
  • plugins/music/music.py

    rf08eb75 r65ec512  
    44from urllib import unquote_plus, quote, unquote 
    55from xml.sax.saxutils import escape 
     6from lrucache import LRUCache 
    67import eyeD3 
    78 
     
    1112     
    1213    content_type = 'x-container/tivo-music' 
     14    playable_cache = {} 
     15    playable_cache = LRUCache(1000) 
     16    media_data_cache = LRUCache(100) 
    1317         
    1418    def QueryContainer(self, handler, query): 
     
    2630            return os.path.isdir(os.path.join(path, file)) 
    2731 
     32        def AudioFileFilter(file): 
     33            full_path = os.path.join(path, file) 
     34 
     35            if full_path in self.playable_cache: 
     36                return self.playable_cache[full_path] 
     37            if os.path.isdir(full_path) or eyeD3.isMp3File(full_path): 
     38                self.playable_cache[full_path] = True 
     39                return True 
     40            else: 
     41                self.playable_cache[full_path] = False 
     42                return False  
     43 
    2844        def media_data(file): 
    2945            dict = {} 
     
    3248            file = os.path.join(path, file) 
    3349 
     50            if file in self.media_data_cache: 
     51                return self.media_data_cache[file] 
     52         
    3453            if isdir(file) or not eyeD3.isMp3File(file): 
     54                self.media_data_cache[file] = dict 
    3555                return dict 
    36              
     56 
    3757            try: 
    3858                audioFile = eyeD3.Mp3AudioFile(file) 
     
    5171                pass 
    5272             
     73            self.media_data_cache[file] = dict 
    5374            return dict 
    5475             
     
    5778        t = Template(file=os.path.join(SCRIPTDIR,'templates', 'container.tmpl')) 
    5879        t.name = subcname 
    59         t.files, t.total, t.start = self.get_files(handler, query, lambda f: isdir(f) or eyeD3.isMp3File(os.path.join(path, f))
     80        t.files, t.total, t.start = self.get_files(handler, query, AudioFileFilter
    6081        t.files = map(media_data, t.files) 
    6182        t.isdir = isdir 
  • plugins/video/video.py

    r11a926a r65ec512  
    55from urlparse import urlparse 
    66from xml.sax.saxutils import escape 
     7from lrucache import LRUCache 
    78 
    89SCRIPTDIR = os.path.dirname(__file__) 
     
    1213     
    1314    content_type = 'x-container/tivo-videos' 
    14     playable_cache = {} 
     15    playable_cache = LRUCache(1000) 
    1516 
    1617    def SendFile(self, handler, container, name): 
     
    4748            full_path = os.path.join(path, file) 
    4849 
    49             if self.playable_cache.has_key(full_path)
     50            if full_path in self.playable_cache
    5051                return self.playable_cache[full_path] 
    5152            if os.path.isdir(full_path) or transcode.suported_format(full_path):