Skip to content

利用 AI 大模型和自动化工作流,根据主题或关键词一键生成高清短视频。Generate HD short videos from a topic or keyword with an automated AI workflow.

Add exception handling for reading the configuration file and optimize the loading method

harry5933a4762013
diff --git a/app/config/config.py b/app/config/config.py
index 0c3120b7..afec11ba 100644
--- a/app/config/config.py
+++ b/app/config/config.py
@@ -15,8 +15,14 @@ if not os.path.isfile(config_file):
logger.info(f"load config from file: {config_file}")
-with open(config_file, mode="rb") as fp:
- _cfg = tomli.load(fp)
+try:
+ with open(config_file, mode="rb") as fp:
+ _cfg = tomli.load(fp)
+except Exception as e:
+ logger.warning(f"load config failed: {str(e)}, try to load as utf-8-sig")
+ with open(config_file, mode="r", encoding='utf-8-sig') as fp:
+ _cfg_content = fp.read()
+ _cfg = tomli.loads(_cfg_content)
app = _cfg.get("app", {})
whisper = _cfg.get("whisper", {})