Changeset a0bb213a2bf17582d50549a14fabeeca44ab24dc
- Timestamp:
- 12/30/07 00:27:01 (1 year ago)
- git-parent:
- Files:
-
- plugin.py (modified) (2 diffs)
- plugins/music/music.py (modified) (1 diff)
- plugins/photo/photo.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugin.py
r22be2e4 ra0bb213 61 61 def item_count(self, handler, query, cname, files): 62 62 """Return only the desired portion of the list, as specified by 63 ItemCount, AnchorItem and AnchorOffset 63 ItemCount, AnchorItem and AnchorOffset. 'files' is either a 64 list of strings, OR a list of objects with a 'name' attribute. 64 65 """ 65 66 totalFiles = len(files) … … 80 81 anchor = os.path.normpath(anchor) 81 82 83 if type(files[0]) == str: 84 filenames = files 85 else: 86 filenames = [x.name for x in files] 82 87 try: 83 index = file s.index(anchor)88 index = filenames.index(anchor) 84 89 except ValueError: 85 90 print 'Anchor not found:', anchor # just use index = 0 plugins/music/music.py
r6c43706 ra0bb213 171 171 handler.end_headers() 172 172 handler.wfile.write(page) 173 174 def item_count(self, handler, query, cname, files):175 """Return only the desired portion of the list, as specified by176 ItemCount, AnchorItem and AnchorOffset177 """178 totalFiles = len(files)179 index = 0180 181 if query.has_key('ItemCount'):182 count = int(query['ItemCount'][0])183 184 if query.has_key('AnchorItem'):185 bs = '/TiVoConnect?Command=QueryContainer&Container='186 local_base_path = self.get_local_base_path(handler, query)187 188 anchor = query['AnchorItem'][0]189 if anchor.startswith(bs):190 anchor = anchor.replace(bs, '/')191 anchor = unquote(anchor)192 anchor = anchor.replace(os.path.sep + cname, local_base_path)193 anchor = os.path.normpath(anchor)194 195 filenames = [x.name for x in files]196 try:197 index = filenames.index(anchor)198 except ValueError:199 print 'Anchor not found:', anchor # just use index = 0200 201 if count > 0:202 index += 1203 204 if query.has_key('AnchorOffset'):205 index += int(query['AnchorOffset'][0])206 207 #foward count208 if count > 0:209 files = files[index:index + count]210 #backwards count211 elif count < 0:212 if index + count < 0:213 count = -index214 files = files[index + count:index]215 index += count216 217 else: # No AnchorItem218 219 if count >= 0:220 files = files[:count]221 elif count < 0:222 index = count % len(files)223 files = files[count:]224 225 return files, totalFiles, index226 173 227 174 def get_files(self, handler, query, filterFunction=None): plugins/photo/photo.py
r052b7c8 ra0bb213 305 305 handler.wfile.write(page) 306 306 307 def item_count(self, handler, query, cname, files):308 """Return only the desired portion of the list, as specified by309 ItemCount, AnchorItem and AnchorOffset310 """311 totalFiles = len(files)312 index = 0313 314 if query.has_key('ItemCount'):315 count = int(query['ItemCount'][0])316 317 if query.has_key('AnchorItem'):318 bs = '/TiVoConnect?Command=QueryContainer&Container='319 local_base_path = self.get_local_base_path(handler, query)320 321 anchor = query['AnchorItem'][0]322 if anchor.startswith(bs):323 anchor = anchor.replace(bs, '/')324 anchor = unquote(anchor)325 anchor = anchor.replace(os.path.sep + cname, local_base_path)326 anchor = os.path.normpath(anchor)327 328 filenames = [x.name for x in files]329 try:330 index = filenames.index(anchor)331 except ValueError:332 pass # anchor not found, just use index = 0333 334 if count > 0:335 index += 1336 337 if query.has_key('AnchorOffset'):338 index += int(query['AnchorOffset'][0])339 340 #foward count341 if count > 0:342 files = files[index:index + count]343 #backwards count344 elif count < 0:345 if index + count < 0:346 count = -index347 files = files[index + count:index]348 index += count349 350 else: # No AnchorItem351 352 if count >= 0:353 files = files[:count]354 elif count < 0:355 index = count % len(files)356 files = files[count:]357 358 return files, totalFiles, index359 360 307 def get_files(self, handler, query, filterFunction): 361 308
