[rhythmbox] artdisplay: use album artist in preference to track artist where available
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] artdisplay: use album artist in preference to track artist where available
- Date: Fri, 11 Jun 2010 05:37:14 +0000 (UTC)
commit b36da7822db0b95ce61b4e5b7c170416f8f86fa2
Author: Jonathan Matthew <jonathan d14n org>
Date: Fri Jun 11 15:36:52 2010 +1000
artdisplay: use album artist in preference to track artist where available
plugins/artdisplay/artdisplay/CoverArtDatabase.py | 23 +++++++++++--------
.../artdisplay/artdisplay/LastFMCoverArtSearch.py | 4 ++-
.../artdisplay/artdisplay/LocalCoverArtSearch.py | 15 +++++++++---
3 files changed, 27 insertions(+), 15 deletions(-)
---
diff --git a/plugins/artdisplay/artdisplay/CoverArtDatabase.py b/plugins/artdisplay/artdisplay/CoverArtDatabase.py
index 14e6325..6c133ec 100644
--- a/plugins/artdisplay/artdisplay/CoverArtDatabase.py
+++ b/plugins/artdisplay/artdisplay/CoverArtDatabase.py
@@ -107,6 +107,13 @@ class TicketSystem:
self.dead.remove (ticket)
return False
+def get_search_props(db, entry):
+ artist = db.entry_get(entry, rhythmdb.PROP_ALBUM_ARTIST)
+ if artist == "":
+ artist = db.entry_get(entry, rhythmdb.PROP_ARTIST)
+ album = db.entry_get(entry, rhythmdb.PROP_ALBUM)
+ return (artist, album)
+
class CoverArtDatabase (object):
def __init__ (self):
@@ -114,8 +121,7 @@ class CoverArtDatabase (object):
self.same_search = {}
def build_art_cache_filename (self, db, entry, extension):
- artist = db.entry_get (entry, rhythmdb.PROP_ARTIST)
- album = db.entry_get (entry, rhythmdb.PROP_ALBUM)
+ artist, album = get_search_props(db, entry)
art_folder = os.path.expanduser (ART_FOLDER)
old_art_folder = os.path.expanduser (OLD_ART_FOLDER)
if not os.path.exists (art_folder) and os.path.exists (old_art_folder):
@@ -175,9 +181,8 @@ class CoverArtDatabase (object):
if entry is None:
callback (entry, None, None, None, None)
return
-
- st_artist = db.entry_get (entry, rhythmdb.PROP_ARTIST) or _("Unknown")
- st_album = db.entry_get (entry, rhythmdb.PROP_ALBUM) or _("Unknown")
+
+ st_artist, st_album = get_search_props(db, entry)
# replace quote characters
# don't replace single quote: could be important punctuation
@@ -210,11 +215,9 @@ class CoverArtDatabase (object):
# Check if we're already searching for art for this album
# (this won't work for compilations, but there isn't much we can do about that)
def find_same_search(a, b, db):
- for prop in (rhythmdb.PROP_ARTIST, rhythmdb.PROP_ALBUM):
- if db.entry_get(a, prop) != db.entry_get(b, prop):
- return False
-
- return True
+ a_artist, a_album = get_search_props(db, a)
+ b_artist, b_album = get_search_props(db, b)
+ return (a_artist == b_artist) and (a_album == b_album)
match_entry = self.ticket.find(entry, find_same_search, db)
if match_entry is not None:
diff --git a/plugins/artdisplay/artdisplay/LastFMCoverArtSearch.py b/plugins/artdisplay/artdisplay/LastFMCoverArtSearch.py
index 9a2d65c..36adea2 100644
--- a/plugins/artdisplay/artdisplay/LastFMCoverArtSearch.py
+++ b/plugins/artdisplay/artdisplay/LastFMCoverArtSearch.py
@@ -122,7 +122,9 @@ class LastFMCoverArtSearch (object):
callback (self, entry, None, *args)
return
- artist = db.entry_get (entry, rhythmdb.PROP_ARTIST)
+ artist = db.entry_get (entry, rhythmdb.PROP_ALBUM_ARTIST)
+ if artist == "":
+ artist = db.entry_get (entry, rhythmdb.PROP_ARTIST)
if artist == _("Unknown"):
artist = ""
diff --git a/plugins/artdisplay/artdisplay/LocalCoverArtSearch.py b/plugins/artdisplay/artdisplay/LocalCoverArtSearch.py
index 389070d..4c710d9 100644
--- a/plugins/artdisplay/artdisplay/LocalCoverArtSearch.py
+++ b/plugins/artdisplay/artdisplay/LocalCoverArtSearch.py
@@ -48,6 +48,13 @@ def shared_prefix_length (a, b):
l = l+1
return l
+def get_search_props(db, entry):
+ artist = db.entry_get(entry, rhythmdb.PROP_ALBUM_ARTIST)
+ if artist == "":
+ artist = db.entry_get(entry, rhythmdb.PROP_ARTIST)
+ album = db.entry_get(entry, rhythmdb.PROP_ALBUM)
+ return (artist, album)
+
class LocalCoverArtSearch:
def __init__ (self):
@@ -93,8 +100,7 @@ class LocalCoverArtSearch:
on_search_completed_cb (self, entry, [], *args)
return
- self.artist = db.entry_get (entry, rhythmdb.PROP_ARTIST)
- self.album = db.entry_get (entry, rhythmdb.PROP_ALBUM)
+ self.artist, self.album = get_search_props(db, entry)
print 'searching for local art for %s' % (self.file.get_uri())
parent = self.file.get_parent()
@@ -156,7 +162,8 @@ class LocalCoverArtSearch:
file.replace_async(replace_cb, user_data=pixbuf())
def _save_dir_cb (self, enum, result, (db, entry, dir, pixbuf)):
- artist, album = [db.entry_get (entry, x) for x in [rhythmdb.PROP_ARTIST, rhythmdb.PROP_ALBUM]]
+ artist, album = get_search_props(db, entry)
+
try:
files = enum.next_files_finish(result)
if len(files) == 0:
@@ -174,7 +181,7 @@ class LocalCoverArtSearch:
uri = dir.resolve_relative_path(f.get_name()).get_uri()
u_entry = db.entry_lookup_by_location (uri)
if u_entry:
- u_artist, u_album = [db.entry_get (u_entry, x) for x in [rhythmdb.PROP_ARTIST, rhythmdb.PROP_ALBUM]]
+ u_artist, u_album = get_search_props(db, u_entry)
if album != u_album:
print "Not saving local art; encountered media with different album (%s, %s, %s)" % (uri, u_artist, u_album)
enum.close()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]