Allow disable in main.py

This commit is contained in:
warwickh 2021-09-18 11:07:43 +10:00
parent ade19135a3
commit 1b708bdbb1
4 changed files with 33 additions and 28 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.audio.subsonic" name="Subsonic" version="3.0.1" provider-name="BasilFX,grosbouff,silascutler,Heruwar,warwickh">
<addon id="plugin.audio.subsonic" name="Subsonic" version="3.0.1" provider-name="BasilFX,warwickh">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="script.module.dateutil" version="2.4.2"/>

View File

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

View File

@ -755,18 +755,19 @@ def get_entry_playlist(item,params):
def get_image(item):
db = get_db()
image = None
try:
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,6 +775,7 @@ def get_artist_info(artist_id, forced=False):
print("Retreiving artist info for id: %s"%(artist_id))
#popup("Updating artist info\nplease wait")
try:
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)
@ -783,6 +785,8 @@ def get_artist_info(artist_id, forced=False):
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 = ""

View File

@ -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 = '<a target=\'_blank\' href="https://www.last.fm/music/Afrojack">Read more on Last.fm</a>
artist_info = re.sub('<a.*?</a>', '', 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")