diff --git a/conf.ini b/conf.ini index a37eefc..866bb11 100644 --- a/conf.ini +++ b/conf.ini @@ -1,11 +1,12 @@ [conf] proxy = socks5://localhost:7890 headless = 1 -interval = 1000 -username = vj.zhzh.dbb.d.udhj.db@gmail.com -password = Nijigasaki27 -cookie = +interval1 = 5000 +interval2 = 500 +username = theo.bal.d2.79.8@gmail.com +password = Nijigasaki1214 +cookie = ACEUCI=1; SCOUTER=x3r0eu8rdpfvvm; ACEFCID=UID-67344B044C2B3720B8A8FB64; ACEUACS=undefined; _ga=GA1.1.1973599067.1731480324; mxuid=f462236b-7f65-4776-a6de-46dc6715ec2e; cro_uv_ymd=20241113; AUBS2A39876863068=1731480324912546807%7C2%7C1731480324912546807%7C1%7C1731480324325B1COZ6%7C1; TKGLOBAL_SES=AAAAlBK4XWccUeZ6-vNYcvqLYn-5s8PZxWsz_S8eenI564JuHVYul1TOlCXbn1672AMdYTQz-aoHG5CILDQzDbv_FaFYNJaPx0evUQMJkBseJzToYnjfBqK45U-Dd14ZjmnMTYoEstvw5kZAYJ-AdK1CcVWuhLeEA419r5B8ogFCRxsAoPbWbQg-PVxQNcxNksakIXiUgmejbdGvOOkScdu2qMI.A; TKGLOBAL_CHK=AAAA4HhSeftkR-heOlLeUKgH4__rSvzTsZUK_Iu7Q1LrN-3BdTTVuh1gNJZ2hS-1tTzkarglz7X3zq2mS_NgXZwMq5BRtIGGuIkPhabYsMHT8rJy5_FAMwH7hfxrJTC-Gz2hHYtWfLBaLe3fdc4tobuzYwq-Z2UVUhZNwX11XRPFqlqFfrAVXwIZmSH0rGykOKZTj-E2UT6w7QdmvkrwwVN5la_FjC03xjhR2AbCeWiqymZ-YB87cK2xyu1HECLa4FYY6nlVOM7dC-cJqqSnZb61uQT8jOYMWLVrzPuUL0BQ0ucb.tKANqptF2XKMqhII_afhfV9TSbaS0ekNiA6bT0PIryFdIjnfRPGy95Mp82wSx9F68SgN6sU1ZC28v_B68U7jN3SaoMIhECmjPGj9gtP9oBXxGqlZ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yCREcabJ%2FQU8lvkpS1OIwCIoggwK%2FwkShZn1iXbOCpE%2Foc1PlATO0KttuxF%2FBCuWy6fq7CIXN7yzuQBmdvVX7EFikhGA348RqPH7gRg3iSiUiXBSSdycm%2FzbVvJLRFceUZp0iNdPy7zUaaEcEsiFJWL8hOtWmyJl8YCH5tCSgmzZE%2FGT%2FslsrV7RH5rocXgWXr1SPOuhYoxitPLIbaBZOH0uKysJoxn9hmkvUuRIKN7gUJhanBaSkt2fOYiTcSDvEb1QEe%2BZsigkIonWOH7iOnUTEnTjWnbtqAaqMtj1RNdVQG5JStuBf52iyZAFPKM9dqC%2F%2FQFpoV4JUx7xckq8VaXZO7IbvEPJeo5QQa469rRMRWNC864hukAPZ56AA%3D%3D; TKGLOBAL_MASKING_ID="the*************@gmail.com"; TKLINK_CAPTCHA_KEY=01cfff51-f84b-4de8-9334-82f3940cc475; TKLINK_CHK_NO="WPjYvajLGinplpnCYNCq4A=="; _ga_PVZX56STJJ=GS1.1.1731480324.1.1.1731480334.50.0.0; ASBS2A39876863068=1731480324912546807%7C1731480335981116885%7C1731480324912546807%7C0%7Cbookmark; ARBS2A39876863068=httpswwwticketlinkcokrglobalzhreserveplanschedule1740993756bookmark; wcCookieV2=43.198.205.125_T_798900_WC; TKLINK_CHK_KEY="6WI8yRjBwHfdVotNaoaNWI3iCh0Kfn/qHUgx6oaQVDZ8rWxuYhj8mhLhFzmFzB+NBekOJ5/dHh2GdvKBmWO6GQ==" [seat] -seats = d1 1층 FLOOR 4구역 8열 2번,d2 1층 4구역 7열 4번 +seats = diff --git a/ticket.py b/ticket.py index f028e8a..34e8db8 100644 --- a/ticket.py +++ b/ticket.py @@ -12,7 +12,7 @@ from loguru import logger from cookie import get_cookie # type: ignore # code by wlt233 | for LoveLive! Series AsiaTour 2024 -# 2024.11.10 | v0.1 +# 2024.11.12 | v0.2 # ref: https://www.ticketlink.co.kr/global/zh/product/51390 # log @@ -20,7 +20,7 @@ logger.add("./data/log/{time}.log") # seat data -COOKIE, USERNAME, PASSWORD, HEADLESS = "", "", "", "" +COOKIE, USERNAME, PASSWORD, HEADLESS, PROXY = "", "", "", "", "" with open("./data/able_d1.json", "r") as f: able_d1 = json.load(f) with open("./data/able_d2.json", "r") as f: @@ -63,7 +63,7 @@ async def async_post_json(url: str, proxy=None, *args, **kwargs): # soldout -async def get_sold(proxy): +async def get_sold(): global COOKIE headers = { 'Cookie': COOKIE, @@ -83,17 +83,38 @@ async def get_sold(proxy): 'sec-ch-ua-mobile': '?0', 'sec-ch-ua-platform': '"Windows"', } - resp_d1 = await async_post_json( - 'https://www.ticketlink.co.kr/global/zh/api/V2/plan/552446605/seat-soldout/area', #d1 - proxy=proxy, headers=headers, json=json_data, #cookies=cookies - ) - resp_d2 = await async_post_json( - 'https://www.ticketlink.co.kr/global/zh/api/V2/plan/1740993756/seat-soldout/area', #d2 - proxy=proxy, headers=headers, json=json_data, #cookies=cookies - ) - sold_d1 = resp_d1["data"] - sold_d2 = resp_d2["data"] - return sold_d1, sold_d2 + try: + resp_d1 = await async_post_json( + 'https://www.ticketlink.co.kr/global/zh/api/V2/plan/552446605/seat-soldout/area', #d1 + proxy=PROXY, headers=headers, json=json_data, #cookies=cookies + ) + resp_d2 = await async_post_json( + 'https://www.ticketlink.co.kr/global/zh/api/V2/plan/1740993756/seat-soldout/area', #d2 + proxy=PROXY, headers=headers, json=json_data, #cookies=cookies + ) + sold_d1 = resp_d1["data"] + sold_d2 = resp_d2["data"] + return sold_d1, sold_d2 + except: + logger.error("座位情况检查失败!") + return None, None + +async def search_seats(seats): + sold_d1, sold_d2 = await get_sold() + if sold_d1 and sold_d2: + for k, l in able_d1.items(): + for seat in l: + seat_id = str(seat["logicalSeatId"]) + if "FLOOR" in seat['mapInfo'] and not sold_d1[seat_id]: + logger.success(f"发现内场票:d1 {seat['mapInfo']}") + seats[1].append(seat) + for k, l in able_d2.items(): + for seat in l: + seat_id = str(seat["logicalSeatId"]) + if "FLOOR" in seat['mapInfo'] and not sold_d2[seat_id]: + logger.success(f"发现内场票:d2 {seat['mapInfo']}") + seats[2].append(seat) + @@ -117,7 +138,8 @@ def parse_seat(seat): }, 'st': int(time.time() * 1000), } -async def lock_ticket(proxy, day, seats): + +async def lock_ticket(day, seats): global COOKIE if not seats: return if len(seats) > 4: seats = seats[:4] @@ -156,9 +178,10 @@ async def lock_ticket(proxy, day, seats): try: resp = await async_post_json( f'https://www.ticketlink.co.kr/global/en/api/V2/plan/occupy/schedules/{day_code}/', - proxy=proxy, headers=headers, json=json_data + proxy=PROXY, headers=headers, json=json_data ) if resp["success"]: + print("\x07") logger.success(f"锁票成功!支付链接:\nhttps://www.ticketlink.co.kr/global/en/reserve/key/{resp['data']}/price") os.system("pause") sys.exit(0) @@ -177,6 +200,9 @@ async def lock_ticket(proxy, day, seats): update_cookie() + + + def update_cookie(): global COOKIE, USERNAME, PASSWORD, HEADLESS COOKIE = get_cookie(USERNAME, PASSWORD, HEADLESS) @@ -193,14 +219,28 @@ def update_cookie(): -async def loop(proxy, interval, seats): + + + +async def loop(interval1, interval2, seats): + t = time.time() + while True: + await search_seats(seats) + if seats[1] or seats[2]: + break + else: + logger.error("没有搜索到内场座位...") + if time.time() - t > 1200: + update_cookie() + t = time.time() + else: + await asyncio.sleep(interval1 / 1000) + event_loop = asyncio.get_event_loop() while True: - event_loop.create_task(lock_ticket(proxy, 1, seats[1])) - event_loop.create_task(lock_ticket(proxy, 2, seats[2])) - # await lock_ticket(proxy, 1, seats[1]) - # await lock_ticket(proxy, 2, seats[2]) - await asyncio.sleep(interval / 1000) + event_loop.create_task(lock_ticket(1, seats[1])) + event_loop.create_task(lock_ticket(2, seats[2])) + await asyncio.sleep(interval2 / 1000) @@ -218,12 +258,15 @@ if __name__ == "__main__": os.system("pause") sys.exit(0) update_cookie() - proxy = config.get("conf", "proxy") or None - interval = int(config.get("conf", "interval") or 100) - seats_attr = config.get("seat", "seats").split(",") + PROXY = config.get("conf", "proxy") or None + interval1 = int(config.get("conf", "interval1") or 10000) + interval2 = int(config.get("conf", "interval2") or 1000) + seats_str = config.get("seat", "seats") + seats_attr = seats_str.split(",") if seats_str else [] logger.info(f"cookie = {COOKIE[:50]}...") - logger.info(f"proxy = {proxy}") - logger.info(f"interval = {interval} ms") + logger.info(f"proxy = {PROXY}") + logger.info(f"interval1 = {interval1} ms (search)") + logger.info(f"interval2 = {interval2} ms (lock)") logger.info(f"seats = {seats_attr}") seats = { 1: [], 2: [] } @@ -244,8 +287,6 @@ if __name__ == "__main__": logger.info(f"已找到位置 d2 {a},尝试锁票") break if not seats[1] and not seats[2]: - logger.error(f"没有找到座位,请检检查座位参数!") - os.system("pause") - sys.exit(0) + logger.error(f"没有找到配置的座位,开始自动搜索内场座位...") - asyncio.run(loop(proxy, interval, seats)) + asyncio.run(loop(interval1, interval2, seats))