diff --git a/resources/lib/database/__init__.py b/resources/lib/database/__init__.py index b88b6d0b..d4dcd7a3 100644 --- a/resources/lib/database/__init__.py +++ b/resources/lib/database/__init__.py @@ -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 diff --git a/resources/lib/entrypoint/service.py b/resources/lib/entrypoint/service.py index e6efa3e9..66e0c410 100644 --- a/resources/lib/entrypoint/service.py +++ b/resources/lib/entrypoint/service.py @@ -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') diff --git a/resources/lib/library.py b/resources/lib/library.py index c227e12e..b63fe7e3 100644 --- a/resources/lib/library.py +++ b/resources/lib/library.py @@ -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() diff --git a/resources/settings.xml b/resources/settings.xml index ec72c41d..639f6269 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -24,7 +24,6 @@ -