[gnome-music] albumart: switch to full options if we fail to find the thumbnail



commit 5f8afde8daa6ca8f4b4ff666d7aebf97e1d66334
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date:   Wed Apr 16 15:32:22 2014 +0200

    albumart: switch to full options if we fail to find the thumbnail

 gnomemusic/albumArtCache.py |   13 +++++++++----
 gnomemusic/grilo.py         |   16 +++++++++++++---
 gnomemusic/widgets.py       |    4 +---
 3 files changed, 23 insertions(+), 10 deletions(-)
---
diff --git a/gnomemusic/albumArtCache.py b/gnomemusic/albumArtCache.py
index a61d460..abe4cb6 100644
--- a/gnomemusic/albumArtCache.py
+++ b/gnomemusic/albumArtCache.py
@@ -36,6 +36,7 @@ import os
 from threading import Thread
 from queue import Queue, Empty
 from gnomemusic import log
+from gnomemusic.grilo import grilo
 import logging
 logger = logging.getLogger(__name__)
 
@@ -116,7 +117,7 @@ class AlbumArtCache:
             self.cacheDir = os.path.join(GLib.get_user_cache_dir(), 'media-art')
             Gio.file_new_for_path(self.cacheDir).make_directory(None)
         except:
-            logger.warn("Cannot create media-art dir")
+            pass
 
         self.q = Queue()
         for i in range(self.num_worker_threads):
@@ -178,6 +179,7 @@ class AlbumArtCache:
     @log
     def finish(self, pixbuf, path, callback, itr):
         try:
+            grilo.reset_fast_options()
             callback(pixbuf, path, itr)
         except Exception as e:
             logger.warn("Error: %s" % e)
@@ -188,9 +190,12 @@ class AlbumArtCache:
         try:
             uri = item.get_thumbnail()
             if uri is None:
-                logger.warn("can't find URL for album '%s' by %s" % (album, artist))
-                self.finish(None, path, callback, itr)
-                return
+                grilo.set_full_options()
+                uri = item.get_thumbnail()
+                if uri is None:
+                    logger.warn("can't find URL for album '%s' by %s" % (album, artist))
+                    self.finish(None, path, callback, itr)
+                    return
 
             src = Gio.File.new_for_uri(uri)
             dest = Gio.File.new_for_path(path)
diff --git a/gnomemusic/grilo.py b/gnomemusic/grilo.py
index 4deaf75..db6e086 100644
--- a/gnomemusic/grilo.py
+++ b/gnomemusic/grilo.py
@@ -56,9 +56,7 @@ class Grilo(GObject.GObject):
                                                   "gnome-music", "playlists"])
         if not (GLib.file_test(self.playlist_path, GLib.FileTest.IS_DIR)):
             GLib.mkdir_with_parents(self.playlist_path, int("0755", 8))
-        self.options = Grl.OperationOptions()
-        self.options.set_flags(Grl.ResolutionFlags.FAST_ONLY |
-                               Grl.ResolutionFlags.IDLE_RELAY)
+        self.reset_fast_options()
 
         self.sources = {}
         self.tracker = None
@@ -77,6 +75,18 @@ class Grilo(GObject.GObject):
             logger.debug("tracker found")
 
     @log
+    def set_full_options(self):
+        self.options = Grl.OperationOptions()
+        self.options.set_flags(Grl.ResolutionFlags.FULL |
+                               Grl.ResolutionFlags.IDLE_RELAY)
+
+    @log
+    def reset_fast_options(self):
+        self.options = Grl.OperationOptions()
+        self.options.set_flags(Grl.ResolutionFlags.FAST_ONLY |
+                               Grl.ResolutionFlags.IDLE_RELAY)
+
+    @log
     def _on_content_changed(self, mediaSource, changedMedias, changeType, locationUnknown):
         try:
             for media in changedMedias:
diff --git a/gnomemusic/widgets.py b/gnomemusic/widgets.py
index 71a72ea..411b48f 100644
--- a/gnomemusic/widgets.py
+++ b/gnomemusic/widgets.py
@@ -228,9 +228,7 @@ class AlbumWidget(Gtk.EventBox):
         self.selection_toolbar = selection_toolbar
         self.header_bar = header_bar
         self.album = album
-        self.ui.get_object('cover').set_from_pixbuf(self.symbolicIcon)
-        ALBUM_ART_CACHE.lookup(item, 256, 256,
-                               self._on_look_up)
+        ALBUM_ART_CACHE.lookup(item, 256, 256, self._on_look_up, None, artist, album)
 
         # if the active queue has been set by self album,
         # use it as model, otherwise build the liststore


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