import os
import importlib

# 数据库配置
MONGO_URI = "mongodb://localhost:27017"
MONGO_DB_NAME = "Rankings"
# MONGO_URI = "mongodb://mongouser:Jdei2243afN@172.16.0.6:27017,172.16.0.4:27017/test?replicaSet=cmgo-r6qkaern_0&authSource=admin"
# MONGO_DB_NAME = "kemeng_media"

# 应用配置
APP_ENV = os.getenv('APP_ENV', 'development')
DEBUG = APP_ENV == 'development'

# 日志配置
LOG_LEVEL = 'INFO'
LOG_DIR = 'logs'

# 定时器配置
SCHEDULER_TIME = "24:00"  # 定时器执行时间，格式为 HH:MM (24小时制)

# 定时器环境变量配置
TIMER_ENV_CONFIG = {
    'TIMER_MODE': '1',      # 启用定时器模式，使数据保存到 Ranking_storage_list 集合
    'AUTO_CONTINUE': '1'    # 启用自动模式，跳过详细数据获取以提高性能
}

# 自动模式跳过函数配置
AUTO_CONTINUE_SKIP_FUNCTIONS = [
    'get_collection_video_details',  # 跳过合集视频详细数据获取
    'scroll_comments',               # 跳过评论滚动
    # 可以在这里添加更多需要跳过的函数名
]

# TOS/火山云对象存储配置
TOS_CONFIG = {
    'access_key_id': os.getenv('TOS_ACCESS_KEY_ID', 'AKLTYjQyYmE1ZDAwZTY5NGZiOWI3ODZkZDhhOWE4MzVjODE'),
    'access_key_secret': os.getenv('TOS_ACCESS_KEY_SECRET', 'WlRKa05EbGhZVEUyTXpjNU5ESmpPRGt5T0RJNFl6QmhPR0pqTVRjMVpUWQ=='),
    'endpoint': 'https://tos-cn-beijing.volces.com',
    'region': 'cn-beijing',
    'bucket_name': os.getenv('TOS_BUCKET_NAME', 'km1'),
    'self_domain': os.getenv('TOS_SELF_DOMAIN', 'oss.xintiao85.com'),
    'disable_ssl_warnings': True
}

# API配置（兼容现有代码）
API_CONFIG = {
    'huoshan': {
        'AccessKey': TOS_CONFIG['access_key_id'],
        'SecretKey': TOS_CONFIG['access_key_secret']
    },
    'OSS_BUCKET_NAME': TOS_CONFIG['bucket_name'],
    'OSS_HOST': TOS_CONFIG['self_domain']
}

def apply_timer_environment():
    """应用定时器环境变量配置"""
    for key, value in TIMER_ENV_CONFIG.items():
        os.environ[key] = value

def get_skip_functions():
    """获取自动模式下需要跳过的函数列表"""
    return AUTO_CONTINUE_SKIP_FUNCTIONS.copy()

print(f"Successfully loaded configuration for environment: {APP_ENV}")