home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 February / PCWFEB08.iso / Software / Freeware / Miro 1.0 / Miro_Installer.exe / xulrunner / python / indexes.py < prev    next >
Encoding:
Python Source  |  2007-11-12  |  2.3 KB  |  89 lines

  1. # Miro - an RSS based video player application
  2. # Copyright (C) 2005-2007 Participatory Culture Foundation
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  17.  
  18. import app
  19. import item
  20. import folder
  21. import feed
  22. import guide
  23. import tabs
  24.  
  25. def itemsByFeed(x):
  26.     # This specifically sorts subitems by their parent's feed.
  27.     return x.getFeed().getID()
  28.  
  29. def itemsByChannelFolder(x):
  30.     return x.getFeed().getFolder()
  31.  
  32. def itemsByParent(x):
  33.     return x.parent_id
  34.  
  35. def feedsByURL(x):
  36.     return x.getOriginalURL()
  37.  
  38. def guidesByURL(x):
  39.     return x.getURL()
  40.  
  41. def downloadsByDLID(x):
  42.     return str(x.dlid)
  43.  
  44. def downloadsByURL(x):
  45.     return x.origURL.encode('ascii', 'replace')
  46.  
  47. # Returns the class of the object, aggregating all Item subtypes under Item
  48. def objectsByClass(x):
  49.     if isinstance(x,item.Item):
  50.         return item.Item
  51.     else:
  52.         return x.__class__
  53.  
  54. def itemsByState(x):
  55.     return x.getState()
  56.  
  57. def itemsByChannelCategory(x):
  58.     return x.getChannelCategory()
  59.  
  60. def downloadsByCategory(x):
  61.     """Splits downloading items into 3 categories:
  62.         normal -- not pending or external
  63.         pending  -- pending manual downloads
  64.         external -- external torrents
  65.     """
  66.     if x.getFeed().url == 'dtv:manualFeed':
  67.         return 'external'
  68.     elif x.isPendingManualDownload():
  69.         return 'pending'
  70.     else:
  71.         return 'normal'
  72.  
  73. def playlistsByItemID(playlist):
  74.     return playlist.item_ids
  75.  
  76. def playlistsByItemAndFolderID(playlist):
  77.     return [(id, playlist.folder_id) for id in playlist.item_ids]
  78.  
  79. def tabType(tab):
  80.     return tab.type
  81.  
  82. def tabOrderType(tabOrder):
  83.     return tabOrder.type
  84.  
  85. def byFolder(obj):
  86.     return obj.getFolder()
  87.  
  88. def foldersByTitle(obj):
  89.     return obj.title