Merge pull request #170 from YJL626/patch-2

Catch the file format error and add a default value.
This commit is contained in:
LanQian 2024-10-27 15:58:22 +08:00 committed by GitHub
commit ce85014a92
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -71,7 +71,10 @@ else:
if os.path.exists(USER_AGENTS_FILE):
with open(USER_AGENTS_FILE, "r", encoding="utf-8") as f:
user_agent_map = json.load(f)
try:
user_agent_map = json.load(file)
except json.JSONDecodeError:
user_agent_map = {}
# token数量变化时更新ua
if len(user_agent_map.keys()) != len(token_list):
new_tokens = list(set(token_list) - user_agent_map.keys())