|
|
|
@ -9,23 +9,23 @@ import time
|
|
|
|
|
import httpx
|
|
|
|
|
from loguru import logger
|
|
|
|
|
|
|
|
|
|
from cookie import get_cookie # type: ignore
|
|
|
|
|
from cookie import get_cookie
|
|
|
|
|
|
|
|
|
|
# code by wlt233 | for LoveLive! Series AsiaTour 2024
|
|
|
|
|
# 2024.11.12 | v0.2
|
|
|
|
|
# ref: https://www.ticketlink.co.kr/global/zh/product/51390
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# log
|
|
|
|
|
logger.add("./data/log/{time}.log")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# seat data
|
|
|
|
|
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:
|
|
|
|
|
able_d2 = json.load(f)
|
|
|
|
|
|
|
|
|
|
coordinates = [
|
|
|
|
|
(1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7),
|
|
|
|
|
(2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7),
|
|
|
|
@ -45,7 +45,8 @@ for x, y in coordinates:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# web
|
|
|
|
|
|
|
|
|
|
# web wrapper
|
|
|
|
|
async def _async_req(method, url: str, proxy=None, *args, **kwargs):
|
|
|
|
|
logger.info(f"[async {method}] {url}")
|
|
|
|
|
# logger.info(f"{args} {kwargs}")
|
|
|
|
@ -62,7 +63,9 @@ async def async_post_json(url: str, proxy=None, *args, **kwargs):
|
|
|
|
|
raise e
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# soldout
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# soldout check
|
|
|
|
|
async def get_sold():
|
|
|
|
|
global COOKIE
|
|
|
|
|
headers = {
|
|
|
|
@ -183,16 +186,15 @@ async def lock_ticket(day, seats):
|
|
|
|
|
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)
|
|
|
|
|
seats.clear()
|
|
|
|
|
await asyncio.sleep(450)
|
|
|
|
|
else:
|
|
|
|
|
msg = f"锁票失败!msg:{resp['result']['message']}"
|
|
|
|
|
if "이전에 진행된 예매가 있습니다" in msg:
|
|
|
|
|
msg += (f" 有正在进行的预售,请访问以下链接初始化。"
|
|
|
|
|
f"https://www.ticketlink.co.kr/global/en/reserve/plan/schedule/{day_code}?loadPrevious=true")
|
|
|
|
|
logger.critical(msg)
|
|
|
|
|
os.system("pause")
|
|
|
|
|
sys.exit(0)
|
|
|
|
|
await asyncio.sleep(10)
|
|
|
|
|
else:
|
|
|
|
|
logger.error(msg)
|
|
|
|
|
except:
|
|
|
|
@ -202,7 +204,7 @@ async def lock_ticket(day, seats):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# cookie
|
|
|
|
|
def update_cookie():
|
|
|
|
|
global COOKIE, USERNAME, PASSWORD, HEADLESS
|
|
|
|
|
COOKIE = get_cookie(USERNAME, PASSWORD, HEADLESS)
|
|
|
|
@ -220,27 +222,32 @@ def update_cookie():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# main loop state machine
|
|
|
|
|
async def loop(interval1, interval2, seats):
|
|
|
|
|
t = time.time()
|
|
|
|
|
while True:
|
|
|
|
|
await search_seats(seats)
|
|
|
|
|
if seats[1] or seats[2]:
|
|
|
|
|
break
|
|
|
|
|
if not (seats[1] or seats[2]):
|
|
|
|
|
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)
|
|
|
|
|
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(1, seats[1]))
|
|
|
|
|
event_loop.create_task(lock_ticket(2, seats[2]))
|
|
|
|
|
if not (seats[1] or seats[2]):
|
|
|
|
|
break
|
|
|
|
|
else:
|
|
|
|
|
await asyncio.sleep(interval2 / 1000)
|
|
|
|
|
|
|
|
|
|
event_loop = asyncio.get_event_loop()
|
|
|
|
|
while True:
|
|
|
|
|
event_loop.create_task(lock_ticket(1, seats[1]))
|
|
|
|
|
event_loop.create_task(lock_ticket(2, seats[2]))
|
|
|
|
|
await asyncio.sleep(interval2 / 1000)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|