home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / rhythmbox / plugins / artdisplay / PodcastCoverArtSearch.py < prev    next >
Encoding:
Python Source  |  2009-04-07  |  2.2 KB  |  61 lines

  1. # -*- Mode: python; coding: utf-8; tab-width: 8; indent-tabs-mode: t; -*- 
  2. #
  3. # Copyright (C) 2006 - Martin Szulecki
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2, or (at your option)
  8. # any later version.
  9. #
  10. # The Rhythmbox authors hereby grant permission for non-GPL compatible
  11. # GStreamer plugins to be used and distributed together with GStreamer
  12. # and Rhythmbox. This permission is above and beyond the permissions granted
  13. # by the GPL license by which Rhythmbox is covered. If you modify this code
  14. # you may extend this exception to your version of the code, but you are not
  15. # obligated to do so. If you do not wish to do so, delete this exception
  16. # statement from your version.
  17. # This program is distributed in the hope that it will be useful,
  18. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. # GNU General Public License for more details.
  21. #
  22. # You should have received a copy of the GNU General Public License
  23. # along with this program; if not, write to the Free Software
  24. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA.
  25.  
  26. import rhythmdb
  27.  
  28. class PodcastCoverArtSearch (object):
  29.     def __init__ (self):
  30.         self.searching = False
  31.         self.cancel = False
  32.         self.entry = None
  33.  
  34.     def search (self, db, entry, on_search_completed_callback, *args):
  35.         self.searching = True
  36.         self.cancel = False
  37.         self.entry = entry
  38.         self.args = args
  39.  
  40.         # Check if entry is a podcast for performance
  41.         if entry.get_entry_type() != db.entry_type_get_by_name("podcast-post"):
  42.             on_search_completed_callback (self, self.entry, None, *self.args)
  43.             return
  44.  
  45.         # Retrieve corresponding feed for this entry
  46.         podcast_location = db.entry_get(entry, rhythmdb.PROP_SUBTITLE)
  47.         podcast_feed_entry = db.entry_lookup_by_location(podcast_location)
  48.  
  49.         # Check for PROP_IMAGE in feed
  50.         image_url = db.entry_get(podcast_feed_entry, rhythmdb.PROP_IMAGE)
  51.         
  52.         on_search_completed_callback (self, self.entry, image_url, *self.args)
  53.  
  54.     def search_next (self):
  55.         return False
  56.  
  57.     def get_best_match_urls (self, search_results):
  58.         # Return image URL
  59.         return [search_results]
  60.