fix: 保存cookie前创建cookiesFile目录以防止文件不存在错误
- 在所有平台的cookie生成函数中添加目录创建逻辑 - 修复cookiesFile目录不存在导致cookie保存失败的问题 - 影响的函数:douyin_cookie_gen、get_tencent_cookie、get_ks_cookie和xiaohongshu_cookie_gen 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+16
-4
@@ -50,7 +50,10 @@ async def douyin_cookie_gen(id,status_queue):
|
||||
return None
|
||||
uuid_v1 = uuid.uuid1()
|
||||
print(f"UUID v1: {uuid_v1}")
|
||||
await context.storage_state(path=Path(BASE_DIR / "cookiesFile" / f"{uuid_v1}.json"))
|
||||
# 确保cookiesFile目录存在
|
||||
cookies_dir = Path(BASE_DIR / "cookiesFile")
|
||||
cookies_dir.mkdir(exist_ok=True)
|
||||
await context.storage_state(path=cookies_dir / f"{uuid_v1}.json")
|
||||
result = await check_cookie(3, f"{uuid_v1}.json")
|
||||
if not result:
|
||||
status_queue.put("500")
|
||||
@@ -125,7 +128,10 @@ async def get_tencent_cookie(id,status_queue):
|
||||
return None
|
||||
uuid_v1 = uuid.uuid1()
|
||||
print(f"UUID v1: {uuid_v1}")
|
||||
await context.storage_state(path=Path(BASE_DIR / "cookiesFile" / f"{uuid_v1}.json"))
|
||||
# 确保cookiesFile目录存在
|
||||
cookies_dir = Path(BASE_DIR / "cookiesFile")
|
||||
cookies_dir.mkdir(exist_ok=True)
|
||||
await context.storage_state(path=cookies_dir / f"{uuid_v1}.json")
|
||||
result = await check_cookie(2,f"{uuid_v1}.json")
|
||||
if not result:
|
||||
status_queue.put("500")
|
||||
@@ -196,7 +202,10 @@ async def get_ks_cookie(id,status_queue):
|
||||
return None
|
||||
uuid_v1 = uuid.uuid1()
|
||||
print(f"UUID v1: {uuid_v1}")
|
||||
await context.storage_state(path=Path(BASE_DIR / "cookiesFile" / f"{uuid_v1}.json"))
|
||||
# 确保cookiesFile目录存在
|
||||
cookies_dir = Path(BASE_DIR / "cookiesFile")
|
||||
cookies_dir.mkdir(exist_ok=True)
|
||||
await context.storage_state(path=cookies_dir / f"{uuid_v1}.json")
|
||||
result = await check_cookie(4, f"{uuid_v1}.json")
|
||||
if not result:
|
||||
status_queue.put("500")
|
||||
@@ -267,7 +276,10 @@ async def xiaohongshu_cookie_gen(id,status_queue):
|
||||
return None
|
||||
uuid_v1 = uuid.uuid1()
|
||||
print(f"UUID v1: {uuid_v1}")
|
||||
await context.storage_state(path=Path(BASE_DIR / "cookiesFile" / f"{uuid_v1}.json"))
|
||||
# 确保cookiesFile目录存在
|
||||
cookies_dir = Path(BASE_DIR / "cookiesFile")
|
||||
cookies_dir.mkdir(exist_ok=True)
|
||||
await context.storage_state(path=cookies_dir / f"{uuid_v1}.json")
|
||||
result = await check_cookie(1, f"{uuid_v1}.json")
|
||||
if not result:
|
||||
status_queue.put("500")
|
||||
|
||||
Reference in New Issue
Block a user