mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-24 17:56:11 +00:00
Fix database discovery
This commit is contained in:
parent
9cc8405a70
commit
d0c5cf5864
2 changed files with 7 additions and 3 deletions
|
@ -32,6 +32,7 @@ class Database(object):
|
||||||
'''
|
'''
|
||||||
timeout = 120
|
timeout = 120
|
||||||
discovered = False
|
discovered = False
|
||||||
|
discovered_file = None
|
||||||
|
|
||||||
def __init__(self, file=None, commit_close=True):
|
def __init__(self, file=None, commit_close=True):
|
||||||
|
|
||||||
|
@ -110,6 +111,7 @@ class Database(object):
|
||||||
modified['file'] = file.decode('utf-8')
|
modified['file'] = file.decode('utf-8')
|
||||||
|
|
||||||
LOG.info("Discovered database: %s", modified)
|
LOG.info("Discovered database: %s", modified)
|
||||||
|
self.discovered_file = modified['file']
|
||||||
|
|
||||||
return xbmc.translatePath("special://database/%s" % modified['file']).decode('utf-8')
|
return xbmc.translatePath("special://database/%s" % modified['file']).decode('utf-8')
|
||||||
|
|
||||||
|
@ -129,13 +131,14 @@ class Database(object):
|
||||||
try:
|
try:
|
||||||
loaded = self._get_database(databases[file]) if file in databases else file
|
loaded = self._get_database(databases[file]) if file in databases else file
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
LOG.error(error)
|
|
||||||
|
|
||||||
for i in range(1, 10):
|
for i in range(1, 10):
|
||||||
alt_file = "%s-%s" % (file, i)
|
alt_file = "%s-%s" % (file, i)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
loaded = self._get_database(databases[alt_file])
|
loaded = self._get_database(databases[alt_file])
|
||||||
|
|
||||||
|
break
|
||||||
except KeyError: # No other db options
|
except KeyError: # No other db options
|
||||||
loaded = None
|
loaded = None
|
||||||
|
|
||||||
|
@ -144,6 +147,7 @@ class Database(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if discovered and discovered != loaded:
|
if discovered and discovered != loaded:
|
||||||
|
|
||||||
databases[file] = discovered
|
databases[file] = discovered
|
||||||
self.discovered = True
|
self.discovered = True
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -124,10 +124,10 @@ class Library(threading.Thread):
|
||||||
with Database('music') as musicdb:
|
with Database('music') as musicdb:
|
||||||
|
|
||||||
if kodidb.discovered or musicdb.discovered:
|
if kodidb.discovered or musicdb.discovered:
|
||||||
if kodidb.path != settings('DiscoveredDatabase'):
|
if kodidb.discovered_file != settings('DiscoveredDatabase'):
|
||||||
|
|
||||||
LOG.info("Newly discovered database: %s", kodidb.path)
|
LOG.info("Newly discovered database: %s", kodidb.path)
|
||||||
settings('DiscoveredDatabase', kodidb.path)
|
settings('DiscoveredDatabase', kodidb.discovered_file)
|
||||||
self.monitor.settings['enable_db_discovery'] = True
|
self.monitor.settings['enable_db_discovery'] = True
|
||||||
settings('AskDiscoverDatabase.bool', True)
|
settings('AskDiscoverDatabase.bool', True)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue