Service will now check for old address format

This commit is contained in:
warwickh 2021-09-29 13:59:54 +10:00
parent 0db8d3b06c
commit 117175d2cc
3 changed files with 20 additions and 8 deletions

View File

@ -58,7 +58,7 @@ def _format_vars(variables):
:return: formatted string with sorted ``var = val`` pairs :return: formatted string with sorted ``var = val`` pairs
:rtype: str :rtype: str
""" """
var_list = [(var, val) for var, val in iteritems(variables)] var_list = [(var, val) for var, val in iter(variables.items())]
lines = [] lines = []
for var, val in sorted(var_list, key=lambda i: i[0]): for var, val in sorted(var_list, key=lambda i: i[0]):
if not (var.startswith('__') or var.endswith('__')): if not (var.startswith('__') or var.endswith('__')):
@ -320,7 +320,7 @@ class MemStorage(MutableMapping):
:rtype: str :rtype: str
""" """
lines = [] lines = []
for key, val in iteritems(self): for key, val in iter(self.items()):
lines.append('{0}: {1}'.format(repr(key), repr(val))) lines.append('{0}: {1}'.format(repr(key), repr(val)))
return ', '.join(lines) return ', '.join(lines)
@ -1187,7 +1187,7 @@ class RoutedPlugin(Plugin):
quote_plus(str(arg)) quote_plus(str(arg))
) )
# list allows to manipulate the dict during iteration # list allows to manipulate the dict during iteration
for key, value in list(iteritems(kwargs)): for key, value in list(iter(kwargs.items())):
for match in matches[len(args):]: for match in matches[len(args):]:
match_string = match[1:-1] match_string = match[1:-1]
@ -1327,7 +1327,7 @@ class RoutedPlugin(Plugin):
if match is not None: if match is not None:
kwargs = match.groupdict() kwargs = match.groupdict()
# list allows to manipulate the dict during iteration # list allows to manipulate the dict during iteration
for key, value in list(iteritems(kwargs)): for key, value in list(iter(kwargs.items())):
if key.startswith('int__') or key.startswith('float__'): if key.startswith('int__') or key.startswith('float__'):
del kwargs[key] del kwargs[key]
if key.startswith('int__'): if key.startswith('int__'):

View File

@ -50,7 +50,6 @@ def popup(text, time=5000, image=None):
def get_connection(): def get_connection():
global connection global connection
if connection==None: if connection==None:
connected = False connected = False
# Create connection # Create connection

View File

@ -44,6 +44,16 @@ except:
scrobbled = False scrobbled = False
def check_address_format():
address = Addon().get_setting('subsonic_url')
port = Addon().get_setting('port')
if len(address.split(":"))>2:
found_port = address.split(":")[2]
plugin.log("Found port %s in address %s, splitting"%(found_port, address))
plugin.log("Changing port from %s to %s"%(port, found_port))
Addon().set_setting('port', int(found_port))
Addon().set_setting('subsonic_url', "%s:%s"%(address.split(":")[0],address.split(":")[1]))
def popup(text, time=5000, image=None): def popup(text, time=5000, image=None):
title = plugin.addon.getAddonInfo('name') title = plugin.addon.getAddonInfo('name')
icon = plugin.addon.getAddonInfo('icon') icon = plugin.addon.getAddonInfo('icon')
@ -75,10 +85,12 @@ def get_connection():
return connection return connection
def get_mb(): def get_mb():
global mb
mb = musicbrainz.MBConnection() mb = musicbrainz.MBConnection()
return mb return mb
def get_db(): def get_db():
global db
db_path = os.path.join(plugin.profile_dir, db_filename) db_path = os.path.join(plugin.profile_dir, db_filename)
plugin.log("Getting DB %s"%db_path) plugin.log("Getting DB %s"%db_path)
try: try:
@ -118,7 +130,7 @@ def refresh_artist(artist_id):
def check_db_status(forced=False): def check_db_status(forced=False):
global last_db_check global last_db_check
refresh_single_flag = False refresh_single_flag = False
try: if 1:#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")
plugin.log("DB check starting %s %s" % (time.time(), last_db_check)) plugin.log("DB check starting %s %s" % (time.time(), last_db_check))
@ -135,8 +147,8 @@ def check_db_status(forced=False):
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:
plugin.log("DB check failed %s"%e) # plugin.log("DB check failed %s"%e)
return return
@ -180,6 +192,7 @@ def scrobble_track(track_id):
if __name__ == '__main__': if __name__ == '__main__':
if serviceEnabled: if serviceEnabled:
check_address_format()
monitor = xbmc.Monitor() monitor = xbmc.Monitor()
xbmc.log("Subsonic service started", xbmc.LOGINFO) xbmc.log("Subsonic service started", xbmc.LOGINFO)
popup("Subsonic service started") popup("Subsonic service started")