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): def _discover_database(self, database):
''' Grab the first database encountered, by most recent. ''' Use UpdateLibrary(video) to update the date modified
Will likely not work, but heck. 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') databases = xbmc.translatePath("special://database/").decode('utf-8')
types = { types = {
'video': "MyVideos", 'video': "MyVideos",
@ -99,6 +104,7 @@ class Database(object):
modified = {'file': None, 'time': 0} modified = {'file': None, 'time': 0}
for file in reversed(files): for file in reversed(files):
if (file.startswith(database) and not file.endswith('-wal') and if (file.startswith(database) and not file.endswith('-wal') and
not file.endswith('-shm') and not file.endswith('db-journal')): not file.endswith('-shm') and not file.endswith('db-journal')):
@ -124,7 +130,7 @@ class Database(object):
''' '''
databases = obj.Objects().objects 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) return self._get_database(databases[file], True)
discovered = self._discover_database(file) if not databases.get('database_set%s' % file) else None 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'] = settings('enableContext.bool')
self.settings['enable_context_transcode'] = settings('enableContextTranscode.bool') self.settings['enable_context_transcode'] = settings('enableContextTranscode.bool')
self.settings['kodi_companion'] = settings('kodiCompanion.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_logLevel', value=str(self.settings['log_level']))
window('emby_kodiProfile', value=self.settings['profile']) window('emby_kodiProfile', value=self.settings['profile'])
settings('platformDetected', client.get_platform()) settings('platformDetected', client.get_platform())
@ -453,14 +452,6 @@ class Service(xbmc.Monitor):
self.settings['enable_context_transcode'] = settings('enableContextTranscode.bool') self.settings['enable_context_transcode'] = settings('enableContextTranscode.bool')
LOG.warn("New context transcode setting: %s", self.settings['enable_context_transcode']) 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: if settings('useDirectPaths') != self.settings['mode'] and self.library_thread.started:
self.settings['mode'] = settings('useDirectPaths') self.settings['mode'] = settings('useDirectPaths')

View file

@ -122,18 +122,7 @@ class Library(threading.Thread):
''' '''
with Database('video') as kodidb: with Database('video') as kodidb:
with Database('music') as musicdb: with Database('music') as musicdb:
pass
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
@stop() @stop()
def service(self): def service(self):
@ -196,11 +185,14 @@ class Library(threading.Thread):
set_screensaver(value=self.screensaver) set_screensaver(value=self.screensaver)
self.screensaver = None 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') xbmc.executebuiltin('Container.Refresh')
else: # Update widgets else: # Update widgets
xbmc.executebuiltin('UpdateLibrary(video)') xbmc.executebuiltin('UpdateLibrary(video)')
if xbmc.getCondVisibility('Window.IsMedia'):
xbmc.executebuiltin('Container.Refresh')
def stop_client(self): def stop_client(self):
self.stop_thread = True self.stop_thread = True
@ -317,23 +309,7 @@ class Library(threading.Thread):
Check databases. Check databases.
Check for the server plugin. Check for the server plugin.
''' '''
if not self.test_databases(): 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
Views().get_views() Views().get_views()
Views().get_nodes() 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="30507" id="syncIndicator" type="number" default="999" visible="eq(-1,true)" subsetting="true"/>
<setting label="33185" id="syncDuringPlay" type="bool" default="true" /> <setting label="33185" id="syncDuringPlay" type="bool" default="true" />
<setting label="30536" id="dbSyncScreensaver" 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="33111" type="lsep" />
<setting label="30511" id="useDirectPaths" type="enum" lvalues="33036|33037" default="1" /> <setting label="30511" id="useDirectPaths" type="enum" lvalues="33036|33037" default="1" />