post_config.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # config.py
  2. class Config:
  3. # 当前绝对路径
  4. import os
  5. BASE_DIR = os.path.dirname(os.path.abspath(__file__))
  6. IMAGE_DIR = r"D:\桌面\研究生\组会\rednote\data"
  7. CHROME_DRIVER_PATH = r"D:/下载/chromedriver-win64/chromedriver-win64/chromedriver.exe"
  8. USER_DATA_DIR = r"user-data-dir=" + os.path.join(BASE_DIR, "user_data")
  9. PAGE_LOAD_TIMEOUT = 40
  10. ELEMENT_WAIT_TIMEOUT = 40
  11. # 发布配置默认值
  12. _POST_CONFIG = {
  13. 'image_paths': [],
  14. 'title': "你能告诉我这是什么风格吗?",
  15. 'description': "每天输出一套穿搭\n",
  16. 'topic': ["每日穿搭", "今日分享"],
  17. 'upload_time': "2025-07-07 10:26"
  18. }
  19. @classmethod
  20. def set_post_config(cls, **kwargs):
  21. """
  22. 设置发布配置
  23. :param kwargs: 可以包含 title, description, topic, upload_time
  24. """
  25. for key, value in kwargs.items():
  26. if key in cls._POST_CONFIG:
  27. cls._POST_CONFIG[key] = value
  28. else:
  29. raise ValueError(f"Invalid config key: {key}")
  30. @classmethod
  31. def get_post_config(cls):
  32. """
  33. 获取当前的发布配置
  34. :return: 当前的发布配置字典
  35. """
  36. return cls._POST_CONFIG.copy() # 返回副本以防止直接修改