def fullTextureCacheSync(self): """ This method will sync all Kodi artwork to textures13.db and cache them locally. This takes diskspace! """ if not dialog('yesno', "Image Texture Cache", lang(39250)): return LOG.info("Doing Image Cache Sync") # ask to rest all existing or not if dialog('yesno', "Image Texture Cache", lang(39251)): LOG.info("Resetting all cache data first") # Remove all existing textures first path = try_decode(translatePath("special://thumbnails/")) if exists_dir(path): rmtree(path, ignore_errors=True) self.restoreCacheDirectories() # remove all existing data from texture DB connection = kodi_sql('texture') cursor = connection.cursor() query = 'SELECT tbl_name FROM sqlite_master WHERE type=?' cursor.execute(query, ('table', )) rows = cursor.fetchall() for row in rows: tableName = row[0] if tableName != "version": cursor.execute("DELETE FROM %s" % tableName) connection.commit() connection.close() # Cache all entries in video DB connection = kodi_sql('video') cursor = connection.cursor() # dont include actors query = "SELECT url FROM art WHERE media_type != ?" cursor.execute(query, ('actor', )) result = cursor.fetchall() total = len(result) LOG.info("Image cache sync about to process %s video images" % total) connection.close() for url in result: self.cacheTexture(url[0]) # Cache all entries in music DB connection = kodi_sql('music') cursor = connection.cursor() cursor.execute("SELECT url FROM art") result = cursor.fetchall() total = len(result) LOG.info("Image cache sync about to process %s music images" % total) connection.close() for url in result: self.cacheTexture(url[0])
def deleteCachedArtwork(self, url): # Only necessary to remove and apply a new backdrop or poster connection = kodi_sql('texture') cursor = connection.cursor() try: cursor.execute("SELECT cachedurl FROM texture WHERE url = ?", (url, )) cachedurl = cursor.fetchone()[0] except TypeError: LOG.info("Could not find cached url.") else: # Delete thumbnail as well as the entry path = translatePath("special://thumbnails/%s" % cachedurl) LOG.debug("Deleting cached thumbnail: %s" % path) if exists(path): rmtree(try_decode(path), ignore_errors=True) cursor.execute("DELETE FROM texture WHERE url = ?", (url, )) connection.commit() finally: connection.close()
def delete_cached_artwork(url): """ Deleted the cached artwork with path url (if it exists) """ connection = kodi_sql('texture') cursor = connection.cursor() try: cursor.execute("SELECT cachedurl FROM texture WHERE url=? LIMIT 1", (url,)) cachedurl = cursor.fetchone()[0] except TypeError: # Could not find cached url pass else: # Delete thumbnail as well as the entry path = translatePath("special://thumbnails/%s" % cachedurl) LOG.debug("Deleting cached thumbnail: %s", path) if exists(path): rmtree(try_decode(path), ignore_errors=True) cursor.execute("DELETE FROM texture WHERE url = ?", (url,)) connection.commit() finally: connection.close()
def __enter__(self): self.kodiconn = kodi_sql(self.db_type) kodi_db = Kodidb_Functions(self.kodiconn.cursor()) return kodi_db
def __enter__(self): self.plexconn = kodi_sql('plex') return Plex_DB_Functions(self.plexconn.cursor())
def __enter__(self): self.kodiconn = kodi_sql(self.db_type) kodi_db = KodiDBMethods(self.kodiconn.cursor()) return kodi_db