def delete_memory_cache(self, db_type, id_type, media_id): try: if db_type in ('movie', 'tvshow'): string = '%s_%s_%s' % (db_type, id_type, str(media_id)) clear_property(string) else: # season string = 'meta_season_%s' % str(media_id) clear_property(string) except: pass
def remove_from_history(params): cache_file = kodi_utils.translate_path( 'special://profile/addon_data/plugin.video.fen/maincache.db') dbcon = database.connect(cache_file) dbcur = dbcon.cursor() dbcur.execute("DELETE FROM maincache WHERE id=?", (params['data_id'], )) dbcon.commit() kodi_utils.clear_property(params['data_id']) kodi_utils.execute_builtin('Container.Refresh') if not params['silent']: kodi_utils.notification(32576)
def furk_tfile_audio(params): __handle__ = int(argv[1]) kodi_utils.clear_property('furk_t_files_json') excludes = ('', 'cover', 'covers', 'scan', 'scans', 'playlists') t_files = Furk.t_files(params.get('item_id')) item_path_list = list( set([ clean_file_name(i['path']) for i in t_files if clean_file_name(i['path']).lower() not in excludes ])) item_path_list.sort() line = '%s[CR]%s[CR]%s' if not item_path_list: if kodi_utils.confirm_dialog(text=32763, ok_label=32652, cancel_label=32764, top_space=True): return browse_audio_album(t_files, params.get('name')) from modules.player import FenPlayer FenPlayer().playAudioAlbum(t_files) return browse_audio_album(t_files, __handle__) def _builder(): for x in item_path_list: try: url_params = { 'mode': 'furk.browse_audio_album', 'item_path': x, 'handle': __handle__ } url = build_url(url_params) listitem = make_listitem() listitem.setLabel(x.upper()) listitem.setArt({ 'icon': default_furk_icon, 'poster': default_furk_icon, 'thumb': default_furk_icon, 'fanart': fanart, 'banner': default_furk_icon }) yield (url, listitem, True) except: pass t_files_json = json.dumps(t_files) kodi_utils.set_property('furk_t_files_json', str(t_files_json)) kodi_utils.add_items(__handle__, list(_builder())) kodi_utils.set_content(__handle__, 'files') kodi_utils.end_directory(__handle__) kodi_utils.set_view_mode('view.premium')
def run(self): logger('FEN', 'CheckSettingsFile Service Starting') kodi_utils.clear_property('fen_settings') profile_dir = translate_path( 'special://profile/addon_data/plugin.video.fen/') if not path_exists(profile_dir): kodi_utils.make_directorys(profile_dir) settings_xml = os.path.join(profile_dir, 'settings.xml') if not path_exists(settings_xml): __addon__ = kodi_utils.addon() addon_version = __addon__.getAddonInfo('version') __addon__.setSetting('version_number', addon_version) monitor.waitForAbort(0.5) make_settings_dict() return logger('FEN', 'CheckSettingsFile Service Finished')
def clear_media_results_database(): import sqlite3 as database from modules.kodi_utils import translate_path, clear_property FURK_DATABASE = translate_path( 'special://profile/addon_data/plugin.video.fen/maincache.db') dbcon = database.connect(FURK_DATABASE) dbcur = dbcon.cursor() dbcur.execute("SELECT id FROM maincache WHERE id LIKE 'fen_FURK_SEARCH_%'") try: furk_results = [str(i[0]) for i in dbcur.fetchall()] if not furk_results: return 'success' dbcur.execute( "DELETE FROM maincache WHERE id LIKE 'fen_FURK_SEARCH_%'") dbcon.commit() for i in furk_results: clear_property(i) return 'success' except: return 'failed'
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 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 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_property(self): kodi_utils.clear_property(self.window_id) self.discover_params = {} kodi_utils.execute_builtin('Container.Refresh')
def _clear_properties(self): for item in default_internal_scrapers: kodi_utils.clear_property('%s.internal_results' % item)
def link_folders(service, folder_name, action): import json from caches.main_cache import main_cache def _get_media_type(): media_type_list = [('movie', ls(32028), 'movies.png'), ('tvshow', ls(32029), 'tv.png')] list_items = [{ 'line1': item[1], 'line2': ls(32693) % item[1], 'icon': os.path.join(theme_folder, item[2]) } for item in media_type_list] kwargs = { 'items': json.dumps(list_items), 'heading': 'Fen', 'enumerate': 'false', 'multi_choice': 'false', 'multi_line': 'true' } chosen_media_type = kodi_utils.select_dialog( [i[0] for i in media_type_list], **kwargs) return chosen_media_type theme_folder = kodi_utils.translate_path( 'special://home/addons/script.tikiart/resources/media') string = 'FEN_%s_%s' % (service, folder_name) current_link = main_cache.get(string) if action == 'remove': if not current_link: return if not kodi_utils.confirm_dialog(text=ls(32694) % current_link, top_space=True): return import sqlite3 as database cache_file = kodi_utils.translate_path( 'special://profile/addon_data/plugin.video.fen/maincache.db') dbcon = database.connect(cache_file) dbcur = dbcon.cursor() dbcur.execute("DELETE FROM maincache WHERE id=?", (string, )) dbcon.commit() dbcon.close() kodi_utils.clear_property(string) if service == 'FOLDER': clear_cache('folders', silent=True) kodi_utils.execute_builtin('Container.Refresh') return kodi_utils.ok_dialog(text=32576, top_space=True) if current_link: if not kodi_utils.confirm_dialog(text='%s[CR][B]%s[/B][CR]%s' % (ls(32695), current_link, ls(32696))): return media_type = _get_media_type() if media_type == None: return title = kodi_utils.dialog.input(ls(32228)).lower() if not title: return from apis.tmdb_api import tmdb_movies_title_year, tmdb_tv_title_year year = kodi_utils.dialog.input('%s (%s)' % (ls(32543), ls(32669)), type=kodi_utils.numeric_input) function = tmdb_movies_title_year if media_type == 'movie' else tmdb_tv_title_year results = function(title, year)['results'] if len(results) == 0: return kodi_utils.ok_dialog(text=32490, top_space=True) name_key = 'title' if media_type == 'movie' else 'name' released_key = 'release_date' if media_type == 'movie' else 'first_air_date' function_list = [] function_list_append = function_list.append def _builder(): for item in results: title = item[name_key] try: year = item[released_key].split('-')[0] except: year = '' if year: rootname = '%s (%s)' % (title, year) else: rootname = title icon = 'https://image.tmdb.org/t/p/w780%s' % item['poster_path'] if item.get('poster_path') \ else kodi_utils.translate_path('special://home/addons/plugin.video.fen/icon.png') function_list_append(rootname) yield {'line1': rootname, 'line2': item['overview'], 'icon': icon} list_items = list(_builder()) kwargs = { 'items': json.dumps(list_items), 'heading': 'Fen', 'enumerate': 'false', 'multi_choice': 'false', 'multi_line': 'true' } rootname = kodi_utils.select_dialog(function_list, **kwargs) if rootname == None: return from datetime import timedelta main_cache.set(string, rootname, expiration=timedelta(days=365)) if service == 'FOLDER': clear_cache('folders', silent=True) kodi_utils.execute_builtin('Container.Refresh') return kodi_utils.ok_dialog(text=32576, top_space=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 delete_all_seasons_memory_cache(self, media_id): for item in range(1, 51): string = 'meta_season_%s_%s' % (str(media_id), str(item)) clear_property(string)
def _clear_property(setting_id): kodi_utils.clear_property(setting_id)
def execute_nextep(meta, nextep_settings): def _get_nextep_params(): nextep_params = nextep_playback_info(meta) return nextep_params def _get_nextep_url(): Sources().playback_prep(nextep_params) return kodi_utils.get_property('fen_nextep_url') def _confirm_threshold(): nextep_threshold = nextep_settings['threshold'] if nextep_threshold == 0: return True try: current_number = int( kodi_utils.get_property('fen_total_autoplays')) except: current_number = 1 if current_number == nextep_threshold: current_number = 1 kodi_utils.set_property('fen_total_autoplays', str(current_number)) if open_window(('windows.next_episode', 'NextEpisode'), 'next_episode.xml', meta=nextep_meta, function='confirm'): return True else: kodi_utils.notification(32736, 1500) return False else: current_number += 1 kodi_utils.set_property('fen_total_autoplays', str(current_number)) return True def _continue_action(): if run_popup: action = open_window(('windows.next_episode', 'NextEpisode'), 'next_episode.xml', meta=nextep_meta, function='next_ep') else: action = 'close' return action def _control(): confirm_threshold = False final_action = 'cancel' while player.isPlayingVideo(): try: total_time = player.getTotalTime() curr_time = player.getTime() remaining_time = round(total_time - curr_time) if remaining_time <= nextep_threshold_check: if not confirm_threshold: confirm_threshold = _confirm_threshold() if not confirm_threshold: final_action = 'cancel' break if remaining_time <= display_nextep_popup: final_action = _continue_action() break kodi_utils.sleep(200) except: pass return final_action kodi_utils.clear_property('fen_nextep_url') player = FenPlayer() run_popup, display_nextep_popup = nextep_settings[ 'run_popup'], nextep_settings['window_time'] nextep_prep, nextep_threshold_check = nextep_settings[ 'start_prep'], nextep_settings['threshold_check'] nextep_meta, nextep_params = _get_nextep_params() if nextep_params == 'error': return kodi_utils.notification(32574, 3000) elif nextep_params == 'no_next_episode': return nextep_url = _get_nextep_url() if not nextep_url: return kodi_utils.notification(32760, 3000) action = _control() if action == 'cancel': return kodi_utils.notification(32736, 3000) elif action == 'play': player.stop() elif action == 'close': if not run_popup: kodi_utils.notification( '%s %s S%02dE%02d' % (ls(32801), nextep_meta['title'], nextep_meta['season'], nextep_meta['episode']), 6500, nextep_meta['poster']) while player.isPlayingVideo(): kodi_utils.sleep(100) kodi_utils.sleep(1000) player.run(nextep_url)
def check_trakt_refresh(): if kodi_utils.get_property('fen_refresh_trakt_info') == 'true': from apis.trakt_api import trakt_sync_activities trakt_sync_activities(force_update=True) kodi_utils.clear_property('fen_refresh_trakt_info')