利用 AI 大模型和自动化工作流,根据主题或关键词一键生成高清短视频。Generate HD short videos from a topic or keyword with an automated AI workflow.
Python ai-video-generatorcontent-creationffmpeginstagram-reelsllmpythonshort-videosubtitlestext-to-speechtiktokvideo-automationvideo-workflowworkflow-automationyoutube-shorts
fix(upload_post): use dynamic properties to read runtime config changes without restart
Praveen Bishnoi469f898f1eeb
diff --git a/app/services/upload_post.py b/app/services/upload_post.pyindex bb58ae85..a3133923 100644--- a/app/services/upload_post.py+++ b/app/services/upload_post.py@@ -14,13 +14,29 @@ from app.config import configclass UploadPostService:API_BASE = "https://api.upload-post.com"- def __init__(self):- self.api_key = config.app.get("upload_post_api_key", "")- self.username = config.app.get("upload_post_username", "")- self.enabled = config.app.get("upload_post_enabled", False)- self.platforms = config.app.get("upload_post_platforms", ["tiktok", "instagram"])- self.auto_upload = config.app.get("upload_post_auto_upload", False)- self.youtube_privacy_status = config.app.get("upload_post_youtube_privacy_status", "public")+ @property+ def api_key(self) -> str:+ return config.app.get("upload_post_api_key", "")++ @property+ def username(self) -> str:+ return config.app.get("upload_post_username", "")++ @property+ def enabled(self) -> bool:+ return config.app.get("upload_post_enabled", False)++ @property+ def platforms(self) -> list:+ return config.app.get("upload_post_platforms", ["tiktok", "instagram"])++ @property+ def auto_upload(self) -> bool:+ return config.app.get("upload_post_auto_upload", False)++ @property+ def youtube_privacy_status(self) -> str:+ return config.app.get("upload_post_youtube_privacy_status", "public")def is_configured(self) -> bool:return bool(self.api_key and self.username and self.enabled)diff --git a/test/services/test_upload_post.py b/test/services/test_upload_post.pyindex 6c761800..9bbb6115 100644--- a/test/services/test_upload_post.py+++ b/test/services/test_upload_post.py@@ -189,3 +189,36 @@ class TestUploadPostYouTubePayload(unittest.TestCase):if __name__ == "__main__":unittest.main()+++class TestUploadPostServiceDynamicConfig(unittest.TestCase):+ def test_upload_post_service_dynamically_reads_config(self):+ test_app_config = {+ "upload_post_api_key": "",+ "upload_post_username": "",+ "upload_post_enabled": False,+ "upload_post_auto_upload": False,+ "upload_post_platforms": ["tiktok"],+ }++ with patch("app.services.upload_post.config.app", test_app_config):+ service = UploadPostService()+ self.assertFalse(service.is_configured())+ self.assertFalse(service.enabled)+ self.assertFalse(service.auto_upload)++ test_app_config["upload_post_enabled"] = True+ test_app_config["upload_post_auto_upload"] = True+ test_app_config["upload_post_api_key"] = "test-key"+ test_app_config["upload_post_username"] = "test-user"+ test_app_config["upload_post_platforms"] = ["tiktok", "instagram"]++ self.assertTrue(service.enabled)+ self.assertTrue(service.auto_upload)+ self.assertEqual(service.api_key, "test-key")+ self.assertTrue(service.is_configured())+ self.assertIn("instagram", service.platforms)++ test_app_config["upload_post_enabled"] = False+ self.assertFalse(service.enabled)+ self.assertFalse(service.is_configured())