Merge pull request #169 from angelblue05/develop

Update database discovery
This commit is contained in:
angelblue05 2019-01-21 07:02:52 -06:00 committed by GitHub
commit e9616f6526
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 43 deletions

View file

@ -85,9 +85,14 @@ class Database(object):
def _discover_database(self, database):
''' Grab the first database encountered, by most recent.
Will likely not work, but heck.
''' Use UpdateLibrary(video) to update the date modified
on the database file used by Kodi.
'''
if database == 'video':
xbmc.executebuiltin('UpdateLibrary(video)')
xbmc.sleep(200)
databases = xbmc.translatePath("special://database/").decode('utf-8')
types = {
'video': "MyVideos",
@ -99,6 +104,7 @@ class Database(object):
modified = {'file': None, 'time': 0}
for file in reversed(files):
if (file.startswith(database) and not file.endswith('-wal') and
not file.endswith('-shm') and not file.endswith('db-journal')):
@ -124,7 +130,7 @@ class Database(object):
'''
databases = obj.Objects().objects
if file not in ('video', 'music', 'texture') or databases.get('database_set%s' % file):
if file not in ('video', 'music') or databases.get('database_set%s' % file):
return self._get_database(databases[file], True)
discovered = self._discover_database(file) if not databases.get('database_set%s' % file) else None

View file

@ -53,7 +53,6 @@ class Service(xbmc.Monitor):
self.settings['enable_context'] = settings('enableContext.bool')
self.settings['enable_context_transcode'] = settings('enableContextTranscode.bool')
self.settings['kodi_companion'] = settings('kodiCompanion.bool')
self.settings['enable_db_discovery'] = settings('AskDiscoverDatabase.bool')
window('emby_logLevel', value=str(self.settings['log_level']))
window('emby_kodiProfile', value=self.settings['profile'])
settings('platformDetected', client.get_platform())
@ -453,14 +452,6 @@ class Service(xbmc.Monitor):
self.settings['enable_context_transcode'] = settings('enableContextTranscode.bool')
LOG.warn("New context transcode setting: %s", self.settings['enable_context_transcode'])
if settings('AskDiscoverDatabase.bool') != self.settings['enable_db_discovery']:
LOG.warn(self.settings['enable_db_discovery'])
self.settings['enable_db_discovery'] = settings('AskDiscoverDatabase.bool')
LOG.warn("Enable database discovery: %s", self.settings['enable_db_discovery'])
if dialog("yesno", heading="{emby}", line1=_(33191)):
window('emby.restart.bool', True)
if settings('useDirectPaths') != self.settings['mode'] and self.library_thread.started:
self.settings['mode'] = settings('useDirectPaths')

View file

@ -122,18 +122,7 @@ class Library(threading.Thread):
'''
with Database('video') as kodidb:
with Database('music') as musicdb:
if kodidb.discovered or musicdb.discovered:
if kodidb.discovered_file != settings('DiscoveredDatabase'):
LOG.info("Newly discovered database: %s", kodidb.path)
settings('DiscoveredDatabase', kodidb.discovered_file)
self.monitor.settings['enable_db_discovery'] = True
settings('AskDiscoverDatabase.bool', True)
return False
return True
pass
@stop()
def service(self):
@ -196,11 +185,14 @@ class Library(threading.Thread):
set_screensaver(value=self.screensaver)
self.screensaver = None
if xbmc.getCondVisibility('Container.Content(musicvideos)') or xbmc.getCondVisibility('Window.IsMedia'): # Prevent cursor from moving
if xbmc.getCondVisibility('Container.Content(musicvideos)'): # Prevent cursor from moving
xbmc.executebuiltin('Container.Refresh')
else: # Update widgets
xbmc.executebuiltin('UpdateLibrary(video)')
if xbmc.getCondVisibility('Window.IsMedia'):
xbmc.executebuiltin('Container.Refresh')
def stop_client(self):
self.stop_thread = True
@ -317,23 +309,7 @@ class Library(threading.Thread):
Check databases.
Check for the server plugin.
'''
if not self.test_databases():
if settings('AskDiscoverDatabase.bool'):
self.monitor.settings['enable_db_discovery'] = False
settings('AskDiscoverDatabase.bool', False)
result = dialog("yesno", heading="{emby}", line1=_(33189))
settings('DiscoverDatabase.bool', result == 1)
if not result:
LOG.info("Do not discover database again.")
return False
elif not settings('DiscoverDatabase.bool'):
LOG.info("Do not re-discover database again.")
return False
self.test_databases()
Views().get_views()
Views().get_nodes()

View file

@ -24,7 +24,6 @@
<setting label="30507" id="syncIndicator" type="number" default="999" visible="eq(-1,true)" subsetting="true"/>
<setting label="33185" id="syncDuringPlay" type="bool" default="true" />
<setting label="30536" id="dbSyncScreensaver" type="bool" default="true" />
<setting label="33190" id="AskDiscoverDatabase" type="bool" default="true" />
<setting label="33111" type="lsep" />
<setting label="30511" id="useDirectPaths" type="enum" lvalues="33036|33037" default="1" />