Added image grab from wikipedia - artist level only

This commit is contained in:
warwickh 2021-09-18 10:05:27 +10:00
parent 40d4ac737a
commit ade19135a3
2 changed files with 20 additions and 5 deletions

20
main.py
View File

@ -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)

View File

@ -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)