From 5117218f860dedc635f37656a934f8b787c6595c Mon Sep 17 00:00:00 2001 From: gordielachance Date: Tue, 4 Oct 2016 14:57:24 +0200 Subject: [PATCH] hide artist in lists if it is unique --- main.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 705452e..96264fe 100644 --- a/main.py +++ b/main.py @@ -339,7 +339,15 @@ def list_albums(params): plugin.log('list_albums with args:' + query_args_json); #Get items - items = connection.walk_albums(**query_args) + generator = connection.walk_albums(**query_args) + + #make a list out of the generator so we can iterate it several times + items = list(generator) + + #check if there is only one artist for this album (and then hide it) + artists = [item.get('artist',None) for item in items] + if len(artists) <= 1: + params['hide_artist'] = True # Iterate through items for item in items: @@ -578,6 +586,11 @@ def list_tracks(params): #make a list out of the generator so we can iterate it several times items = list(generator) + + #check if there is only one artist for this album (and then hide it) + artists = [item.get('artist',None) for item in items] + if len(artists) <= 1: + params['hide_artist'] = True #update stars if menu_id == 'tracks_starred':