mirror of
https://github.com/vndangkhoa/purestream.git
synced 2026-04-05 01:17:58 +07:00
fix: sanitize cookie sameSite values for Playwright compatibility
This commit is contained in:
parent
a8920ff23d
commit
601ae284b5
1 changed files with 21 additions and 1 deletions
|
|
@ -131,7 +131,27 @@ class PlaywrightManager:
|
||||||
with open(COOKIES_FILE, "r") as f:
|
with open(COOKIES_FILE, "r") as f:
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
if isinstance(data, list):
|
if isinstance(data, list):
|
||||||
cookies = data
|
# Sanitize each cookie for Playwright compatibility
|
||||||
|
for c in data:
|
||||||
|
if isinstance(c, dict) and "name" in c and "value" in c:
|
||||||
|
cookie = {
|
||||||
|
"name": c["name"],
|
||||||
|
"value": str(c["value"]),
|
||||||
|
"domain": c.get("domain") or ".tiktok.com",
|
||||||
|
"path": c.get("path") or "/",
|
||||||
|
}
|
||||||
|
# Only add optional fields if they have valid values
|
||||||
|
if c.get("secure") is not None:
|
||||||
|
cookie["secure"] = bool(c["secure"])
|
||||||
|
if c.get("httpOnly") is not None:
|
||||||
|
cookie["httpOnly"] = bool(c["httpOnly"])
|
||||||
|
# Sanitize sameSite - Playwright only accepts Strict|Lax|None
|
||||||
|
if c.get("sameSite"):
|
||||||
|
ss = str(c["sameSite"]).capitalize()
|
||||||
|
if ss in ["Strict", "Lax", "None"]:
|
||||||
|
cookie["sameSite"] = ss
|
||||||
|
# If invalid, just omit it
|
||||||
|
cookies.append(cookie)
|
||||||
elif isinstance(data, dict):
|
elif isinstance(data, dict):
|
||||||
# Backward compatibility or simple dict format
|
# Backward compatibility or simple dict format
|
||||||
for name, value in data.items():
|
for name, value in data.items():
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue