#!/usr/bin/env python3
import json

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

new_entry = {
    'name': '精河县-环境影响评价',
    'script': 'crawl_xjjh_hjyxpj.py',
    'incremental': True,
    'args': '1',
    'sync_mode': 'direct_server',
    'enabled': True,
    'group': '区县政务公开',
    'note': '环境影响评价'
}

existing = [c for c in config['crawlers'] if c.get('script') == 'crawl_xjjh_hjyxpj.py']
if existing:
    print('Already exists:', json.dumps(existing, ensure_ascii=False))
else:
    config['crawlers'].append(new_entry)
    total = len(config['crawlers'])
    config['count'] = total
    with open('/root/gov_crawler/daily_crawl_config.json', 'w') as f:
        json.dump(config, f, ensure_ascii=False, indent=2)
    print(f'Added. Total: {total}')
