def TriggerDownloadSubtitle(rating_key=None, subtitle_id=None, item_title=None, language=None, randomize=None): from interface.main import fatality set_refresh_menu_state("Downloading subtitle for %s" % item_title or rating_key) search_results = get_item_task_data("AvailableSubsForItem", rating_key, language) download_subtitle = None for subtitle in search_results: if str(subtitle.id) == subtitle_id: download_subtitle = subtitle break if not download_subtitle: Log.Error(u"Something went horribly wrong") else: scheduler.dispatch_task("DownloadSubtitleForItem", rating_key=rating_key, subtitle=download_subtitle) scheduler.clear_task_data("AvailableSubsForItem") return fatality(randomize=timestamp(), header=" ", replace_parent=True)
def RefreshItem(rating_key=None, came_from="/recent", item_title=None, force=False, refresh_kind=None, previous_rating_key=None, timeout=8000, randomize=None, trigger=True): assert rating_key from interface.main import fatality header = " " if trigger: set_refresh_menu_state(u"Triggering %sRefresh for %s" % ("Force-" if force else "", item_title)) Thread.Create(refresh_item, rating_key=rating_key, force=force, refresh_kind=refresh_kind, parent_rating_key=previous_rating_key, timeout=int(timeout)) header = u"%s of item %s triggered" % ("Refresh" if not force else "Forced-refresh", rating_key) return fatality(randomize=timestamp(), header=header, replace_parent=True)
def TriggerRestart(randomize=None): set_refresh_menu_state("Restarting the plugin") DispatchRestart() return fatality(header="Restart triggered, please wait about 5 seconds", force_title=" ", only_refresh=True, replace_parent=True, no_history=True, randomize=timestamp())
def RefreshItem(rating_key=None, came_from="/recent", item_title=None, force=False): assert rating_key set_refresh_menu_state("Triggering %sRefresh for %s" % ("Force-" if force else "", item_title)) Thread.Create(refreshItem, rating_key=rating_key, force=force) return fatality( randomize=timestamp(), header="%s of item %s triggered" % ("Refresh" if not force else "Forced-refresh", rating_key), replace_parent=True, )
def RefreshItem(rating_key=None, came_from="/recent", item_title=None, force=False, refresh_kind=None, previous_rating_key=None, timeout=8000, randomize=None, trigger=True): assert rating_key header = " " if trigger: set_refresh_menu_state(u"Triggering %sRefresh for %s" % ("Force-" if force else "", item_title)) Thread.Create(refresh_item, rating_key=rating_key, force=force, refresh_kind=refresh_kind, parent_rating_key=previous_rating_key, timeout=int(timeout)) header = u"%s of item %s triggered" % ("Refresh" if not force else "Forced-refresh", rating_key) return fatality(randomize=timestamp(), header=header, replace_parent=True)
def TriggerRestart(randomize=None): set_refresh_menu_state("Restarting the plugin") Thread.CreateTimer(1.0, Restart) return fatality( header="Restart triggered, please wait about 5 seconds", force_title=" ", only_refresh=True, replace_parent=True, no_history=True, )
def TriggerRestart(randomize=None): set_refresh_menu_state(_("Restarting the plugin")) DispatchRestart() return fatality( header=_("Restart triggered, please wait about 5 seconds"), force_title=" ", only_refresh=True, replace_parent=True, no_history=True, randomize=timestamp())
def ValidatePrefs(): Core.log.setLevel(logging.DEBUG) Log.Debug("Validate Prefs called.") # cache the channel state update_dict = False restart = False # reset pin Dict["pin_correct_time"] = None config.initialize() if "channel_enabled" not in Dict: update_dict = True elif Dict["channel_enabled"] != config.enable_channel: Log.Debug("Channel features %s, restarting plugin", "enabled" if config.enable_channel else "disabled") update_dict = True restart = True if update_dict: Dict["channel_enabled"] = config.enable_channel Dict.Save() if restart: DispatchRestart() scheduler.setup_tasks() set_refresh_menu_state(None) if Prefs["log_console"]: Core.log.addHandler(logger.console_handler) Log.Debug("Logging to console from now on") else: Core.log.removeHandler(logger.console_handler) Log.Debug("Stop logging to console") Log.Debug("Setting log-level to %s", Prefs["log_level"]) logger.register_logging_handler(DEPENDENCY_MODULE_NAMES, level=Prefs["log_level"]) Core.log.setLevel(logging.getLevelName(Prefs["log_level"])) return
def ValidatePrefs(): Core.log.setLevel(logging.DEBUG) Log.Debug("Validate Prefs called.") config.initialize() scheduler.setup_tasks() set_refresh_menu_state(None) if Prefs["log_console"]: Core.log.addHandler(logger.console_handler) Log.Debug("Logging to console from now on") else: Core.log.removeHandler(logger.console_handler) Log.Debug("Stop logging to console") Log.Debug("Setting log-level to %s", Prefs["log_level"]) logger.registerLoggingHander(DEPENDENCY_MODULE_NAMES, level=Prefs["log_level"]) Core.log.setLevel(logging.getLevelName(Prefs["log_level"])) return
def TriggerDownloadSubtitle(rating_key=None, subtitle_id=None, item_title=None, language=None, randomize=None): from interface.main import fatality set_refresh_menu_state(_("Downloading subtitle for %(title_or_id)s", title_or_id=item_title or rating_key)) search_results = get_item_task_data("AvailableSubsForItem", rating_key, language) download_subtitle = None for subtitle in search_results: if str(subtitle.id) == subtitle_id: download_subtitle = subtitle break if not download_subtitle: Log.Error(u"Something went horribly wrong") else: scheduler.dispatch_task("DownloadSubtitleForItem", rating_key=rating_key, subtitle=download_subtitle) scheduler.clear_task_data("AvailableSubsForItem") return fatality(randomize=timestamp(), header=" ", replace_parent=True)
def RefreshItem(rating_key=None, came_from="/recent", item_title=None, force=False, refresh_kind=None, previous_rating_key=None, timeout=8000, randomize=None, trigger=True): assert rating_key from interface.main import fatality header = " " if trigger: t = u"Triggering refresh for %(title)s" if force: u"Triggering forced refresh for %(title)s" set_refresh_menu_state(_(t, title=item_title)) Thread.Create(refresh_item, rating_key=rating_key, force=force, refresh_kind=refresh_kind, parent_rating_key=previous_rating_key, timeout=int(timeout)) t = u"Refresh of item %(item_id)s triggered" if force: t = u"Forced refresh of item %(item_id)s triggered" header = _(t, item_id=rating_key) return fatality(randomize=timestamp(), header=header, replace_parent=True)
def ValidatePrefs(): Core.log.setLevel(logging.DEBUG) Log.Debug("Validate Prefs called.") # cache the channel state update_dict = False restart = False if "channel_enabled" not in Dict: update_dict = True elif Dict["channel_enabled"] != Prefs["enable_channel"]: Log.Debug("Channel features %s, restarting plugin", "enabled" if Prefs["enable_channel"] else "disabled") update_dict = True restart = True if update_dict: Dict["channel_enabled"] = Prefs["enable_channel"] Dict.Save() if restart: DispatchRestart() config.initialize() scheduler.setup_tasks() set_refresh_menu_state(None) if Prefs["log_console"]: Core.log.addHandler(logger.console_handler) Log.Debug("Logging to console from now on") else: Core.log.removeHandler(logger.console_handler) Log.Debug("Stop logging to console") Log.Debug("Setting log-level to %s", Prefs["log_level"]) logger.register_logging_handler(DEPENDENCY_MODULE_NAMES, level=Prefs["log_level"]) Core.log.setLevel(logging.getLevelName(Prefs["log_level"])) return
def RefreshItem(rating_key=None, came_from="/recent", item_title=None, force=False): assert rating_key set_refresh_menu_state("Triggering %sRefresh for %s" % ("Force-" if force else "", item_title)) Thread.Create(refreshItem, rating_key=rating_key, force=force) return fatality(randomize=timestamp(), header="%s of item %s triggered" % ("Refresh" if not force else "Forced-refresh", rating_key), replace_parent=True)
def ValidatePrefs(): Core.log.setLevel(logging.DEBUG) if Prefs["log_console"]: Core.log.addHandler(logger.console_handler) Log.Debug("Logging to console from now on") else: Core.log.removeHandler(logger.console_handler) Log.Debug("Stop logging to console") # cache the channel state update_dict = False restart = False # reset pin Dict["pin_correct_time"] = None config.initialize() if "channel_enabled" not in Dict: update_dict = True elif Dict["channel_enabled"] != config.enable_channel: Log.Debug("Interface features %s, restarting plugin", "enabled" if config.enable_channel else "disabled") update_dict = True restart = True if "plugin_pin_mode2" not in Dict: update_dict = True elif Dict["plugin_pin_mode2"] != Prefs["plugin_pin_mode2"]: update_dict = True restart = True if update_dict: Dict["channel_enabled"] = config.enable_channel Dict["plugin_pin_mode2"] = Prefs["plugin_pin_mode2"] Dict.Save() if restart: scheduler.stop() DispatchRestart() return scheduler.setup_tasks() scheduler.clear_task_data("MissingSubtitles") set_refresh_menu_state(None) Log.Debug("Validate Prefs called.") # SZ config debug Log.Debug("--- SZ Config-Debug ---") for attr in [ "version", "app_support_path", "data_path", "data_items_path", "enable_agent", "enable_channel", "permissions_ok", "missing_permissions", "fs_encoding", "subtitle_destination_folder", "include", "include_exclude_paths", "include_exclude_sz_files", "new_style_cache", "dbm_supported", "lang_list", "providers", "normal_subs", "forced_only", "forced_also", "plex_transcoder", "refiner_settings", "unrar", "adv_cfg_path", "use_custom_dns", "has_anticaptcha", "anticaptcha_cls", "mediainfo_bin" ]: value = getattr(config, attr) if isinstance(value, dict): d = replace_item(copy.deepcopy(value), "api_key", "xxxxxxxxxxxxxxxxxxxxxxxxx") Log.Debug("config.%s: %s", attr, d) continue if attr in ("api_key", ): value = "xxxxxxxxxxxxxxxxxxxxxxxxx" Log.Debug("config.%s: %s", attr, value) for attr in ["plugin_log_path", "server_log_path"]: value = getattr(config, attr) if value: access = os.access(value, os.R_OK) if Core.runtime.os == "Windows": try: f = open(value, "r") f.read(1) f.close() except: access = False Log.Debug("config.%s: %s (accessible: %s)", attr, value, access) for attr in [ "subtitles.save.filesystem", ]: Log.Debug("Pref.%s: %s", attr, Prefs[attr]) if "sonarr" in config.refiner_settings or "radarr" in config.refiner_settings: Thread.Create(check_connections) # fixme: check existance of and os access of logs Log.Debug("----- Environment -----") Log.Debug("Platform: %s", Core.runtime.platform) Log.Debug("OS: %s", Core.runtime.os) Log.Debug("Python: %s", platform.python_version()) for key, value in os.environ.iteritems(): if key.startswith("PLEX") or key.startswith("SZ_"): if "TOKEN" in key: outval = "xxxxxxxxxxxxxxxxxxx" else: outval = value Log.Debug("%s: %s", key, outval) Log.Debug("Locale: %s", locale.getdefaultlocale()) Log.Debug("-----------------------") Log.Debug("Setting log-level to %s", Prefs["log_level"]) logger.register_logging_handler(DEPENDENCY_MODULE_NAMES, level=Prefs["log_level"]) Core.log.setLevel(logging.getLevelName(Prefs["log_level"])) os.environ[ 'U1pfT01EQl9LRVk'] = '789CF30DAC2C8B0AF433F5C9AD34290A712DF30D7135F12D0FB3E502006FDE081E' return
def TriggerRestart(randomize=None): set_refresh_menu_state("Restarting the plugin") Thread.CreateTimer(1.0, Restart) return fatality(header="Restart triggered, please wait about 5 seconds", force_title=" ", only_refresh=True, replace_parent=True, no_history=True)
def ValidatePrefs(): Core.log.setLevel(logging.DEBUG) if Prefs["log_console"]: Core.log.addHandler(logger.console_handler) Log.Debug("Logging to console from now on") else: Core.log.removeHandler(logger.console_handler) Log.Debug("Stop logging to console") # cache the channel state update_dict = False restart = False # reset pin Dict["pin_correct_time"] = None config.initialize() if "channel_enabled" not in Dict: update_dict = True elif Dict["channel_enabled"] != config.enable_channel: Log.Debug("Channel features %s, restarting plugin", "enabled" if config.enable_channel else "disabled") update_dict = True restart = True if "plugin_pin_mode" not in Dict: update_dict = True elif Dict["plugin_pin_mode"] != Prefs["plugin_pin_mode"]: update_dict = True restart = True if update_dict: Dict["channel_enabled"] = config.enable_channel Dict["plugin_pin_mode"] = Prefs["plugin_pin_mode"] Dict.Save() if restart: scheduler.stop() DispatchRestart() return scheduler.stop() scheduler.setup_tasks() set_refresh_menu_state(None) Log.Debug("Validate Prefs called.") # SZ config debug Log.Debug("--- SZ Config-Debug ---") for attr in [ "app_support_path", "data_path", "data_items_path", "enable_agent", "enable_channel", "permissions_ok", "missing_permissions", "fs_encoding", "subtitle_destination_folder", "dbm_supported", "lang_list", "providers" ]: Log.Debug("config.%s: %s", attr, getattr(config, attr)) for attr in ["plugin_log_path", "server_log_path"]: value = getattr(config, attr) access = os.access(value, os.R_OK) if Core.runtime.os == "Windows": try: f = open(value, "r") f.read(1) f.close() except: access = False Log.Debug("config.%s: %s (accessible: %s)", attr, value, access) for attr in [ "subtitles.save.filesystem", ]: Log.Debug("Pref.%s: %s", attr, Prefs[attr]) # fixme: check existance of and os access of logs Log.Debug("Platform: %s", Core.runtime.platform) Log.Debug("OS: %s", Core.runtime.os) Log.Debug("----- Environment -----") for key, value in os.environ.iteritems(): if key.startswith("PLEX") or key.startswith("SZ_"): if "TOKEN" in key: outval = "xxxxxxxxxxxxxxxxxxx" else: outval = value Log.Debug("%s: %s", key, outval) Log.Debug("Locale: %s", locale.getdefaultlocale()) Log.Debug("-----------------------") Log.Debug("Setting log-level to %s", Prefs["log_level"]) logger.register_logging_handler(DEPENDENCY_MODULE_NAMES, level=Prefs["log_level"]) Core.log.setLevel(logging.getLevelName(Prefs["log_level"])) os.environ[ 'U1pfT01EQl9LRVk'] = '789CF30DAC2C8B0AF433F5C9AD34290A712DF30D7135F12D0FB3E502006FDE081E' return
def ValidatePrefs(): Core.log.setLevel(logging.DEBUG) if Prefs["log_console"]: Core.log.addHandler(logger.console_handler) Log.Debug("Logging to console from now on") else: Core.log.removeHandler(logger.console_handler) Log.Debug("Stop logging to console") # cache the channel state update_dict = False restart = False # reset pin Dict["pin_correct_time"] = None config.initialize() if "channel_enabled" not in Dict: update_dict = True elif Dict["channel_enabled"] != config.enable_channel: Log.Debug("Interface features %s, restarting plugin", "enabled" if config.enable_channel else "disabled") update_dict = True restart = True if "plugin_pin_mode2" not in Dict: update_dict = True elif Dict["plugin_pin_mode2"] != Prefs["plugin_pin_mode2"]: update_dict = True restart = True if update_dict: Dict["channel_enabled"] = config.enable_channel Dict["plugin_pin_mode2"] = Prefs["plugin_pin_mode2"] Dict.Save() if restart: scheduler.stop() DispatchRestart() return scheduler.setup_tasks() scheduler.clear_task_data("MissingSubtitles") set_refresh_menu_state(None) Log.Debug("Validate Prefs called.") # SZ config debug Log.Debug("--- SZ Config-Debug ---") for attr in [ "version", "app_support_path", "data_path", "data_items_path", "enable_agent", "enable_channel", "permissions_ok", "missing_permissions", "fs_encoding", "subtitle_destination_folder", "include", "include_exclude_paths", "include_exclude_sz_files", "new_style_cache", "dbm_supported", "lang_list", "providers", "normal_subs", "forced_only", "forced_also", "plex_transcoder", "refiner_settings", "unrar", "adv_cfg_path", "use_custom_dns", "has_anticaptcha", "anticaptcha_cls"]: value = getattr(config, attr) if isinstance(value, dict): d = replace_item(copy.deepcopy(value), "api_key", "xxxxxxxxxxxxxxxxxxxxxxxxx") Log.Debug("config.%s: %s", attr, d) continue if attr in ("api_key",): value = "xxxxxxxxxxxxxxxxxxxxxxxxx" Log.Debug("config.%s: %s", attr, value) for attr in ["plugin_log_path", "server_log_path"]: value = getattr(config, attr) if value: access = os.access(value, os.R_OK) if Core.runtime.os == "Windows": try: f = open(value, "r") f.read(1) f.close() except: access = False Log.Debug("config.%s: %s (accessible: %s)", attr, value, access) for attr in [ "subtitles.save.filesystem", ]: Log.Debug("Pref.%s: %s", attr, Prefs[attr]) if "sonarr" in config.refiner_settings or "radarr" in config.refiner_settings: Thread.Create(check_connections) # fixme: check existance of and os access of logs Log.Debug("----- Environment -----") Log.Debug("Platform: %s", Core.runtime.platform) Log.Debug("OS: %s", Core.runtime.os) Log.Debug("Python: %s", platform.python_version()) for key, value in os.environ.iteritems(): if key.startswith("PLEX") or key.startswith("SZ_"): if "TOKEN" in key: outval = "xxxxxxxxxxxxxxxxxxx" else: outval = value Log.Debug("%s: %s", key, outval) Log.Debug("Locale: %s", locale.getdefaultlocale()) Log.Debug("-----------------------") Log.Debug("Setting log-level to %s", Prefs["log_level"]) logger.register_logging_handler(DEPENDENCY_MODULE_NAMES, level=Prefs["log_level"]) Core.log.setLevel(logging.getLevelName(Prefs["log_level"])) os.environ['U1pfT01EQl9LRVk'] = '789CF30DAC2C8B0AF433F5C9AD34290A712DF30D7135F12D0FB3E502006FDE081E' return
def ValidatePrefs(): Core.log.setLevel(logging.DEBUG) if Prefs["log_console"]: Core.log.addHandler(logger.console_handler) Log.Debug("Logging to console from now on") else: Core.log.removeHandler(logger.console_handler) Log.Debug("Stop logging to console") # cache the channel state update_dict = False restart = False # reset pin Dict["pin_correct_time"] = None config.initialize() if "channel_enabled" not in Dict: update_dict = True elif Dict["channel_enabled"] != config.enable_channel: Log.Debug("Interface features %s, restarting plugin", "enabled" if config.enable_channel else "disabled") update_dict = True restart = True if "plugin_pin_mode2" not in Dict: update_dict = True elif Dict["plugin_pin_mode2"] != Prefs["plugin_pin_mode2"]: update_dict = True restart = True if update_dict: Dict["channel_enabled"] = config.enable_channel Dict["plugin_pin_mode2"] = Prefs["plugin_pin_mode2"] Dict.Save() if restart: scheduler.stop() DispatchRestart() return scheduler.setup_tasks() scheduler.clear_task_data("MissingSubtitles") set_refresh_menu_state(None) Log.Debug("Validate Prefs called.") # SZ config debug Log.Debug("--- SZ Config-Debug ---") for attr in [ "version", "app_support_path", "data_path", "data_items_path", "enable_agent", "enable_channel", "permissions_ok", "missing_permissions", "fs_encoding", "subtitle_destination_folder", "new_style_cache", "dbm_supported", "lang_list", "providers", "plex_transcoder", "refiner_settings", "unrar", "adv_cfg_path"]: value = getattr(config, attr) if isinstance(value, dict): d = replace_item(copy.deepcopy(value), "api_key", "xxxxxxxxxxxxxxxxxxxxxxxxx") Log.Debug("config.%s: %s", attr, d) continue Log.Debug("config.%s: %s", attr, value) for attr in ["plugin_log_path", "server_log_path"]: value = getattr(config, attr) if value: access = os.access(value, os.R_OK) if Core.runtime.os == "Windows": try: f = open(value, "r") f.read(1) f.close() except: access = False Log.Debug("config.%s: %s (accessible: %s)", attr, value, access) for attr in [ "subtitles.save.filesystem", ]: Log.Debug("Pref.%s: %s", attr, Prefs[attr]) # debug drone if "sonarr" in config.refiner_settings or "radarr" in config.refiner_settings: Log.Debug("----- Connections -----") try: from subliminal_patch.refiners.drone import SonarrClient, RadarrClient for key, cls in [("sonarr", SonarrClient), ("radarr", RadarrClient)]: if key in config.refiner_settings: cname = key.capitalize() try: status = cls(**config.refiner_settings[key]).status() except HTTPError, e: if e.response.status_code == 401: Log.Debug("%s: NOT WORKING - BAD API KEY", cname) else: Log.Debug("%s: NOT WORKING - %s", cname, traceback.format_exc()) except: Log.Debug("%s: NOT WORKING - %s", cname, traceback.format_exc()) else: if status and status["version"]: Log.Debug("%s: OK - %s", cname, status["version"]) else: Log.Debug("%s: NOT WORKING - %s", cname)