Changeset 65ec512fb94a11243e34f62a7c9d7fe282080802
- 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
| r29ad0eb |
r65ec512 |
|
| 53 | 53 | #Dispatch to the container plugin |
|---|
| 54 | 54 | for name, container in self.server.containers.items(): |
|---|
| 55 | | print name, query['Container'][0] |
|---|
| 56 | 55 | if query['Container'][0].startswith(name): |
|---|
| 57 | 56 | plugin = GetPlugin(container['type']) |
|---|
| r11a926a |
r65ec512 |
|
| 113 | 113 | index = index + int(query['AnchorOffset'][0]) |
|---|
| 114 | 114 | |
|---|
| | 115 | #foward count |
|---|
| 115 | 116 | if index < index + count: |
|---|
| 116 | | files = files[max(index, 0):index + count ] |
|---|
| | 117 | files = files[index:index + count ] |
|---|
| 117 | 118 | return files, totalFiles, index |
|---|
| | 119 | #backwards count |
|---|
| 118 | 120 | 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] |
|---|
| 120 | 129 | return files, totalFiles, index + count |
|---|
| rf08eb75 |
r65ec512 |
|
| 4 | 4 | from urllib import unquote_plus, quote, unquote |
|---|
| 5 | 5 | from xml.sax.saxutils import escape |
|---|
| | 6 | from lrucache import LRUCache |
|---|
| 6 | 7 | import eyeD3 |
|---|
| 7 | 8 | |
|---|
| … | … | |
| 11 | 12 | |
|---|
| 12 | 13 | content_type = 'x-container/tivo-music' |
|---|
| | 14 | playable_cache = {} |
|---|
| | 15 | playable_cache = LRUCache(1000) |
|---|
| | 16 | media_data_cache = LRUCache(100) |
|---|
| 13 | 17 | |
|---|
| 14 | 18 | def QueryContainer(self, handler, query): |
|---|
| … | … | |
| 26 | 30 | return os.path.isdir(os.path.join(path, file)) |
|---|
| 27 | 31 | |
|---|
| | 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 | |
|---|
| 28 | 44 | def media_data(file): |
|---|
| 29 | 45 | dict = {} |
|---|
| … | … | |
| 32 | 48 | file = os.path.join(path, file) |
|---|
| 33 | 49 | |
|---|
| | 50 | if file in self.media_data_cache: |
|---|
| | 51 | return self.media_data_cache[file] |
|---|
| | 52 | |
|---|
| 34 | 53 | if isdir(file) or not eyeD3.isMp3File(file): |
|---|
| | 54 | self.media_data_cache[file] = dict |
|---|
| 35 | 55 | return dict |
|---|
| 36 | | |
|---|
| | 56 | |
|---|
| 37 | 57 | try: |
|---|
| 38 | 58 | audioFile = eyeD3.Mp3AudioFile(file) |
|---|
| … | … | |
| 51 | 71 | pass |
|---|
| 52 | 72 | |
|---|
| | 73 | self.media_data_cache[file] = dict |
|---|
| 53 | 74 | return dict |
|---|
| 54 | 75 | |
|---|
| … | … | |
| 57 | 78 | t = Template(file=os.path.join(SCRIPTDIR,'templates', 'container.tmpl')) |
|---|
| 58 | 79 | 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) |
|---|
| 60 | 81 | t.files = map(media_data, t.files) |
|---|
| 61 | 82 | t.isdir = isdir |
|---|
| r11a926a |
r65ec512 |
|
| 5 | 5 | from urlparse import urlparse |
|---|
| 6 | 6 | from xml.sax.saxutils import escape |
|---|
| | 7 | from lrucache import LRUCache |
|---|
| 7 | 8 | |
|---|
| 8 | 9 | SCRIPTDIR = os.path.dirname(__file__) |
|---|
| … | … | |
| 12 | 13 | |
|---|
| 13 | 14 | content_type = 'x-container/tivo-videos' |
|---|
| 14 | | playable_cache = {} |
|---|
| | 15 | playable_cache = LRUCache(1000) |
|---|
| 15 | 16 | |
|---|
| 16 | 17 | def SendFile(self, handler, container, name): |
|---|
| … | … | |
| 47 | 48 | full_path = os.path.join(path, file) |
|---|
| 48 | 49 | |
|---|
| 49 | | if self.playable_cache.has_key(full_path): |
|---|
| | 50 | if full_path in self.playable_cache: |
|---|
| 50 | 51 | return self.playable_cache[full_path] |
|---|
| 51 | 52 | if os.path.isdir(full_path) or transcode.suported_format(full_path): |
|---|