[gnome-music] albumartcache: Improve album name retrieval



commit 5d67f3a57ed20df7f62ccfad21cb1ae7eb48b54e
Author: Marinus Schraal <mschraal src gnome org>
Date:   Tue Oct 11 11:45:10 2016 +0200

    albumartcache: Improve album name retrieval
    
    For individual songs we were using the songtitle as art lookup trigger,
    use the album instead. This fixes albumart missing or incorrectly
    showing in the playerbar.

 gnomemusic/albumartcache.py |    4 ++--
 gnomemusic/utils.py         |   19 +++++++++++++++++++
 2 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/gnomemusic/albumartcache.py b/gnomemusic/albumartcache.py
index 286f16c..3064152 100644
--- a/gnomemusic/albumartcache.py
+++ b/gnomemusic/albumartcache.py
@@ -220,7 +220,7 @@ class AlbumArtCache(GObject.GObject):
     def _lookup_local(self, item, callback, itr, art_size):
         """Checks if there is already a local art file, if not calls
         the remote lookup function"""
-        album = utils.get_media_title(item)
+        album = utils.get_album_title(item)
         artist = utils.get_artist_name(item)
 
         def stream_open(thumb_file, result, arguments):
@@ -286,7 +286,7 @@ class AlbumArtCache(GObject.GObject):
         Lookup remote art through Grilo and if found copy locally. Call
         _lookup_local to finish retrieving suitable art.
         """
-        album = utils.get_media_title(item)
+        album = utils.get_album_title(item)
         artist = utils.get_artist_name(item)
 
         @log
diff --git a/gnomemusic/utils.py b/gnomemusic/utils.py
index 0faa42c..997a926 100644
--- a/gnomemusic/utils.py
+++ b/gnomemusic/utils.py
@@ -25,6 +25,25 @@
 from gettext import gettext as _
 
 
+def get_album_title(item):
+    """Returns the album title associated with the media item
+
+    In case of an audio file the get_album call returns the
+    album title and in case of a container we are looking for
+    the title.
+
+    :param item: A Grilo Media object
+    :return: The album title
+    :rtype: string
+    """
+    album = item.get_album()
+
+    if not album:
+        album = get_media_title(item)
+
+    return album
+
+
 def get_artist_name(item):
     """Returns the preferred artist for a media item.
 


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