import json

def convert_cookies(cookies_dict, domain=".tiktokglobalshop.com"):
    cookies_list = []
    for name, value in cookies_dict.items():
        # 设置 domain
        if name in ("user_oec_info", "i18next"):
            current_domain = "affiliate.tiktokglobalshop.com"
        else:
            current_domain = domain

        cookies_list.append({
            "name": name,
            "value": value,
            "domain": current_domain
        })
    return cookies_list


cookies = {
    '_m4b_theme_': 'new',
    'SHOP_ID': '7376865079253894917',
    'kura_cloud_uid': 'ab03a1e28205bb11df4a1d6a842ea916',
    'pre_country': 'US',
    'csrftoken': 'v4UPrq4lrDdDOoBGB9kHMPiLrKnLM4CX',
    'goofy_grayscale_uid': '746ea09a110e065086655482449ab999',
    'd_ticket': '5484187fcf463b0c7e9230d85be33c171341d',
    'app_id_unified_seller_env': '6556',
    'global_seller_id_unified_seller_env': '7495793993123269592',
    'gf_part_69992': '68',
    'passport_csrf_token': 'a901c7b482df2e429a5ff348f3560385',
    'passport_csrf_token_default': 'a901c7b482df2e429a5ff348f3560385',
    'gf_part_70472': '19',
    'gf_part_70474': '1',
    'gf_part_70480': '65',
    'gf_part_70536': '45',
    'gf_part_70740': '48',
    'gd_random': 'eyJtYXRjaCI6ZmFsc2UsInBlcmNlbnQiOjAuNDc4OTkyMDYxOTE4NzUyNTR9.UeVekoUPCbEPB//cHsB9nse3nlUT5tfp+dRr6is49QA=',
    'gf_part_70802': '90',
    'gf_part_70799': '4',
    'gf_part_71074': '98',
    'gf_part_71086': '79',
    'gf_part_71178': '97',
    'store-country-sign': 'MEIEDFjw5-z_G_qXiPFeFQQg2QC5lh0g3vo2GUrsZb5Uy33w4qQm9ZxPy1DrvabrazsEEIu7tfA3pTbLUWeqek0na70',
    'uid_tt': '30e2b3a27de62ce4c9c4117a1d9c96f8de207af75fcad9066933ef8100a17df8',
    'uid_tt_ss': '30e2b3a27de62ce4c9c4117a1d9c96f8de207af75fcad9066933ef8100a17df8',
    'sid_tt': '6fd738cddea9ef6705b367af683da828',
    'sessionid': '6fd738cddea9ef6705b367af683da828',
    'sessionid_ss': '6fd738cddea9ef6705b367af683da828',
    'msToken': 'im3n4J4adpEI93pgmKIVK7eG7Sn9xqr6s-8GU0ypjqJdCc-pRA4bF2umFgfvo01ssTQKPkEDS4Wr8WL6iryi61iAEX91UoklKP7Z6NwUFI1fBnAVSt1C6djNVa7gDBl07JhtLXzXlkQ=',
    'odin_tt': 'a7602d2b6324b1e0b48fc0c349ab967ef73663b913a1081bbc107daeab4b44f6d67c8ddb1a3715753b68d4ee776f76cb57a182c0606c0a34604d59ea9743aa7f',
    'gf_part_71578': '86',
    'ttwid': '1%7CajSzVxrjJ0cyp8S2QlhI_695G0YRxrhn3KVn-rNbvvI%7C1751010590%7C812ac0d93ac565ba35f6d7dd08a37f1d82c8e383756748310b0435c9537aa224',
    'gf_part_71754': '15',
    's_v_web_id': 'verify_mcfzrgew_VFPOUZqi_oayA_4MKC_9be9_SQDOieAj3J10',
    'i18next': 'en',
    'SELLER_TOKEN': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySWQiOjczNzY4NjA4MzQ5MTQzNTQxNzcsIk9lY1VpZCI6NzQ5NTc5Mzk5MzEyMzI2OTU5MiwiT2VjU2hvcElkIjo3NDk1NzkzOTkzMTIzMjY5NTkyLCJTaG9wUmVnaW9uIjoiVVMiLCJHbG9iYWxTZWxsZXJJZCI6NzQ5NTc5Mzk5MzEyMzI2OTU5MiwiU2VsbGVySWQiOjc0OTU3OTM5OTMxMjMyNjk1OTIsImV4cCI6MTc1MTE4NjQ4MywibmJmIjoxNzUxMDk5MDgzfQ.WfOaHnEBuGGiJF_JkMxp7tf6jSknet4sXutuACgnNFI',
    'sid_guard': '6fd738cddea9ef6705b367af683da828%7C1751174680%7C259200%7CWed%2C+02-Jul-2025+05%3A24%3A40+GMT',
    'sid_ucp_v1': '1.0.0-KDYxZjkxMmNiMjliNjZlODA0YzQ4ODkzYTJmMWQ0ZjI0OTBjZWQ2ODcKGgiBiL-0hfv3r2YQmJyDwwYYnDM4AUDqB0gEEAQaB3VzZWFzdDUiIDZmZDczOGNkZGVhOWVmNjcwNWIzNjdhZjY4M2RhODI4',
    'ssid_ucp_v1': '1.0.0-KDYxZjkxMmNiMjliNjZlODA0YzQ4ODkzYTJmMWQ0ZjI0OTBjZWQ2ODcKGgiBiL-0hfv3r2YQmJyDwwYYnDM4AUDqB0gEEAQaB3VzZWFzdDUiIDZmZDczOGNkZGVhOWVmNjcwNWIzNjdhZjY4M2RhODI4',
    'user_oec_info': '0a534b21083437f9ec1040289989ede0e4c1aebb9830657e8e8873e9d243f409a4968f099f113f294e45a0902bd28ebe3d208e391fc5365e357965ed9b6b6fed87cda4a94c4b255f1881bb60b1fed12577e19bb3571a490a3c000000000000000000004f2ca703ee12db7924a0877091465e43fe04c7293a5e496028937e6704fbad941e75fa65d775810036635b9438ddb65e372510c1aff50d1886d2f6f20d22010464b988c9',
    'msToken': 'FpXQvyvWnF5c-h82ZcaZnawzCodp-Nuvd9E-GsZLsi_2gqdr_kikneO-FOTjipmJ6SBwpp7JylJedYZPqEzJBvFHo-HfzBSjvBoXVQPPqE5GSkK_S_Jn6Hfy3nxB4X-cgFpx1pM9',
    'passport_fe_beating_status': 'false',
}

# 第一步：转换格式
converted_cookies = convert_cookies(cookies)

# 第二步：转成 JSON 字符串（用于 Redis 存储）
cookie_json_str = json.dumps(converted_cookies, ensure_ascii=False)
print("✅ JSON 字符串（可存入 Redis）：")
print(cookie_json_str)






