From 2ae365c5fe8b4c213ab7f30be3a370db83586f0e Mon Sep 17 00:00:00 2001 From: EstrellaXD Date: Sat, 6 May 2023 11:03:16 +0800 Subject: [PATCH 1/3] Fix official problem --- docs/wiki | 2 +- src/module/core/api_func.py | 6 +++--- src/module/models/config.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/wiki b/docs/wiki index 4b8d32e6..a49828bf 160000 --- a/docs/wiki +++ b/docs/wiki @@ -1 +1 @@ -Subproject commit 4b8d32e6e01cd8d02e833caa04ec23c100befe84 +Subproject commit a49828bf9c81da27812639924855d99b0e3b0760 diff --git a/src/module/core/api_func.py b/src/module/core/api_func.py index 46b841ea..69bc482a 100644 --- a/src/module/core/api_func.py +++ b/src/module/core/api_func.py @@ -86,16 +86,16 @@ class APIProcess: return json_config.load(CONFIG_PATH) def get_rss(self, full_path: str): - url = f"https://mikanime.tv/RSS/{full_path}" + url = f"https://mikanani.me/RSS/{full_path}" custom_url = self._custom_url if "://" not in custom_url: custom_url = f"https://{custom_url}" with RequestContent() as request: content = request.get_html(url) - return re.sub(r"https://mikanime.tv", custom_url, content) + return re.sub(r"https://mikanani.me", custom_url, content) @staticmethod def get_torrent(full_path): - url = f"https://mikanime.tv/Download/{full_path}" + url = f"https://mikanani.me/Download/{full_path}" with RequestContent() as request: return request.get_content(url) diff --git a/src/module/models/config.py b/src/module/models/config.py index d591160f..1690cafe 100644 --- a/src/module/models/config.py +++ b/src/module/models/config.py @@ -22,7 +22,7 @@ class RSSParser(BaseModel): enable: bool = Field(True, description="Enable RSS parser") type: str = Field("mikan", description="RSS parser type") token: str = Field("token", description="RSS parser token") - custom_url: str = Field("mikanime.tv", description="Custom RSS host url") + custom_url: str = Field("mikanani.me", description="Custom RSS host url") enable_tmdb: bool = Field(False, description="Enable TMDB") filter: list[str] = Field(["720", r"\d+-\d"], description="Filter") language: str = "zh" From eec7bfbdc9f1f3222aa814628c787bbc6ffeb875 Mon Sep 17 00:00:00 2001 From: EstrellaXD Date: Sat, 6 May 2023 11:23:03 +0800 Subject: [PATCH 2/3] Temp save --- src/module/conf/__init__.py | 1 + src/module/conf/config.py | 38 +++++++++++++++++-------------------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/module/conf/__init__.py b/src/module/conf/__init__.py index a84acc3e..813d23eb 100644 --- a/src/module/conf/__init__.py +++ b/src/module/conf/__init__.py @@ -14,3 +14,4 @@ class RSSLink(str): PLATFORM = "Windows" if "\\" in settings.downloader.path else "Unix" +MIKANANI_URL = "mikanani.me" diff --git a/src/module/conf/config.py b/src/module/conf/config.py index b5bd6e12..2e025010 100644 --- a/src/module/conf/config.py +++ b/src/module/conf/config.py @@ -16,6 +16,21 @@ except ImportError: class Setting(Config): + def __init__(self): + if VERSION != "DEV_VERSION": + CONFIG_PATH = "config/config.json" + else: + CONFIG_PATH = "config/config_dev.json" + if os.path.isfile(CONFIG_PATH): + config = load_config_from_file(CONFIG_PATH) + else: + logger.info(f"Can't find config file, use env instead") + load_dotenv() + config = env_to_config() + super().__init__(config) + save_config_to_file(self, CONFIG_PATH) + self.reload() + @staticmethod def reload(): load_config_from_file(CONFIG_PATH) @@ -34,7 +49,7 @@ def save_config_to_file(config: Config, path: str): def load_config_from_file(path: str) -> Config: with open(path, "r", encoding="utf-8") as f: config = json.load(f) - return Setting(**config) + return config def _val_from_env(env: str, attr: tuple): @@ -57,26 +72,7 @@ def env_to_config() -> Setting: else: attr_name = attr[0] if isinstance(attr, tuple) else attr _settings[key][attr_name] = _val_from_env(env, attr) - return Setting(**_settings) - - -if os.path.isdir("config") and VERSION == "DEV_VERSION": - CONFIG_PATH = "config/config_dev.json" - if os.path.isfile(CONFIG_PATH): - settings = load_config_from_file(CONFIG_PATH) - else: - load_dotenv(".env") - settings = env_to_config() - save_config_to_file(settings, CONFIG_PATH) -elif os.path.isdir("config") and VERSION != "DEV_VERSION": - CONFIG_PATH = "config/config.json" - if os.path.isfile(CONFIG_PATH): - settings = load_config_from_file(CONFIG_PATH) - else: - settings = env_to_config() - save_config_to_file(settings, CONFIG_PATH) -else: - settings = Setting() + return _settings From bf5ac1b6577a805ebc5a272c2e29ee82af35a515 Mon Sep 17 00:00:00 2001 From: EstrellaXD Date: Sat, 6 May 2023 15:01:25 +0800 Subject: [PATCH 3/3] Revert --- src/module/conf/config.py | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/module/conf/config.py b/src/module/conf/config.py index 2e025010..7fe0e841 100644 --- a/src/module/conf/config.py +++ b/src/module/conf/config.py @@ -16,21 +16,6 @@ except ImportError: class Setting(Config): - def __init__(self): - if VERSION != "DEV_VERSION": - CONFIG_PATH = "config/config.json" - else: - CONFIG_PATH = "config/config_dev.json" - if os.path.isfile(CONFIG_PATH): - config = load_config_from_file(CONFIG_PATH) - else: - logger.info(f"Can't find config file, use env instead") - load_dotenv() - config = env_to_config() - super().__init__(config) - save_config_to_file(self, CONFIG_PATH) - self.reload() - @staticmethod def reload(): load_config_from_file(CONFIG_PATH) @@ -49,7 +34,7 @@ def save_config_to_file(config: Config, path: str): def load_config_from_file(path: str) -> Config: with open(path, "r", encoding="utf-8") as f: config = json.load(f) - return config + return Setting(**config) def _val_from_env(env: str, attr: tuple): @@ -72,8 +57,26 @@ def env_to_config() -> Setting: else: attr_name = attr[0] if isinstance(attr, tuple) else attr _settings[key][attr_name] = _val_from_env(env, attr) - return _settings - + return Setting(**_settings) + + +if os.path.isdir("config") and VERSION == "DEV_VERSION": + CONFIG_PATH = "config/config_dev.json" + if os.path.isfile(CONFIG_PATH): + settings = load_config_from_file(CONFIG_PATH) + else: + load_dotenv(".env") + settings = env_to_config() + save_config_to_file(settings, CONFIG_PATH) +elif os.path.isdir("config") and VERSION != "DEV_VERSION": + CONFIG_PATH = "config/config.json" + if os.path.isfile(CONFIG_PATH): + settings = load_config_from_file(CONFIG_PATH) + else: + settings = env_to_config() + save_config_to_file(settings, CONFIG_PATH) +else: + settings = Setting()