diff --git a/addon.xml b/addon.xml index 05ba157..4fe3f5b 100644 --- a/addon.xml +++ b/addon.xml @@ -1,5 +1,5 @@ - + diff --git a/lib/dbutils/dbutils.py b/lib/dbutils/dbutils.py index b1e6811..cf9af1a 100644 --- a/lib/dbutils/dbutils.py +++ b/lib/dbutils/dbutils.py @@ -59,10 +59,11 @@ class SQLiteDatabase(object): except sql.Error as e: print("SQLite error %s"%e.args[0]) except ValueError: - print("Error query %s"%str(query)) - print("Error query type %s"%type(query)) - print("Error params %s"%str(params)) - print("Error params type %s"%type(params)) + pass + #print("Error query %s"%str(query)) + #print("Error query type %s"%type(query)) + #print("Error params %s"%str(params)) + #print("Error params type %s"%type(params)) def get_record_age(self, artist_id): try: diff --git a/main.py b/main.py index e0fbac2..138d2bd 100644 --- a/main.py +++ b/main.py @@ -755,18 +755,19 @@ def get_entry_playlist(item,params): def get_image(item): db = get_db() + image = None try: - image = db.get_value(item.get('id'), 'wikipedia_image')[0][0] + if Addon().get_setting('enhanced_info'): + 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 + return image def get_artist_info(artist_id, forced=False): db = get_db() @@ -774,15 +775,18 @@ def get_artist_info(artist_id, forced=False): print("Retreiving artist info for id: %s"%(artist_id)) #popup("Updating artist info\nplease wait") try: - artist_info = db.get_value(artist_id, 'artist_info')[0][0] - artist_wiki = db.get_value(artist_id, 'wikipedia_extract')[0][0] - #plugin.log("Artist info: %s"%artist_info) - #plugin.log("Artist wiki: %s"%artist_wiki) - #plugin.log("Len Artist info: %s"%len(artist_info)) - #plugin.log("Len Artist wiki: %s"%len(artist_wiki)) - if(len(artist_info)<10): - print("Using wiki data") - artist_info = artist_wiki + if Addon().get_setting('enhanced_info'): + artist_info = db.get_value(artist_id, 'artist_info')[0][0] + artist_wiki = db.get_value(artist_id, 'wikipedia_extract')[0][0] + #plugin.log("Artist info: %s"%artist_info) + #plugin.log("Artist wiki: %s"%artist_wiki) + #plugin.log("Len Artist info: %s"%len(artist_info)) + #plugin.log("Len Artist wiki: %s"%len(artist_wiki)) + if(len(artist_info)<10): + print("Using wiki data") + artist_info = artist_wiki + else: + return "" if(artist_info is None): print("artist_info is None making empty string") artist_info = "" diff --git a/service.py b/service.py index bc141e4..8d2248a 100644 --- a/service.py +++ b/service.py @@ -80,11 +80,11 @@ def get_db(): global db global db_filename db_path = os.path.join(plugin.profile_dir, db_filename) - print("Getting DB %s"%db_path) + plugin.log("Getting DB %s"%db_path) try: db = dbutils.SQLiteDatabase(db_path) except Exception as e: - print("Connecting to DB failed: %s"%e) + plugin.log("Connecting to DB failed: %s"%e) return db def check_artist_info(): @@ -97,9 +97,9 @@ def check_artist_info(): artist_name = db.get_value(artist_id, 'artist_name') artist_info = db.get_value(artist_id, 'artist_info') artist_wiki = db.get_value(artist_id, 'wikipedia_extract') - print("Name %s"%(artist_name)) - print("LastFM %s"%(artist_info)) - print("Wiki %s"%(artist_wiki)) + plugin.log("Name %s"%(artist_name)) + plugin.log("LastFM %s"%(artist_info)) + plugin.log("Wiki %s"%(artist_wiki)) def refresh_artist(artist_id): db = get_db() @@ -112,7 +112,7 @@ def refresh_artist(artist_id): artist_info = artist_info['artistInfo2']['biography'] #pattern = 'Read more on Last.fm artist_info = re.sub('', '', artist_info) - print("subbed: %s"%artist_info) + plugin.log("subbed: %s"%artist_info) except: artist_info = "" mb_artist_id = mb.get_artist_id(artist_name) @@ -137,7 +137,7 @@ def check_db_status(forced=False): try: if(time.time()-check_freq > last_db_check) or forced: #popup("DB Check Starting") - xbmc.log("DB check starting %s %s" % (time.time(), last_db_check), xbmc.LOGINFO) + plugin.log("DB check starting %s %s" % (time.time(), last_db_check)) db = get_db() connection = get_connection() response = connection.getArtists() @@ -146,13 +146,13 @@ 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("Record age %s vs %s for %s"%(record_age, (random.randint(1,111)*refresh_age), artist_id)) + #plugin.log("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) 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) + plugin.log("DB rcheck failed %s"%e) return @@ -174,7 +174,7 @@ def check_player_status(): else: pass except IndexError: - print ("Not a Subsonic track") + plugin.log ("Not a Subsonic track") scrobbled = True except Exception as e: xbmc.log("Subsonic scrobble check failed %e"%e, xbmc.LOGINFO) @@ -207,4 +207,4 @@ if __name__ == '__main__': check_player_status() check_db_status() else: - xbmc.log("Subsonic service not started due to settings", xbmc.LOGINFO) + plugin.log("Subsonic service not started due to settings")