-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcookie_backup.py
More file actions
31 lines (22 loc) 路 859 Bytes
/
Copy pathcookie_backup.py
File metadata and controls
31 lines (22 loc) 路 859 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
30
31
"""
Export cookies to a JSON backup file.
More scripts: https://t.me/Multilogin_Scripts_Bot
Usage:
export MLX_PROFILE_ID="profile-uuid"
python cookie_backup.py
python cookie_backup.py my_backup.json
"""
import json
import os
import sys
from mlx_client import export_cookies, token_from_env
if __name__ == "__main__":
profile_id = os.environ.get("MLX_PROFILE_ID", "")
outfile = sys.argv[1] if len(sys.argv) > 1 else f"cookies_{profile_id[:8]}.json"
if not profile_id:
sys.exit("Set MLX_PROFILE_ID")
result = export_cookies(token_from_env(), profile_id)
cookies = result.get("data", {}).get("cookies", [])
with open(outfile, "w", encoding="utf-8") as f:
json.dump({"profile_id": profile_id, "cookies": cookies}, f, indent=2)
print(json.dumps({"saved": outfile, "count": len(cookies)}, indent=2))