From ade19135a328860eda3e147e3f19d8ef22fdef7c Mon Sep 17 00:00:00 2001 From: warwickh Date: Sat, 18 Sep 2021 10:05:27 +1000 Subject: [PATCH] Added image grab from wikipedia - artist level only --- main.py | 20 ++++++++++++++++++-- service.py | 5 ++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index bb8ecc2..e0fbac2 100644 --- a/main.py +++ b/main.py @@ -753,6 +753,21 @@ def get_entry_playlist(item,params): }} } +def get_image(item): + db = get_db() + try: + image = db.get_value(item.get('id'), 'wikipedia_image')[0][0] + print("Checking image type %s %s %s"%(item.get('id'), image, type(image))) + if (image is None) or (image =='') or (image =='None'): + connection = get_connection() + print("No good, getting from lastfm") + image = connection.getCoverArtUrl(item.get('coverArt')) + print("got %s from lastfm"%image) + #Might fall back to album art if necessary + return image + except: + return + def get_artist_info(artist_id, forced=False): db = get_db() artist_info = "" @@ -776,9 +791,10 @@ def get_artist_info(artist_id, forced=False): return artist_info def get_entry_artist(item,params): - image = connection.getCoverArtUrl(item.get('coverArt')) + image = get_image(item) artist_info = get_artist_info(item.get('id')) - if(artist_info is None or artist_info == 'None'): + #print("Checking for value %s %s"%(artist_info, type(artist_info))) + if(artist_info is None or artist_info == 'None' or artist_info == ''): artist_lbl = '%s' % (item.get('name')) else: artist_lbl = '%s - %s' % (item.get('name'),artist_info) diff --git a/service.py b/service.py index 69e9dd1..bc141e4 100644 --- a/service.py +++ b/service.py @@ -146,11 +146,10 @@ def check_db_status(forced=False): artist_id = artist['id'] record_age = db.get_record_age(artist_id) if(forced or not record_age or (record_age > (random.randint(1,111)*refresh_age))) and not refresh_single_flag: - print("If flag is True I shouldn't be here %s"% refresh_single_flag) - print("Record age %s vs %s for %s"%(record_age, (random.randint(1,111)*refresh_age), artist_id)) + #print("Record age %s vs %s for %s"%(record_age, (random.randint(1,111)*refresh_age), artist_id)) #popup("Refreshing %s" % artist_id) refresh_artist(artist_id) - refresh_single_flag = True + if(record_age>0):refresh_single_flag = True last_db_check = time.time() except Exception as e: xbmc.log("DB rcheck failed %e"%e, xbmc.LOGINFO)