[rhythmbox] artdisplay: cache art extracted from file tags



commit 9079d6be64cce2e060ebe78ba78b868713e1a39b
Author: Jonathan Matthew <jonathan d14n org>
Date:   Fri Jun 18 11:43:18 2010 +1000

    artdisplay: cache art extracted from file tags
    
    The main reason we're doing this is so we can provide a URL for the
    image so that dbus clients can access it.

 plugins/artdisplay/artdisplay/CoverArtDatabase.py |   19 +++++++++++++------
 plugins/artdisplay/artdisplay/__init__.py         |    6 +++++-
 2 files changed, 18 insertions(+), 7 deletions(-)
---
diff --git a/plugins/artdisplay/artdisplay/CoverArtDatabase.py b/plugins/artdisplay/artdisplay/CoverArtDatabase.py
index e6adb15..e785e3a 100644
--- a/plugins/artdisplay/artdisplay/CoverArtDatabase.py
+++ b/plugins/artdisplay/artdisplay/CoverArtDatabase.py
@@ -154,6 +154,18 @@ class CoverArtDatabase (object):
 		if entry is None or pixbuf is None:
 			return
 
+		art_location_url = self.cache_pixbuf(db, entry, pixbuf)
+		callback (entry, pixbuf, art_location_url, None, None)
+		for Engine in ART_SEARCHES_LOCAL:
+			try:
+				Engine ().save_pixbuf (db, entry, pixbuf)
+			except AttributeError:
+				pass
+
+	def cache_pixbuf (self, db, entry, pixbuf):
+		if entry is None or pixbuf is None:
+			return None
+
 		meta_location = self.build_art_cache_filename (db, entry, ART_CACHE_EXTENSION_META)
 		self.write_meta_file (meta_location, None, None)
 
@@ -167,12 +179,7 @@ class CoverArtDatabase (object):
 			art_cache_settings = ART_CACHE_SETTINGS_JPG
 		self.ticket.purge (entry)
 		pixbuf.save (art_location, art_cache_format, art_cache_settings)
-		callback (entry, pixbuf, art_location, None, None)
-		for Engine in ART_SEARCHES_LOCAL:
-			try:
-				Engine ().save_pixbuf (db, entry, pixbuf)
-			except AttributeError:
-				pass
+		return "file://" + pathname2url(art_location)
 
 	def cancel_get_pixbuf (self, entry):
 		self.ticket.purge (entry)
diff --git a/plugins/artdisplay/artdisplay/__init__.py b/plugins/artdisplay/artdisplay/__init__.py
index 13356bb..d047c1a 100644
--- a/plugins/artdisplay/artdisplay/__init__.py
+++ b/plugins/artdisplay/artdisplay/__init__.py
@@ -461,7 +461,11 @@ class ArtDisplayPlugin (rb.Plugin):
 		self.art_db.cancel_get_pixbuf (entry)
 		if self.current_pixbuf == metadata:
 			return
-		self.art_widget.set (entry, metadata, None, None, None, False)
+
+		# cache the pixbuf so we can provide a url
+		uri = self.art_db.cache_pixbuf (db, entry, metadata)
+		self.art_widget.set (entry, metadata, uri, None, None, False)
+		db.emit_entry_extra_metadata_notify (entry, "rb:coverArt-uri", uri)
 
 	def cover_art_uri_notify (self, db, entry, field, metadata):
 		if entry != self.current_entry:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]