diff --git a/lib/simpleplugin/simpleplugin.py b/lib/simpleplugin/simpleplugin.py index b1d5efa..f0058d4 100644 --- a/lib/simpleplugin/simpleplugin.py +++ b/lib/simpleplugin/simpleplugin.py @@ -58,7 +58,7 @@ def _format_vars(variables): :return: formatted string with sorted ``var = val`` pairs :rtype: str """ - var_list = [(var, val) for var, val in iteritems(variables)] + var_list = [(var, val) for var, val in iter(variables.items())] lines = [] for var, val in sorted(var_list, key=lambda i: i[0]): if not (var.startswith('__') or var.endswith('__')): @@ -320,7 +320,7 @@ class MemStorage(MutableMapping): :rtype: str """ lines = [] - for key, val in iteritems(self): + for key, val in iter(self.items()): lines.append('{0}: {1}'.format(repr(key), repr(val))) return ', '.join(lines) @@ -1187,7 +1187,7 @@ class RoutedPlugin(Plugin): quote_plus(str(arg)) ) # 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):]: match_string = match[1:-1] @@ -1327,7 +1327,7 @@ class RoutedPlugin(Plugin): if match is not None: kwargs = match.groupdict() # 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__'): del kwargs[key] if key.startswith('int__'): diff --git a/main.py b/main.py index 3ee0b6e..1d5847d 100644 --- a/main.py +++ b/main.py @@ -50,7 +50,6 @@ def popup(text, time=5000, image=None): def get_connection(): global connection - if connection==None: connected = False # Create connection diff --git a/service.py b/service.py index e7aea72..b9b0bae 100644 --- a/service.py +++ b/service.py @@ -44,6 +44,16 @@ except: 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): title = plugin.addon.getAddonInfo('name') icon = plugin.addon.getAddonInfo('icon') @@ -75,10 +85,12 @@ def get_connection(): return connection def get_mb(): + global mb mb = musicbrainz.MBConnection() return mb def get_db(): + global db db_path = os.path.join(plugin.profile_dir, db_filename) plugin.log("Getting DB %s"%db_path) try: @@ -118,7 +130,7 @@ def refresh_artist(artist_id): def check_db_status(forced=False): global last_db_check refresh_single_flag = False - try: + if 1:#try: if(time.time()-check_freq > last_db_check) or forced: #popup("DB Check Starting") 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) if(record_age>0):refresh_single_flag = True last_db_check = time.time() - except Exception as e: - plugin.log("DB check failed %s"%e) + #except Exception as e: + # plugin.log("DB check failed %s"%e) return @@ -180,6 +192,7 @@ def scrobble_track(track_id): if __name__ == '__main__': if serviceEnabled: + check_address_format() monitor = xbmc.Monitor() xbmc.log("Subsonic service started", xbmc.LOGINFO) popup("Subsonic service started")