[gnome-music] albumArtCache: Fix full retrieve of song items
- From: Vadim Rutkovsky <vrutkovsky src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] albumArtCache: Fix full retrieve of song items
- Date: Mon, 28 Apr 2014 13:29:23 +0000 (UTC)
commit 82ae2ddeec5a7db26a7f311fd9a924010b4edbed
Author: Arnel Borja <arnelborja src gnome org>
Date: Mon Apr 28 19:55:14 2014 +0800
albumArtCache: Fix full retrieve of song items
Check first if the item is a song before retrieving the item's thumbnail
with full options. The old code always assumes that the item is an
album. Then use a different query to retrieve the album if it is a song.
https://bugzilla.gnome.org/show_bug.cgi?id=729102
gnomemusic/albumArtCache.py | 6 +++---
gnomemusic/grilo.py | 11 +++++++++--
gnomemusic/query.py | 28 +++++++++++++++++++++++++++-
3 files changed, 39 insertions(+), 6 deletions(-)
---
diff --git a/gnomemusic/albumArtCache.py b/gnomemusic/albumArtCache.py
index 26a13e4..5e5cf4e 100644
--- a/gnomemusic/albumArtCache.py
+++ b/gnomemusic/albumArtCache.py
@@ -176,8 +176,8 @@ class AlbumArtCache:
try:
uri = item.get_thumbnail()
if uri is None:
- grilo.get_album_art_for_album_id(item.get_id(), self.album_art_for_album_id_callback,
- (item, width, height, path, callback, itr, artist, album))
+ grilo.get_album_art_for_item(item, self.album_art_for_item_callback,
+ (item, width, height, path, callback, itr, artist, album))
return
start_new_thread(self.download_worker,
@@ -186,7 +186,7 @@ class AlbumArtCache:
logger.warn("Error: %s" % e)
@log
- def album_art_for_album_id_callback(self, source, param, item, count, data, error):
+ def album_art_for_item_callback(self, source, param, item, count, data, error):
old_item, width, height, path, callback, itr, artist, album = data
try:
uri = item.get_thumbnail()
diff --git a/gnomemusic/grilo.py b/gnomemusic/grilo.py
index fffafe2..7402f7f 100644
--- a/gnomemusic/grilo.py
+++ b/gnomemusic/grilo.py
@@ -197,10 +197,17 @@ class Grilo(GObject.GObject):
self.tracker.query(query, self.METADATA_KEYS, options, _callback, None)
@log
- def get_album_art_for_album_id(self, album_id, callback, data=None):
+ def get_album_art_for_item(self, item, callback, data=None):
+ item_id = item.get_id()
+
+ query = None
+ if isinstance(item, Grl.MediaAudio):
+ query = Query.get_album_for_song_id(item_id)
+ else:
+ query = Query.get_album_for_album_id(item_id)
+
options = self.full_options.copy()
options.set_count(1)
- query = Query.get_album_for_id(album_id)
self.tracker.query(query, self.METADATA_THUMBNAIL_KEYS, options, callback, data)
diff --git a/gnomemusic/query.py b/gnomemusic/query.py
index fc8b8f3..cfc919d 100644
--- a/gnomemusic/query.py
+++ b/gnomemusic/query.py
@@ -252,7 +252,7 @@ class Query():
return query
@staticmethod
- def get_album_for_id(album_id):
+ def get_album_for_album_id(album_id):
query = """
SELECT DISTINCT
rdf:type(?album)
@@ -277,6 +277,32 @@ class Query():
return query
@staticmethod
+ def get_album_for_song_id(song_id):
+ query = """
+ SELECT DISTINCT
+ rdf:type(?album)
+ tracker:id(?album) AS id
+ (
+ SELECT
+ nmm:artistName(?artist)
+ WHERE {
+ ?album nmm:albumArtist ?artist
+ }
+ LIMIT 1
+ ) AS artist
+ nie:title(?album) AS title
+ nie:title(?album) AS album
+ WHERE {
+ ?song a nmm:MusicPiece ;
+ nmm:musicAlbum ?album .
+ FILTER (
+ tracker:id(?song) = %(song_id)s
+ )
+ }
+ """.replace("\n", " ").strip() % {'song_id': song_id}
+ return query
+
+ @staticmethod
def get_song_with_url(url):
query = '''
SELECT DISTINCT
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]