Exemplo n.º 1
0
    def initialize(self):
        self.libraries_root = os.path.abspath(
            os.path.join(get_root_path(), ".."))
        self.init_libraries()

        if is_windows_special_path:
            Log.Warn(
                "The Plex metadata folder is residing inside a folder with special characters. "
                "Multithreading and playback activities will be disabled.")

        self.fs_encoding = get_viable_encoding()
        self.plugin_info = self.get_plugin_info()
        self.is_development = self.get_dev_mode()
        self.version = self.get_version()
        self.full_version = u"%s %s" % (PLUGIN_NAME, self.version)
        self.set_log_paths()
        self.app_support_path = Core.app_support_path
        self.data_path = getattr(Data, "_core").storage.data_path
        self.data_items_path = os.path.join(self.data_path, "DataItems")
        self.universal_plex_token = self.get_universal_plex_token()
        self.plex_token = os.environ.get("PLEXTOKEN",
                                         self.universal_plex_token)
        subzero.constants.DEFAULT_TIMEOUT = lib.DEFAULT_TIMEOUT = self.pms_request_timeout = \
            min(cast_int(Prefs['pms_request_timeout'], 15), 45)
        self.low_impact_mode = cast_bool(Prefs['low_impact_mode'])
        self.new_style_cache = cast_bool(Prefs['new_style_cache'])
        self.pack_cache_dir = self.get_pack_cache_dir()
        self.advanced = self.get_advanced_config()

        os.environ["SZ_USER_AGENT"] = self.get_user_agent()

        self.setup_proxies()
        self.set_plugin_mode()
        self.set_plugin_lock()
        self.set_activity_modes()
        self.parse_rename_mode()

        self.subtitle_destination_folder = self.get_subtitle_destination_folder(
        )
        self.subtitle_formats = self.get_subtitle_formats()
        self.forced_only = cast_bool(Prefs["subtitles.only_foreign"])
        self.max_recent_items_per_library = int_or_default(
            Prefs["scheduler.max_recent_items_per_library"], 2000)
        self.sections = list(Plex["library"].sections())
        self.missing_permissions = []
        self.ignore_sz_files = cast_bool(Prefs["subtitles.ignore_fs"])
        self.ignore_paths = self.parse_ignore_paths()
        self.enabled_sections = self.check_enabled_sections()
        self.permissions_ok = self.check_permissions()
        self.notify_executable = self.check_notify_executable()
        self.remove_hi = cast_bool(Prefs['subtitles.remove_hi'])
        self.remove_tags = cast_bool(Prefs['subtitles.remove_tags'])
        self.fix_ocr = cast_bool(Prefs['subtitles.fix_ocr'])
        self.fix_common = cast_bool(Prefs['subtitles.fix_common'])
        self.reverse_rtl = cast_bool(Prefs['subtitles.reverse_rtl'])
        self.colors = Prefs['subtitles.colors'] if Prefs[
            'subtitles.colors'] != "don't change" else None
        self.chmod = self.check_chmod()
        self.exotic_ext = cast_bool(Prefs["subtitles.scan.exotic_ext"])
        self.treat_und_as_first = cast_bool(
            Prefs["subtitles.language.treat_und_as_first"])
        self.subtitle_sub_dir = self.get_subtitle_sub_dir()
        self.ext_match_strictness = self.determine_ext_sub_strictness()
        self.default_mods = self.get_default_mods()
        self.debug_mods = cast_bool(Prefs['log_debug_mods'])
        self.no_refresh = os.environ.get("SZ_NO_REFRESH", False)
        self.plex_transcoder = self.get_plex_transcoder()
        self.only_one = cast_bool(Prefs['subtitles.only_one'])
        self.embedded_auto_extract = cast_bool(
            Prefs["subtitles.embedded.autoextract"])
        self.ietf_as_alpha3 = cast_bool(
            Prefs["subtitles.language.ietf_normalize"])
        self.initialized = True
Exemplo n.º 2
0
    def initialize(self):
        self.libraries_root = os.path.abspath(os.path.join(get_root_path(), ".."))
        self.init_libraries()

        if is_windows_special_path:
            Log.Warn("The Plex metadata folder is residing inside a folder with special characters. "
                     "Multithreading and playback activities will be disabled.")

        self.fs_encoding = get_viable_encoding()
        self.plugin_info = self.get_plugin_info()
        self.is_development = self.get_dev_mode()
        self.version = self.get_version()
        self.full_version = u"%s %s" % (PLUGIN_NAME, self.version)
        self.set_log_paths()
        self.app_support_path = Core.app_support_path
        self.data_path = getattr(Data, "_core").storage.data_path
        self.data_items_path = os.path.join(self.data_path, "DataItems")
        self.universal_plex_token = self.get_universal_plex_token()
        self.plex_token = os.environ.get("PLEXTOKEN", self.universal_plex_token)
        self.new_style_cache = cast_bool(Prefs['new_style_cache'])
        self.pack_cache_dir = self.get_pack_cache_dir()
        try:
            self.migrate_prefs()
        except:
            Log.Exception("Catastrophic failure when running prefs migration")

        subzero.constants.DEFAULT_TIMEOUT = lib.DEFAULT_TIMEOUT = self.pms_request_timeout = \
            min(cast_int(Prefs['pms_request_timeout'], 15), 45)
        self.low_impact_mode = cast_bool(Prefs['low_impact_mode'])
        self.advanced = self.get_advanced_config()
        self.debug_i18n = self.advanced.debug_i18n

        os.environ["SZ_USER_AGENT"] = self.get_user_agent()
        os.environ["ANTICAPTCHA_ACCOUNT_KEY"] = self.anticaptcha_token = str(Prefs["anticaptcha.api_key"]) or ""
        acs = str(Prefs["anticaptcha.service"])
        if acs and acs != "none":
            os.environ["ANTICAPTCHA_CLASS"] = self.anticaptcha_cls = acs
        self.has_anticaptcha = self.anticaptcha_token and self.anticaptcha_cls

        self.setup_proxies()
        self.set_plugin_mode()
        self.set_plugin_lock()
        self.set_activity_modes()
        self.parse_rename_mode()

        self.normal_subs = Prefs["subtitles.when"] != "Never"
        self.forced_also = self.normal_subs and Prefs["subtitles.when_forced"] != "Never"
        self.forced_only = not self.normal_subs and Prefs["subtitles.when_forced"] != "Never"
        self.include = \
            Prefs["subtitles.include_exclude_mode"] == "disable SZ for all items by default, use include lists"
        self.subtitle_destination_folder = self.get_subtitle_destination_folder()
        self.subtitle_formats = self.get_subtitle_formats()
        self.max_recent_items_per_library = int_or_default(Prefs["scheduler.max_recent_items_per_library"], 2000)
        self.sections = list(Plex["library"].sections())
        self.missing_permissions = []
        self.include_exclude_sz_files = cast_bool(Prefs["subtitles.include_exclude_fs"])
        self.include_exclude_paths = self.parse_include_exclude_paths()
        self.enabled_sections = self.check_enabled_sections()
        self.permissions_ok = self.check_permissions()
        self.notify_executable = self.check_notify_executable()
        self.remove_hi = cast_bool(Prefs['subtitles.remove_hi'])
        self.remove_tags = cast_bool(Prefs['subtitles.remove_tags'])
        self.fix_ocr = cast_bool(Prefs['subtitles.fix_ocr'])
        self.fix_common = cast_bool(Prefs['subtitles.fix_common'])
        self.fix_upper = cast_bool(Prefs['subtitles.fix_only_uppercase'])
        self.reverse_rtl = cast_bool(Prefs['subtitles.reverse_rtl'])
        self.colors = Prefs['subtitles.colors'] if Prefs['subtitles.colors'] != "don't change" else None
        self.chmod = self.check_chmod()
        self.exotic_ext = cast_bool(Prefs["subtitles.scan.exotic_ext"])
        self.treat_und_as_first = cast_bool(Prefs["subtitles.language.treat_und_as_first"])
        self.subtitle_sub_dir = self.get_subtitle_sub_dir()
        self.ext_match_strictness = self.determine_ext_sub_strictness()
        self.default_mods = self.get_default_mods()
        self.debug_mods = cast_bool(Prefs['log_debug_mods'])
        self.no_refresh = os.environ.get("SZ_NO_REFRESH", False)
        self.plex_transcoder = self.get_plex_transcoder()
        self.only_one = cast_bool(Prefs['subtitles.only_one'])
        self.any_language_is_enough = Prefs['subtitles.any_language_is_enough']
        self.embedded_auto_extract = cast_bool(Prefs["subtitles.embedded.autoextract"])
        self.ietf_as_alpha3 = cast_bool(Prefs["subtitles.language.ietf_normalize"])
        self.use_custom_dns = self.parse_custom_dns()
        self.initialized = True