import json

with open("/root/gov_crawler/daily_crawl_config.json") as f:
    config = json.load(f)

new_entries = [
    {
        "name": "ahxx_shengquan",
        "display_name": "萧县圣泉镇-重大行政决策预公开",
        "script": "crawl_ahxx.py",
        "args": "--incremental",
        "schedule": "0 8 * * *",
        "site_url": "www.ahxx.gov.cn",
        "group": "政务",
        "enabled": True,
    },
    {
        "name": "ahxx_jingkaiqu",
        "display_name": "萧县经开区-意见征集",
        "script": "crawl_ahxx.py",
        "args": "--incremental",
        "schedule": "0 8 * * *",
        "site_url": "www.ahxx.gov.cn",
        "group": "政务",
        "enabled": True,
    },
]

for entry in new_entries:
    exists = any(c.get("name") == entry["name"] for c in config.get("crawlers", []))
    if not exists:
        config.setdefault("crawlers", []).append(entry)
        print("Added: " + entry["name"])
    else:
        print("Already exists: " + entry["name"])

with open("/root/gov_crawler/daily_crawl_config.json", "w") as f:
    json.dump(config, f, ensure_ascii=False, indent=2)

print("Done")
