From 633ec325e307eff96d3fcc3a22498754dd40eb18 Mon Sep 17 00:00:00 2001 From: CHUN YU YAO Date: Fri, 23 Jun 2023 11:36:52 +0800 Subject: [PATCH] 2023-06-21, fix for ticketmaster auto click area zone info --- chrome_tixcraft.py | 78 +++++++++++++++++++++++++++++++++++----------- config_launcher.py | 2 +- settings.py | 2 +- text_server.py | 2 +- 4 files changed, 62 insertions(+), 22 deletions(-) diff --git a/chrome_tixcraft.py b/chrome_tixcraft.py index 5d37db2..602783c 100644 --- a/chrome_tixcraft.py +++ b/chrome_tixcraft.py @@ -53,7 +53,7 @@ import webbrowser import argparse import itertools -CONST_APP_VERSION = "MaxBot (2023.6.20)" +CONST_APP_VERSION = "MaxBot (2023.6.21)" CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt" @@ -6595,6 +6595,62 @@ def set_non_browser_cookies(driver, url, Captcha_Browser): Captcha_Browser.Set_cookies(driver.get_cookies()) Captcha_Browser.Set_Domain(domain_name) +def ticketmaster_parse_zone_info(driver, config_dict): + show_debug_message = True # debug. + show_debug_message = False # online + + if config_dict["advanced"]["verbose"]: + show_debug_message = True + + mapSelectArea = None + try: + my_css_selector = '#mapSelectArea' + mapSelectArea = driver.find_element(By.CSS_SELECTOR, my_css_selector) + except Exception as exc: + if show_debug_message: + print('fail to find my_css_selector:', my_css_selector) + #print("find table#ticketPriceList fail", exc) + + if not mapSelectArea is None: + mapSelectArea_html = "" + try: + mapSelectArea_html = mapSelectArea.get_attribute('innerHTML') + except Exception as exc: + mapSelectArea_html = "" + if show_debug_message: + print(exc) + + zone_string = "" + tag_start = "var zone =" + tag_end = "fieldImageType" + if tag_start in mapSelectArea_html and tag_end in mapSelectArea_html: + if show_debug_message: + print('found zone info!') + zone_string = mapSelectArea_html.split(tag_start)[1] + zone_string = zone_string.split(tag_end)[0] + zone_string = zone_string.strip() + if zone_string[-1:] == "\n": + zone_string=zone_string[:-1] + zone_string = zone_string.strip() + if zone_string[-1:] == ",": + zone_string=zone_string[:-1] + if show_debug_message: + #print('found zone info string:', zone_string) + pass + + if len(zone_string) > 0: + zone_info = {} + try: + zone_info = json.loads(zone_string) + if show_debug_message: + #print("zone_info", zone_info) + pass + if not zone_info is None: + ticketmaster_area_auto_select(driver, config_dict, zone_info) + except Exception as exc: + if show_debug_message: + print(exc) + def ticketmaster_assign_ticket_number(driver, config_dict): show_debug_message = True # debug. show_debug_message = False # online @@ -6610,7 +6666,8 @@ def ticketmaster_assign_ticket_number(driver, config_dict): if show_debug_message: print('fail to find my_css_selector:', my_css_selector) #print("find table#ticketPriceList fail", exc) - pass + ticketmaster_parse_zone_info(driver, config_dict) + form_select = None if not table_select is None: @@ -6625,23 +6682,6 @@ def ticketmaster_assign_ticket_number(driver, config_dict): print('my_css_selector:', my_css_selector) print("find form-select fail", exc) pass - else: - #print('not found table, start click area') - zone_info = {} - - try: - zone_info = driver.execute_async_script(""" - if (!(typeof zone === 'undefined')) { - callback = arguments[arguments.length - 1]; - callback(zone); } - """) - if not zone_info is None: - #print("zone_info", zone_info) - ticketmaster_area_auto_select(driver, config_dict, zone_info) - except Exception as exc: - if show_debug_message: - print(exc) - select_obj = None if form_select is not None: diff --git a/config_launcher.py b/config_launcher.py index d616067..060163d 100644 --- a/config_launcher.py +++ b/config_launcher.py @@ -22,7 +22,7 @@ import base64 import threading import subprocess -CONST_APP_VERSION = "MaxBot (2023.6.19)" +CONST_APP_VERSION = "MaxBot (2023.6.21)" CONST_MAXBOT_LAUNCHER_FILE = "config_launcher.json" CONST_MAXBOT_CONFIG_FILE = "settings.json" diff --git a/settings.py b/settings.py index f3fd46b..9138fe7 100644 --- a/settings.py +++ b/settings.py @@ -34,7 +34,7 @@ ssl._create_default_https_context = ssl._create_unverified_context import socket -CONST_APP_VERSION = "MaxBot (2023.6.20)" +CONST_APP_VERSION = "MaxBot (2023.6.21)" CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt" diff --git a/text_server.py b/text_server.py index ea2cbd0..24d6621 100644 --- a/text_server.py +++ b/text_server.py @@ -28,7 +28,7 @@ import asyncio import tornado from tornado.web import Application -CONST_APP_VERSION = "MaxBot (2023.6.20)" +CONST_APP_VERSION = "MaxBot (2023.6.21)" CONST_MAXBOT_QUESTION_FILE = "MAXBOT_QUESTION.txt"