def clear_cache(self): try: from modules.kodi_utils import translate_path, clear_property, path_exists PM_DATABASE = translate_path( 'special://profile/addon_data/plugin.video.fen/maincache.db') if not path_exists(PM_DATABASE): return True import sqlite3 as database from caches.debrid_cache import debrid_cache user_cloud_success = False dbcon = database.connect(PM_DATABASE) dbcur = dbcon.cursor() # USER CLOUD try: dbcur.execute("""SELECT id FROM maincache WHERE id LIKE ?""", ('fen_pm_user_cloud%', )) try: user_cloud_cache = dbcur.fetchall() user_cloud_cache = [i[0] for i in user_cloud_cache] except: user_cloud_success = True if not user_cloud_success: for i in user_cloud_cache: dbcur.execute("""DELETE FROM maincache WHERE id=?""", (i, )) clear_property(str(i)) dbcon.commit() user_cloud_success = True except: user_cloud_success = False # DOWNLOAD LINKS try: dbcur.execute("""DELETE FROM maincache WHERE id=?""", ('fen_pm_transfers_list', )) clear_property("fen_pm_transfers_list") dbcon.commit() download_links_success = True except: download_links_success = False # HOSTERS try: dbcur.execute("""DELETE FROM maincache WHERE id=?""", ('fen_pm_valid_hosts', )) clear_property('fen_pm_valid_hosts') dbcon.commit() dbcon.close() hoster_links_success = True except: hoster_links_success = False # HASH CACHED STATUS try: debrid_cache.clear_debrid_results('pm') hash_cache_status_success = True except: hash_cache_status_success = False except: return False if False in (user_cloud_success, download_links_success, hoster_links_success, hash_cache_status_success): return False return True
def delete_cache_single(self, db_type, tmdb_id): try: if not path_exists(dbfile): return False self._execute(SINGLE_DELETE, (db_type, tmdb_id)) self._vacuum() return True except: return False
def delete_cache(self, silent=False): try: if not path_exists(dbfile): return 'failure' if not silent and not confirm_dialog(): return 'cancelled' self._execute(FULL_DELETE, ()) self._vacuum() return 'success' except: return 'failure'
def clear_imdb_cache(silent=False): import sqlite3 as database from modules.kodi_utils import translate_path, path_exists, clear_property try: IMDB_DATABASE = translate_path( 'special://profile/addon_data/plugin.video.fen/maincache.db') if not path_exists(IMDB_DATABASE): return True dbcon = database.connect(IMDB_DATABASE) dbcur = dbcon.cursor() dbcur.execute("SELECT id FROM maincache WHERE id LIKE ?", ('imdb_%', )) imdb_results = [str(i[0]) for i in dbcur.fetchall()] if not imdb_results: return True dbcur.execute("DELETE FROM maincache WHERE id LIKE ?", ('imdb_%', )) dbcon.commit() dbcon.close() for i in imdb_results: clear_property(i) return True except: return False
def make_settings_dict(): import xml.etree.ElementTree as ET settings_dict = None try: test_path = translate_path( 'special://profile/addon_data/plugin.video.fen/') profile_dir = 'special://profile/addon_data/plugin.video.fen/%s' if not path_exists(test_path): make_directorys(test_path) settings_xml = translate_path(profile_dir % 'settings.xml') root = ET.parse(settings_xml).getroot() settings_dict = {} for item in root: setting_id = item.get('id') setting_value = item.text if setting_value is None: setting_value = '' dict_item = {setting_id: setting_value} settings_dict.update(dict_item) set_property('fen_settings', json.dumps(settings_dict)) except: pass return settings_dict
def clear_cache(self): try: AD_DATABASE = kodi_utils.translate_path( 'special://profile/addon_data/plugin.video.fen/maincache.db') if not kodi_utils.path_exists(AD_DATABASE): return True from caches.debrid_cache import debrid_cache dbcon = database.connect(AD_DATABASE) dbcur = dbcon.cursor() # USER CLOUD try: dbcur.execute("""DELETE FROM maincache WHERE id=?""", ('fen_ad_user_cloud', )) kodi_utils.clear_property('fen_ad_user_cloud') dbcon.commit() user_cloud_success = True except: user_cloud_success = False # HOSTERS try: dbcur.execute("""DELETE FROM maincache WHERE id=?""", ('fen_ad_valid_hosts', )) kodi_utils.clear_property('fen_ad_valid_hosts') dbcon.commit() dbcon.close() hoster_links_success = True except: hoster_links_success = False # HASH CACHED STATUS try: debrid_cache.clear_debrid_results('ad') hash_cache_status_success = True except: hash_cache_status_success = False except: return False if False in (user_cloud_success, hoster_links_success, hash_cache_status_success): return False return True
def clear_cache(self): try: from modules.kodi_utils import translate_path, clear_property, path_exists RD_DATABASE = translate_path( 'special://profile/addon_data/plugin.video.fen/maincache.db') if not path_exists(RD_DATABASE): return True import sqlite3 as database from caches.debrid_cache import debrid_cache user_cloud_success = False dbcon = database.connect(RD_DATABASE) dbcur = dbcon.cursor() # USER CLOUD try: dbcur.execute("""SELECT data FROM maincache WHERE id=?""", ('fen_rd_user_cloud', )) try: user_cloud_cache = eval(dbcur.fetchone()[0]) user_cloud_info_caches = [ i['id'] for i in user_cloud_cache ] except: user_cloud_success = True if not user_cloud_success: dbcur.execute("""DELETE FROM maincache WHERE id=?""", ('fen_rd_user_cloud', )) clear_property("fen_rd_user_cloud") for i in user_cloud_info_caches: dbcur.execute("""DELETE FROM maincache WHERE id=?""", ('fen_rd_user_cloud_info_%s' % i, )) clear_property("fen_rd_user_cloud_info_%s" % i) dbcon.commit() user_cloud_success = True except: user_cloud_success = False # DOWNLOAD LINKS try: dbcur.execute("""DELETE FROM maincache WHERE id=?""", ('fen_rd_downloads', )) clear_property("fen_rd_downloads") dbcon.commit() download_links_success = True except: download_links_success = False # HOSTERS try: dbcur.execute("""DELETE FROM maincache WHERE id=?""", ('fen_rd_valid_hosts', )) clear_property('fen_rd_valid_hosts') dbcon.commit() dbcon.close() hoster_links_success = True except: hoster_links_success = False # HASH CACHED STATUS try: debrid_cache.clear_debrid_results('rd') hash_cache_status_success = True except: hash_cache_status_success = False except: return False if False in (user_cloud_success, download_links_success, hoster_links_success, hash_cache_status_success): return False return True
def check_databases(): data_path = translate_path( 'special://profile/addon_data/plugin.video.fen/') if not path_exists(data_path): make_directorys(data_path) # Navigator dbcon = database.connect(navigator_db) dbcon.execute( """CREATE TABLE IF NOT EXISTS navigator (list_name text, list_type text, list_contents text)""" ) dbcon.close() # Watched Status dbcon = database.connect(watched_db) dbcon.execute("""CREATE TABLE IF NOT EXISTS progress (db_type text, media_id text, season integer, episode integer, resume_point text, curr_time text, unique(db_type, media_id, season, episode))""" ) dbcon.execute("""CREATE TABLE IF NOT EXISTS watched_status (db_type text, media_id text, season integer, episode integer, last_played text, title text, unique(db_type, media_id, season, episode))""" ) dbcon.execute( """CREATE TABLE IF NOT EXISTS exclude_from_next_episode (media_id text, title text)""" ) dbcon.execute( """CREATE TABLE IF NOT EXISTS unwatched_next_episode (media_id text)""" ) dbcon.close() # Favourites dbcon = database.connect(favorites_db) dbcon.execute( """CREATE TABLE IF NOT EXISTS favourites (db_type text, tmdb_id text, title text, unique (db_type, tmdb_id))""" ) dbcon.close() # Views dbcon = database.connect(views_db) dbcon.execute( """CREATE TABLE IF NOT EXISTS views (view_type text, view_id text, unique (view_type))""" ) dbcon.close() # Trakt dbcon = database.connect(trakt_db) dbcon.execute( """CREATE TABLE IF NOT EXISTS trakt_data (id text unique, data text)""" ) dbcon.execute("""CREATE TABLE IF NOT EXISTS watched_status (db_type text, media_id text, season integer, episode integer, last_played text, title text, unique(db_type, media_id, season, episode))""" ) dbcon.execute("""CREATE TABLE IF NOT EXISTS progress (db_type text, media_id text, season integer, episode integer, resume_point text, curr_time text, unique(db_type, media_id, season, episode))""" ) dbcon.close() # Main Cache dbcon = database.connect(maincache_db) dbcon.execute( """CREATE TABLE IF NOT EXISTS maincache (id text unique, data text, expires integer)""" ) dbcon.close() # Meta Cache dbcon = database.connect(metacache_db) dbcon.execute("""CREATE TABLE IF NOT EXISTS metadata (db_type text not null, tmdb_id text not null, imdb_id text, tvdb_id text, meta text, expires integer, unique (db_type, tmdb_id))""" ) dbcon.execute( """CREATE TABLE IF NOT EXISTS season_metadata (tmdb_id text not null unique, meta text, expires integer)""" ) dbcon.execute( """CREATE TABLE IF NOT EXISTS function_cache (string_id text not null, data text, expires integer)""" ) dbcon.close() # Debrid Cache dbcon = database.connect(debridcache_db) dbcon.execute( """CREATE TABLE IF NOT EXISTS debrid_data (hash text not null, debrid text not null, cached text, expires integer, unique (hash, debrid))""" ) dbcon.close() # Image Hash Cache dbcon = database.connect(imagehash_db) dbcon.execute( """CREATE TABLE IF NOT EXISTS imagehash_data (image text not null, hash text not null, brightness bool not null, unique (image, hash, brightness))""" ) dbcon.close() # External Providers Cache dbcon = database.connect(external_db) dbcon.execute("""CREATE TABLE IF NOT EXISTS results_data (provider text, db_type text, tmdb_id text, title text, year integer, season text, episode text, results text, expires integer, unique (provider, db_type, tmdb_id, title, year, season, episode))""" ) dbcon.close()