Esempio n. 1
0
 def _update_cache( self, filepath, cachefilepath ):
     exists, cloglines = checkPath( filepath, False )
     self.LOGLINES.extend( cloglines )
     if exists:
         st = xbmcvfs.Stat( filepath )
         if time.time() - st.st_mtime() < self._get_cache_time( cachefilepath ):
             self.LOGLINES.append( 'cached artist info found for fanarttv' )
             return False
         else:
             self.LOGLINES.append( 'outdated cached artist info found for fanarttv' )
             return self._put_cache_time( cachefilepath )
     else:
         self.LOGLINES.append( 'no fanarttv cachetime file found, creating it' )
         return self._put_cache_time( cachefilepath )
Esempio n. 2
0
    def _discover_database(self, database):
        ''' 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/")
        types = {
            'video': "MyVideos",
            'music': "MyMusic",
            'texture': "Textures"
        }
        database = types[database]
        dirs, files = xbmcvfs.listdir(databases)
        modified = {'db_file': None, 'time': 0}

        for db_file in reversed(files):

            if (db_file.startswith(database) and not db_file.endswith('-wal')
                    and not db_file.endswith('-shm')
                    and not db_file.endswith('db-journal')):

                st = xbmcvfs.Stat(databases + db_file)
                modified_int = st.st_mtime()
                LOG.debug("Database detected: %s time: %s", db_file,
                          modified_int)

                if modified_int > modified['time']:

                    modified['time'] = modified_int
                    modified['db_file'] = db_file

        LOG.debug("Discovered database: %s", modified)
        self.discovered_file = modified['db_file']

        return xbmc.translatePath("special://database/%s" %
                                  modified['db_file'])