[gnome-music/wip/libmediaart] Port to libmediaart



commit 83f815980270c0651b5ad64d13c117c15110d463
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date:   Tue Apr 1 23:18:27 2014 +0200

    Port to libmediaart

 configure.ac                |    1 +
 gnomemusic/albumArtCache.py |   20 +++++---------------
 2 files changed, 6 insertions(+), 15 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index bc14ca4..662b786 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,6 +33,7 @@ GLIB_GSETTINGS
 GOBJECT_INTROSPECTION_REQUIRE([1.35.9])
 PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= 3.8])
 PKG_CHECK_EXISTS([gtk+-3.0 >= 3.9.0], [GTK_OR_GD=Gtk], [GTK_OR_GD=Gd])
+PKG_CHECK_MODULES(MEDIAART, [libmediaart-1.0], HAVE_MEDIAART=yes, HAVE_MEDIAART=no)
 AC_SUBST(GTK_OR_GD)
 
 GLIB_COMPILE_RESOURCES=`$PKG_CONFIG --variable glib_compile_resources gio-2.0`
diff --git a/gnomemusic/albumArtCache.py b/gnomemusic/albumArtCache.py
index 89abedc..8b1cfd0 100644
--- a/gnomemusic/albumArtCache.py
+++ b/gnomemusic/albumArtCache.py
@@ -28,7 +28,7 @@
 # delete this exception statement from your version.
 
 
-from gi.repository import Gtk, GdkPixbuf, Gio, GLib, Grl, Gdk
+from gi.repository import Gtk, GdkPixbuf, Gio, GLib, Grl, Gdk, MediaArt
 from gettext import gettext as _
 import cairo
 from math import pi
@@ -46,11 +46,10 @@ class LookupRequest:
         self.callback = callback
         self.data = data
         self.path = ''
-        self.key = ''
         self.key_index = 0
         self.icon_format = 'jpeg'
-        self.artist = item.get_string(Grl.METADATA_KEY_ARTIST) or item.get_string(Grl.METADATA_KEY_AUTHOR)
-        self.album = item.get_string(Grl.METADATA_KEY_ALBUM)
+        self.artist = item.get_string(Grl.METADATA_KEY_ARTIST) or item.get_string(Grl.METADATA_KEY_AUTHOR) 
or ''
+        self.album = item.get_string(Grl.METADATA_KEY_ALBUM) or ''
         self.started = False
 
     def start(self):
@@ -72,8 +71,7 @@ class LookupRequest:
                 self._on_try_load_finished(None)
                 return
 
-        self.key = AlbumArtCache.get_default()._keybuilder_funcs[self.key_index].__call__(self.artist, 
self.album)
-        self.path = GLib.build_filenamev([AlbumArtCache.get_default().cacheDir, '%s.%s' % (self.key, 
self.icon_format)])
+        self.path = MediaArt.get_path(self.artist, self.album, "album", None)[0]
         f = Gio.File.new_for_path(self.path)
 
         f.read_async(GLib.PRIORITY_DEFAULT, None, self._on_read_ready, None)
@@ -146,8 +144,7 @@ class GetUriRequest:
         self.data = data
         self.callbacks = []
         self.path = ''
-        self.key = AlbumArtCache.get_default()._keybuilder_funcs[0].__call__(artist, album)
-        self.path = GLib.build_filenamev([AlbumArtCache.get_default().cacheDir, self.key])
+        self.path = MediaArt.get_path(artist, album, "album", None)[0]
         self.stream = None
         self.started = False
 
@@ -254,13 +251,6 @@ class AlbumArtCache:
         self.frame_cache = {}
         self.frame_lock = threading.Lock()
 
-        self._keybuilder_funcs = [
-            lambda artist, album: 'album-%s-%s' % (
-                self._normalize_and_hash(artist), self._normalize_and_hash(album)),
-            lambda artist, album: 'album-%s-%s' % (
-                self._normalize_and_hash(album), self._normalize_and_hash(None))
-        ]
-
         try:
             Gio.file_new_for_path(self.cacheDir).make_directory(None)
         except:


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