From 1985b8e381760b427d992f6c4c11fa057f76c28d Mon Sep 17 00:00:00 2001 From: wlt233 <1486185683@qq.com> Date: Thu, 14 Nov 2024 13:35:46 +0800 Subject: [PATCH] feat: add ignore list (v0.3) --- conf.ini | 3 +- ticket.py | 82 ++++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 59 insertions(+), 26 deletions(-) diff --git a/conf.ini b/conf.ini index a7d7bc8..993267c 100644 --- a/conf.ini +++ b/conf.ini @@ -5,8 +5,9 @@ interval1 = 5000 interval2 = 500 username = theo.bal.d2.79.8@gmail.com password = Nijigasaki1214 -cookie = ACEUCI=1; SCOUTER=z4goact5cpuv28; ACEFCID=UID-67346B196F8C525AC4D6339C; ACEUACS=undefined; mxuid=51d18e88-4873-485a-95ab-7f8834d42ea0; _ga=GA1.1.46977207.1731488538; cro_uv_ymd=20241113; AUBS2A39876863068=1731488537400286700%7C2%7C1731488537400286700%7C1%7C1731488537298YC4H1S%7C1; TKGLOBAL_SES=AAAAlLtFu9-5ZnitMZqLT4MjVHjXuFbihJ0lSPQ6vtMgqfW_pE2-BZ520K9tSGplJJW-JLPeV9_uxfdpYRrJtPKW8dy4_lQXcLw7Nm9DzSFbAj2R7GjZBfExW0hCecB_0alJeq9eeLda3xxl7PQC7mFGlMP4wRoytOjYXDh_5IfOW3Vcj4nde-ZcOfy0drmkBqQd4XbjVNJDML9s5TPrqCiJEuc.A; TKGLOBAL_CHK=AAAA4XR7i3tbtQehiXXhXAAAa9Zd_f9h5rRBDpSu8fO6ORh522ZU0gpixEh7nxdDoWnv0AOD6rtWGb3RVrIwS7vdiIcxK-s5Kxg6YMvv20BRV4t32CWkNNLtL7FLKGD8gSz7VneYLtVPHnrJgYnCryA_Y3PMJ_dXdafmF0DP_YVSSVUN7U3g1aLdgxewHgUkzk7iVA_k7OmjJph9OW5cxjXltplboKhUt54SK3V3IENhPZ0M7wNVudRSJkhSIHCt5XLO8gbFuBCiOE3Auz0aBnMmWHjRhN2Ry68LQMxN2ukzooK7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ns6gcoOHTfNzmdEHhFbi2olxTY96RDCo48BY3QYs9jO%2FiFb34Cwq%2Feft2OFlBFR5yHlClgGyGgk8WdHlD5DkMVgXzM%2ByGlIbCfAvZxYzHY9jAHo6vRHIPsWTNgBY0an9wSV8Tg1tBmdvX498352sK4lwD7nopRMrg5Sj01Uk3GbQx%2F%2FvTbPl2894rdnihH%2FSm61tisfkCrvpOMRYcPscfXdwH5qj7D3ntRFJ2SOrTdjWFSon3Y5FQEXg9m7P8hP34q3VD4S2%2BrmlLkAFQbnmtcgip%2BN4Gxcx9abLohg9SS5G4gBhTkpPb9TFxsWakEQG8YHGxN13sGtfWfh3rbInQpO7cDOW%2F8%2BOJZCHNeXiYtcWImL3QHK%2Felf3B8PoI2XU8%2Bt2jogZ11pLOCmBoX%2FT5zNU6lYDjMmc%2BnV9sFn45gxoNMhQqPmuV6qPlQ%2FJYMJFxaIn%2FnLtPXX4CWjDjoDSkxHein7ZuAd7YC%2BuUXlL49rdjNtOCU9gqhYv4tU6BT4O4cg5nZ2WAKnYh%2BVV4fk1mX22X2GAN0naw%3D%3D; TKGLOBAL_MASKING_ID="the*************@gmail.com"; TKLINK_CAPTCHA_KEY=fa9663ab-8ea0-43c8-83db-afab8c544209; TKLINK_CHK_NO="clupiqMFH37RYsJFvEIuAQ=="; _ga_PVZX56STJJ=GS1.1.1731488537.1.1.1731488546.51.0.0; ASBS2A39876863068=1731488537400286700%7C1731488547168735040%7C1731488537400286700%7C0%7Cbookmark; ARBS2A39876863068=httpswwwticketlinkcokrglobalzhreserveplanschedule1740993756bookmark; wcCookieV2=103.151.173.102_T_559041_WC; TKLINK_CHK_KEY="/DihM4JRsrX9Uv3CfoGMBBi/LlUA/D9REZ0mWNsxc8Wlb3IZLpEbqCoYg2C5urUlS9d/Tq7otJfKEi6KchbIIw==" +cookie = ACEUCI=1; SCOUTER=x7kvgjuavojluk; ACEFCID=UID-6735818584017AAF5803F2FE; ACEUACS=undefined; mxuid=4ffd4147-08d0-4b4c-b6d1-f2a054a47f7b; _ga=GA1.1.548053917.1731559814; cro_uv_ymd=20241114; AUBS2A39876863068=1731559813406060933%7C2%7C1731559813406060933%7C1%7C1731559813958ZY0HIR%7C1; TKGLOBAL_SES=AAAAk1BzbwaNrpGpyfDDDhIUI8lfSCVaXkACgsA1dPlXBmSTDrwgJw74fT5_MDUtW8RI3FQd1o6P8Ac5azzPWkqSjBYVWJXJgrz8EuVL0yvygApt7xw0juhiOw6PTd2xMLGz0PxJbJFYomZb8OzozYTcTfjcjee9B-gUZa6Sy6aenU87r_Qegz5gVqOA4GGet_ADqnq4QCf1kXGL3x9yZRJBM2E.A; TKGLOBAL_CHK=AAAA2-NRotGEBIwpMvJqghV65z5Tp3O-GEZPi6Y8dnThHJEc10tfftSCx8Msm7SUG4NrfI-ZT0SvWsr2LaTwHlTiSlABO1fkfM-PZEboQCvIr0lffxmfu4BBv8oE6aN2VjO0SPEtkRqiTjsqQaSxmB85mCz-vNFjrbEUmUwSxPBeuxsb07Q9EqEGys1dOJd2byXuHIX_ItdjNFGN_aYHjfxk0SYF9-ZAuXp_078uX1ITSjP9c42qal5jdVlv9zqqoOlm4DkYOAgdzv1wzh_XP92yxyLiHtNGEesyTafzeSdg1SxY.gpXe_jgUmBgBVNlDf-E7Ej4CP3mwKzyMge3Iod-lWGPUVFVz69bU8zjKuNQ_mMcFydVimzihSNALYZ02W5XaZTNgieCZgwfi1jVl0QWVNBcGK07Va1DM7A-FNpS0o3197j6eyA38qomOef4FrWCfR5qa1rdfRm1ZLExqGYpymUiZVBTzXVkTNWW8VYS7kyzATyYqbBxHZJTvYxP4wh6kgdEA8iqnkFv6d8N-iERzAgpdaFD1ko0gJZ1KUVb_16ZRTtnHg2Qv-vnMTvDKBNqfgckRrsywIASSVp9xR6ktVy1I77s3qn4HrhaEWVJ4FeNcWhQ8gooxR-qrVNuxb0CNBg; TKGLOBAL=KnLuIDsQjMq%2FddCjD7YWcikNgnImESNKoadR7mBw7SeCYcVULQm6p5lsc5aiU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BGUW4AnvVh9MpW0sn3EN%2B%2BX9kDPLjfdSA7FYIzLcvvvw8pM0zLntxDk7wgK19pYE02rC%2FK%2FyewTZMvR5mpo%2FXXenFYoZIsFBL48Husy6z1IWszOroO2rgTAMSEA5q%2F9uW1PA%3D%3D; TKGLOBAL_MASKING_ID="the*************@gmail.com"; TKLINK_CAPTCHA_KEY=4ac8d350-7ca7-465b-90da-01fed8c3c905; TKLINK_CHK_NO="XJ1VElCEVbwydk59zCf9Xw=="; _ga_PVZX56STJJ=GS1.1.1731559814.1.1.1731559823.51.0.0; ASBS2A39876863068=1731559813406060933%7C1731559823274799468%7C1731559813406060933%7C0%7Cbookmark; ARBS2A39876863068=httpswwwticketlinkcokrglobalzhreserveplanschedule1740993756bookmark; wcCookieV2=103.151.173.102_T_427171_WC; TKLINK_CHK_KEY="mGuNVphH8Txj55pMud89OTNM1SwY9ZUsaj1yEKCjhck3P4R3w0YHNH3EipY+0qs1oNM6AVR0C16sfYFc+AUduQ==" [seat] seats = +ignore = 1537123495,1537123246 diff --git a/ticket.py b/ticket.py index c42a546..66bd8e8 100644 --- a/ticket.py +++ b/ticket.py @@ -12,7 +12,7 @@ from loguru import logger from cookie import get_cookie # code by wlt233 | for LoveLive! Series AsiaTour 2024 -# 2024.11.12 | v0.2 +# 2024.11.13 | v0.3 # ref: https://www.ticketlink.co.kr/global/zh/product/51390 @@ -22,6 +22,7 @@ logger.add("./data/log/{time}.log") # seat data COOKIE, USERNAME, PASSWORD, HEADLESS, PROXY = "", "", "", "", "" +SEATS_IGNORE = [] with open("./data/able_d1.json", "r") as f: able_d1 = json.load(f) with open("./data/able_d2.json", "r") as f: @@ -43,6 +44,24 @@ for x, y in coordinates: 'virtualY': str(y), }) +def get_seat(attr_or_seatid, day=None): + if not day or day == 1: + for k, l in able_d1.items(): + for seat in l: + if seat["mapInfo"] == attr_or_seatid: + return 1, seat + elif str(seat["logicalSeatId"]) == attr_or_seatid: + return 1, seat + if not day or day == 2: + for k, l in able_d2.items(): + for seat in l: + if seat["mapInfo"] == attr_or_seatid: + return 2, seat + elif str(seat["logicalSeatId"]) == attr_or_seatid: + return 2, seat + logger.error(f"没有找到座位:{attr_or_seatid}") + return None, None + @@ -109,14 +128,20 @@ async def search_seats(seats): 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) + if not seat_id in SEATS_IGNORE: + logger.success(f"发现内场票:d1 {seat['mapInfo']} {seat_id}") + seats[1].append(seat) + else: + logger.warning(f"发现内场票:d1 {seat['mapInfo']} 在忽略列表中") 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) + if not seat_id in SEATS_IGNORE: + logger.success(f"发现内场票:d2 {seat['mapInfo']} {seat_id}") + seats[2].append(seat) + else: + logger.warning(f"发现内场票:d2 {seat['mapInfo']} 在忽略列表中") @@ -267,31 +292,38 @@ if __name__ == "__main__": 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 [] + seats_list = seats_str.split(",") if seats_str else [] + ignore_list = config.get("seat", "ignore").split(",") logger.info(f"cookie = {COOKIE[:50]}...") 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}") + logger.info(f"seats = {seats_list}") seats = { 1: [], 2: [] } - for attr in seats_attr: - day, a = attr.split(maxsplit=1) - if "1" in day: - for k, l in able_d1.items(): - for s in l: - if s["mapInfo"] == a: - seats[1].append(s) - logger.info(f"已找到位置 d1 {a},尝试锁票") - break - if "2" in day: - for k, l in able_d2.items(): - for s in l: - if s["mapInfo"] == a: - seats[2].append(s) - logger.info(f"已找到位置 d2 {a},尝试锁票") - break - if not seats[1] and not seats[2]: - logger.error(f"没有找到配置的座位,开始自动搜索内场座位...") + for seat_str in seats_list: + if " " in seat_str: + daystr, attr = seat_str.split(maxsplit=1) + day = 1 if "1" in daystr else 2 + day, seat = get_seat(attr, day) + else: + day, seat = get_seat(seat_str) + if day and seat: + seats[day].append(seat) + logger.info(f"已找到锁票位置 d{day} {seat['mapInfo']} {seat['logicalSeatId']}") + if not (seats[1] or seats[2]): + logger.error(f"没有找到配置的锁票座位,开始自动搜索内场座位...") + + for seat_str in ignore_list: + if " " in seat_str: + daystr, attr = seat_str.split(maxsplit=1) + day = 1 if "1" in daystr else 2 + day, seat = get_seat(attr, day) + else: + day, seat = get_seat(seat_str) + if day and seat: + SEATS_IGNORE.append(str(seat['logicalSeatId'])) + logger.info(f"已找到忽略位置 d{day} {seat['mapInfo']} {seat['logicalSeatId']}") + asyncio.run(loop(interval1, interval2, seats))