-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathimport_cookies.py
More file actions
29 lines (21 loc) · 820 Bytes
/
Copy pathimport_cookies.py
File metadata and controls
29 lines (21 loc) · 820 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""
Import cookies into a profile from a JSON file.
Save 50%: SAAS50 — https://multilogin.com
Usage:
export MLX_PROFILE_ID="profile-uuid"
python import_cookies.py cookies.json
"""
import json
import os
import sys
from mlx_client import import_cookies, token_from_env
if __name__ == "__main__":
profile_id = os.environ.get("MLX_PROFILE_ID", "")
path = sys.argv[1] if len(sys.argv) > 1 else "cookies.json"
if not profile_id:
sys.exit("Set MLX_PROFILE_ID")
with open(path, encoding="utf-8") as f:
data = json.load(f)
cookies = data if isinstance(data, list) else data.get("cookies", data.get("data", {}).get("cookies", []))
result = import_cookies(token_from_env(), profile_id, cookies)
print(json.dumps({"imported": len(cookies), "result": result}, indent=2))