Allow disable in main.py
This commit is contained in:
parent
ade19135a3
commit
1b708bdbb1
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?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>
|
<requires>
|
||||||
<import addon="xbmc.python" version="3.0.0"/>
|
<import addon="xbmc.python" version="3.0.0"/>
|
||||||
<import addon="script.module.dateutil" version="2.4.2"/>
|
<import addon="script.module.dateutil" version="2.4.2"/>
|
||||||
|
|
|
@ -59,10 +59,11 @@ class SQLiteDatabase(object):
|
||||||
except sql.Error as e:
|
except sql.Error as e:
|
||||||
print("SQLite error %s"%e.args[0])
|
print("SQLite error %s"%e.args[0])
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print("Error query %s"%str(query))
|
pass
|
||||||
print("Error query type %s"%type(query))
|
#print("Error query %s"%str(query))
|
||||||
print("Error params %s"%str(params))
|
#print("Error query type %s"%type(query))
|
||||||
print("Error params type %s"%type(params))
|
#print("Error params %s"%str(params))
|
||||||
|
#print("Error params type %s"%type(params))
|
||||||
|
|
||||||
def get_record_age(self, artist_id):
|
def get_record_age(self, artist_id):
|
||||||
try:
|
try:
|
||||||
|
|
28
main.py
28
main.py
|
@ -755,18 +755,19 @@ def get_entry_playlist(item,params):
|
||||||
|
|
||||||
def get_image(item):
|
def get_image(item):
|
||||||
db = get_db()
|
db = get_db()
|
||||||
|
image = None
|
||||||
try:
|
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)))
|
print("Checking image type %s %s %s"%(item.get('id'), image, type(image)))
|
||||||
if (image is None) or (image =='') or (image =='None'):
|
if (image is None) or (image =='') or (image =='None'):
|
||||||
connection = get_connection()
|
connection = get_connection()
|
||||||
print("No good, getting from lastfm")
|
|
||||||
image = connection.getCoverArtUrl(item.get('coverArt'))
|
image = connection.getCoverArtUrl(item.get('coverArt'))
|
||||||
print("got %s from lastfm"%image)
|
print("got %s from lastfm"%image)
|
||||||
#Might fall back to album art if necessary
|
#Might fall back to album art if necessary
|
||||||
return image
|
return image
|
||||||
except:
|
except:
|
||||||
return
|
return image
|
||||||
|
|
||||||
def get_artist_info(artist_id, forced=False):
|
def get_artist_info(artist_id, forced=False):
|
||||||
db = get_db()
|
db = get_db()
|
||||||
|
@ -774,15 +775,18 @@ def get_artist_info(artist_id, forced=False):
|
||||||
print("Retreiving artist info for id: %s"%(artist_id))
|
print("Retreiving artist info for id: %s"%(artist_id))
|
||||||
#popup("Updating artist info\nplease wait")
|
#popup("Updating artist info\nplease wait")
|
||||||
try:
|
try:
|
||||||
artist_info = db.get_value(artist_id, 'artist_info')[0][0]
|
if Addon().get_setting('enhanced_info'):
|
||||||
artist_wiki = db.get_value(artist_id, 'wikipedia_extract')[0][0]
|
artist_info = db.get_value(artist_id, 'artist_info')[0][0]
|
||||||
#plugin.log("Artist info: %s"%artist_info)
|
artist_wiki = db.get_value(artist_id, 'wikipedia_extract')[0][0]
|
||||||
#plugin.log("Artist wiki: %s"%artist_wiki)
|
#plugin.log("Artist info: %s"%artist_info)
|
||||||
#plugin.log("Len Artist info: %s"%len(artist_info))
|
#plugin.log("Artist wiki: %s"%artist_wiki)
|
||||||
#plugin.log("Len Artist wiki: %s"%len(artist_wiki))
|
#plugin.log("Len Artist info: %s"%len(artist_info))
|
||||||
if(len(artist_info)<10):
|
#plugin.log("Len Artist wiki: %s"%len(artist_wiki))
|
||||||
print("Using wiki data")
|
if(len(artist_info)<10):
|
||||||
artist_info = artist_wiki
|
print("Using wiki data")
|
||||||
|
artist_info = artist_wiki
|
||||||
|
else:
|
||||||
|
return ""
|
||||||
if(artist_info is None):
|
if(artist_info is None):
|
||||||
print("artist_info is None making empty string")
|
print("artist_info is None making empty string")
|
||||||
artist_info = ""
|
artist_info = ""
|
||||||
|
|
22
service.py
22
service.py
|
@ -80,11 +80,11 @@ def get_db():
|
||||||
global db
|
global db
|
||||||
global db_filename
|
global db_filename
|
||||||
db_path = os.path.join(plugin.profile_dir, 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:
|
try:
|
||||||
db = dbutils.SQLiteDatabase(db_path)
|
db = dbutils.SQLiteDatabase(db_path)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Connecting to DB failed: %s"%e)
|
plugin.log("Connecting to DB failed: %s"%e)
|
||||||
return db
|
return db
|
||||||
|
|
||||||
def check_artist_info():
|
def check_artist_info():
|
||||||
|
@ -97,9 +97,9 @@ def check_artist_info():
|
||||||
artist_name = db.get_value(artist_id, 'artist_name')
|
artist_name = db.get_value(artist_id, 'artist_name')
|
||||||
artist_info = db.get_value(artist_id, 'artist_info')
|
artist_info = db.get_value(artist_id, 'artist_info')
|
||||||
artist_wiki = db.get_value(artist_id, 'wikipedia_extract')
|
artist_wiki = db.get_value(artist_id, 'wikipedia_extract')
|
||||||
print("Name %s"%(artist_name))
|
plugin.log("Name %s"%(artist_name))
|
||||||
print("LastFM %s"%(artist_info))
|
plugin.log("LastFM %s"%(artist_info))
|
||||||
print("Wiki %s"%(artist_wiki))
|
plugin.log("Wiki %s"%(artist_wiki))
|
||||||
|
|
||||||
def refresh_artist(artist_id):
|
def refresh_artist(artist_id):
|
||||||
db = get_db()
|
db = get_db()
|
||||||
|
@ -112,7 +112,7 @@ def refresh_artist(artist_id):
|
||||||
artist_info = artist_info['artistInfo2']['biography']
|
artist_info = artist_info['artistInfo2']['biography']
|
||||||
#pattern = '<a target=\'_blank\' href="https://www.last.fm/music/Afrojack">Read more on Last.fm</a>
|
#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)
|
artist_info = re.sub('<a.*?</a>', '', artist_info)
|
||||||
print("subbed: %s"%artist_info)
|
plugin.log("subbed: %s"%artist_info)
|
||||||
except:
|
except:
|
||||||
artist_info = ""
|
artist_info = ""
|
||||||
mb_artist_id = mb.get_artist_id(artist_name)
|
mb_artist_id = mb.get_artist_id(artist_name)
|
||||||
|
@ -137,7 +137,7 @@ def check_db_status(forced=False):
|
||||||
try:
|
try:
|
||||||
if(time.time()-check_freq > last_db_check) or forced:
|
if(time.time()-check_freq > last_db_check) or forced:
|
||||||
#popup("DB Check Starting")
|
#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()
|
db = get_db()
|
||||||
connection = get_connection()
|
connection = get_connection()
|
||||||
response = connection.getArtists()
|
response = connection.getArtists()
|
||||||
|
@ -146,13 +146,13 @@ def check_db_status(forced=False):
|
||||||
artist_id = artist['id']
|
artist_id = artist['id']
|
||||||
record_age = db.get_record_age(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:
|
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)
|
#popup("Refreshing %s" % artist_id)
|
||||||
refresh_artist(artist_id)
|
refresh_artist(artist_id)
|
||||||
if(record_age>0):refresh_single_flag = True
|
if(record_age>0):refresh_single_flag = True
|
||||||
last_db_check = time.time()
|
last_db_check = time.time()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
xbmc.log("DB rcheck failed %e"%e, xbmc.LOGINFO)
|
plugin.log("DB rcheck failed %s"%e)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ def check_player_status():
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
except IndexError:
|
except IndexError:
|
||||||
print ("Not a Subsonic track")
|
plugin.log ("Not a Subsonic track")
|
||||||
scrobbled = True
|
scrobbled = True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
xbmc.log("Subsonic scrobble check failed %e"%e, xbmc.LOGINFO)
|
xbmc.log("Subsonic scrobble check failed %e"%e, xbmc.LOGINFO)
|
||||||
|
@ -207,4 +207,4 @@ if __name__ == '__main__':
|
||||||
check_player_status()
|
check_player_status()
|
||||||
check_db_status()
|
check_db_status()
|
||||||
else:
|
else:
|
||||||
xbmc.log("Subsonic service not started due to settings", xbmc.LOGINFO)
|
plugin.log("Subsonic service not started due to settings")
|
||||||
|
|
Loading…
Reference in New Issue