|
@@ -3,6 +3,7 @@
|
|
|
"""
|
|
|
import logging
|
|
|
import os
|
|
|
+import random
|
|
|
import threading
|
|
|
import time
|
|
|
|
|
@@ -39,7 +40,7 @@ class LockManager:
|
|
|
return False
|
|
|
|
|
|
|
|
|
-def add_phone(lock_key: str, phones: set):
|
|
|
+def add_phone(lock_key: str, phones: list):
|
|
|
directory = f"./.data/{lock_key}"
|
|
|
if not os.path.exists(directory):
|
|
|
os.makedirs(directory)
|
|
@@ -49,7 +50,7 @@ def add_phone(lock_key: str, phones: set):
|
|
|
# 检查是否是文件夹
|
|
|
if os.path.isdir(full_path):
|
|
|
# 如果是文件夹,将文件夹名称添加到集合中
|
|
|
- phones.add(entry)
|
|
|
+ phones.append(entry)
|
|
|
print(f"已存在的{lock_key}账号:", phones)
|
|
|
|
|
|
|
|
@@ -59,8 +60,8 @@ lock_manager_dict = {
|
|
|
}
|
|
|
|
|
|
lock_phone_dict = {
|
|
|
- "huitun": set(),
|
|
|
- "xhs": set()
|
|
|
+ "huitun": list(),
|
|
|
+ "xhs": list()
|
|
|
}
|
|
|
|
|
|
for key in lock_phone_dict.keys():
|
|
@@ -71,7 +72,9 @@ def get_idle_phone(key: str):
|
|
|
lock_manager = lock_manager_dict[key]
|
|
|
api.assert_not_none(lock_manager, "lock_manager is None")
|
|
|
while True:
|
|
|
- for phone in lock_phone_dict[key]:
|
|
|
+ phone_list = lock_phone_dict[key]
|
|
|
+ for phone in phone_list:
|
|
|
if not lock_manager.is_locked(phone):
|
|
|
+ random.shuffle(phone_list)
|
|
|
return phone
|
|
|
time.sleep(1)
|