def __init__(self, source_dict, debrid_torrents, debrid_hosters, internal_scrapers, prescrape_sources, display_uncached_torrents, progress_dialog, disabled_ignored=False): self.scrape_provider = 'external' self.debrid_torrents, self.debrid_hosters = debrid_torrents, debrid_hosters self.source_dict, self.hostDict = source_dict, self.make_host_dict() self.internal_scrapers, self.prescrape_sources = internal_scrapers, prescrape_sources self.display_uncached_torrents = display_uncached_torrents self.progress_dialog, self.disabled_ignored = progress_dialog, disabled_ignored self.internal_activated, self.internal_prescraped = len( self.internal_scrapers) > 0, len(self.prescrape_sources) > 0 self.processed_prescrape, self.scraping_started, self.threads_completed = False, False, False self.sources, self.final_sources, self.processed_internal_scrapers = [], [], [] self.processed_internal_scrapers_append = self.processed_internal_scrapers.append self.sleep_time = display_sleep_time() self.pause_scrape = (self.sleep_time * 1.05) / 1000 self.int_dialog_highlight, self.ext_dialog_highlight = get_setting( 'int_dialog_highlight', 'darkgoldenrod'), get_setting('ext_dialog_highlight', 'dodgerblue') self.finish_early = get_setting('search.finish.early') == 'true' self.int_total_format, self.ext_total_format = total_format % ( self.int_dialog_highlight, '%s'), total_format % (self.ext_dialog_highlight, '%s') self.timeout = 60 if self.disabled_ignored else int( get_setting('scrapers.timeout.1', '60')) self.meta = json.loads(kodi_utils.get_property('fen_playback_meta')) self.background = self.meta.get('background', False) self.internal_sources_total = self.internal_sources_4K = self.internal_sources_1080p = self.internal_sources_720p = self.internal_sources_sd = 0 self.sources_total = self.sources_4k = self.sources_1080p = self.sources_720p = self.sources_sd = 0
def trakt_calendar_days(recently_aired, current_date): from datetime import timedelta if recently_aired: start, finish = (current_date - timedelta(days=7)).strftime('%Y-%m-%d'), '7' else: previous_days = int(get_setting('trakt.calendar_previous_days', '3')) future_days = int(get_setting('trakt.calendar_future_days', '7')) start = (current_date - timedelta(days=previous_days)).strftime('%Y-%m-%d') finish = str(previous_days + future_days) return start, finish
def run(self): logger('FEN', 'ReuseLanguageInvokerCheck Service Starting') addon_xml = translate_path( 'special://home/addons/plugin.video.fen/addon.xml') tree = ET.parse(addon_xml) root = tree.getroot() current_addon_setting = get_setting('reuse_language_invoker', 'true') try: current_xml_setting = [ str(i.text) for i in root.iter('reuselanguageinvoker') ][0] except: return logger('FEN', 'ReuseLanguageInvokerCheck Service Finished') if current_xml_setting == current_addon_setting: return logger('FEN', 'ReuseLanguageInvokerCheck Service Finished') for item in root.iter('reuselanguageinvoker'): item.text = current_addon_setting hash_start = gen_file_hash(addon_xml) tree.write(addon_xml) hash_end = gen_file_hash(addon_xml) logger('FEN', 'ReuseLanguageInvokerCheck Service Finished') if hash_start != hash_end: if not kodi_utils.confirm_dialog(text='%s\n%s' % (ls(33021), ls(33020))): return current_profile = kodi_utils.get_infolabel( 'system.profilename') kodi_utils.execute_builtin('LoadProfile(%s)' % current_profile) else: kodi_utils.ok_dialog(text=32574, top_space=True)
def get_api(self): try: api_key = get_setting('furk_api_key') if not api_key: user_name, user_pass = get_setting('furk_login'), get_setting( 'furk_password') if not user_name or not user_pass: return url = base_url + login_url % (user_name, user_pass) result = requests.post(url, timeout=self.timeout) result = p.json() if self.check_status(result): from modules.kodi_utils import ext_addon api_key = result['api_key'] set_setting('furk_api_key', api_key) ext_addon('script.module.myaccounts').setSetting( 'furk.api.key', api_key) else: pass return api_key except: pass
def run(self): time = datetime.datetime.now() current_time = self._get_timestamp(time) due_clean = int(get_setting('database.maintenance.due', '0')) if current_time >= due_clean: logger('FEN', 'Database Maintenance Service Starting') monitor.waitForAbort(10.0) try: clean_databases(current_time, database_check=False, silent=True) except: pass next_clean = str( int(self._get_timestamp(time + datetime.timedelta(days=3)))) set_setting('database.maintenance.due', next_clean) return logger('FEN', 'Database Maintenance Service Finished')
def search(self, query): try: if '@files' in query: search_in = '' mod_level = 'no' else: search_in = '&attrs=name' mod_setting = int(get_setting('furk.mod.level', '0')) mod_level = 'no' if mod_setting == 0 else 'yes' if mod_setting == 1 else 'full' url = base_url + search_url % (self.api_key, query, 'extended', mod_level, search_in) string = 'fen_FURK_SEARCH_%s' % url return cache_object(self._process_files, string, url, json=False, expiration=48) except: return