def clear_cache(): import xbmcgui skip_prompt = xbmcaddon.Addon().getSetting("quiet_cache") dialog = xbmcgui.Dialog() if skip_prompt == 'false': if dialog.yesno(addon_name, _("Clear Metadata?")): koding.Remove_Table("meta") koding.Remove_Table("episode_meta") if dialog.yesno(addon_name, _("Clear GIF Cache?")): dest_folder = os.path.join( xbmc.translatePath( xbmcaddon.Addon().getSetting("cache_folder")), "artcache") koding.Delete_Folders(dest_folder) if dialog.yesno(addon_name, _("Clear Main Cache?")): res = koding.Get_All_From_Table("Table_names") for results in res: table_nm = results['name'] print table_nm koding.Remove_Table(table_nm) if dialog.yesno(addon_name, _("Clear Plugin Cache?")): res = koding.Get_All_From_Table("Plugin_table_names") for results in res: table_nm = results['name'] print table_nm koding.Remove_Table(table_nm) else: koding.Remove_Table("meta") koding.Remove_Table("episode_meta") dest_folder = os.path.join( xbmc.translatePath(xbmcaddon.Addon().getSetting("cache_folder")), "artcache") koding.Delete_Folders(dest_folder) res = koding.Get_All_From_Table("Table_names") for results in res: table_nm = results['name'] print table_nm koding.Remove_Table(table_nm) res = koding.Get_All_From_Table("Plugin_table_names") for results in res: table_nm = results['name'] print table_nm koding.Remove_Table(table_nm) db = sqlite3.connect('%s' % (database_loc)) cursor = db.cursor() db.execute("vacuum") db.commit() db.close() xbmc.log("running hook: clear cache", xbmc.LOGNOTICE) run_hook("clear_cache") xbmcgui.Dialog().notification('Clear Cache', 'Cache has been cleared', xbmcaddon.Addon().getAddonInfo("icon"), 4000)
def fetch_from_db2(url): koding.reset_db() url2 = clean_url(url) match = koding.Get_All_From_Table(url2) if match: match = match[0] if not match["value"]: return None match_item = match["value"] try: result = pickle.loads(base64.b64decode(match_item)) except: return None created_time = match["created"] print created_time + "created" print time.time() print CACHE_TIME test_time = float(created_time) + CACHE_TIME print test_time if float(created_time) + CACHE_TIME <= time.time(): koding.Remove_Table(url2) db = sqlite3.connect('%s' % (database_loc)) cursor = db.cursor() db.execute("vacuum") db.commit() db.close() display_list2(result, "video", url2) else: pass return result else: return []
def search(): """ Open root search directory """ versionspec = {"columns": {"version": "TEXT"}} koding.Create_Table("version", versionspec) search_spec = {"columns": {"term": "TEXT"}} koding.Create_Table("search", search_spec) terms = koding.Get_All_From_Table("search") if terms: koding.Add_Dir(name=_("Clear Search"), mode="clear_search", folder=True, icon=icon, fanart=fanart) for term in terms: label = term["term"] context_menu = [(_("Remove Search"), "RunPlugin({0})".format( get_addon_url(mode="remove_search", url=label)))] koding.Add_Dir(name=label, url=label, mode="do_search", folder=True, icon=icon, fanart=fanart, context_items=context_menu) koding.Add_Dir(name=_("Add Search"), mode="add_search", folder=True, icon=icon, fanart=fanart)
def fetch_from_db(url): koding.reset_db() url2 = clean_url(url) match = koding.Get_All_From_Table(url2) if match: match = match[0] if not match["value"]: return None match_item = match["value"] try: result = pickle.loads(base64.b64decode(match_item)) except: return None created_time = match["created"] if float(created_time) + int(main_cache_time) <= time.time(): koding.Remove_Table(url2) db = sqlite3.connect('%s' % (database_loc)) cursor = db.cursor() db.execute("vacuum") db.commit() db.close() return result else: return result return result else: return []
def Clear_Main(): res = koding.Get_All_From_Table("Table_names") for results in res: table_nm = results['name'] print table_nm koding.Remove_Table(table_nm) db = sqlite3.connect('%s' % (database_loc)) cursor = db.cursor() db.execute("vacuum") db.commit() db.close()
def fetch_episode_from_db(identifier, season, episode, provider, lang): """ get episode's meta info from database Args: identifier: identifier of the item season: season number of the episode episode: episode number of the episode provider: metadata provider to fetch info for lang: language to fetch info for Returns: item's metadata """ import koding versionspec = {"columns": {"version": "TEXT"}} koding.Create_Table("version", versionspec) if not koding.Get_All_From_Table("version"): koding.Add_To_Table("version", {"version": "0.0.1"}) episode_meta_spec = { "columns": { "identifier": "TEXT", "season": "TEXT", "episode": "TEXT", "provider": "TEXT", "lang": "TEXT", "meta": "TEXT", "created": "TEXT" }, "constraints": { "unique": "identifier, provider, lang", } } koding.Create_Table("episode_meta", episode_meta_spec) match = koding.Get_From_Table( "episode_meta", { "identifier": identifier, "provider": provider, "season": season, "episode": episode, "lang": lang }) if match: match = match[0] if not match["meta"]: return None, match["created"] match_meta = match["meta"].replace("'", "\"") try: match_meta = match_meta.encode('ascii', 'ignore') except: match_meta = match_meta.decode('utf-8').encode('ascii', 'ignore') return pickle.loads(match_meta), match["created"] else: return [], None
def CheckSession(apikey): hour = datetime.timedelta(minutes=60) results = koding.Get_All_From_Table(table) for item in results: Auth = item.get('auth',False) Auth = True if Auth == 'True' else False SessionId = item.get('sessionid','') StatusMessageSession = item.get('statusmessage','') SessionTime = item.get('sessiontime','2018-04-30 23:25:13.671000') SessionTime = dparser.parse(SessionTime) EndSessionTime = SessionTime+hour if DateTimeNow > EndSessionTime: BYB.Notify(title=str(addon_name),message='TMDB Session has expired creating new one') koding.Remove_Table(table) Auth,SessionId,StatusMessageSession = CreateSession(apikey) return Auth,SessionId,StatusMessageSession