bugs fixed for ticketplus.

master
Max 2023-11-23 14:51:48 +08:00 committed by GitHub
parent e0b6140290
commit c6382f1b7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 42 additions and 20 deletions

View File

@ -42,6 +42,11 @@ ssl._create_default_https_context = ssl._create_unverified_context
# ocr
import base64
# workaround for ddddocr with Pillow.
from PIL import Image
if not hasattr(Image, 'ANTIALIAS'):
setattr(Image, 'ANTIALIAS', Image.LANCZOS)
try:
import ddddocr
@ -55,7 +60,7 @@ import webbrowser
import chromedriver_autoinstaller
CONST_APP_VERSION = "MaxBot (2023.11.15)"
CONST_APP_VERSION = "MaxBot (2023.11.16)"
CONST_MAXBOT_CONFIG_FILE = "settings.json"
CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt"
@ -3268,7 +3273,7 @@ def tixcraft_ticket_main_ocr(driver, config_dict, ocr, Captcha_Browser, domain_n
else:
previous_answer = None
last_url, is_quit_bot = get_current_url(driver)
for redo_ocr in range(999):
for redo_ocr in range(99):
is_need_redo_ocr, previous_answer, is_form_sumbited = tixcraft_auto_ocr(driver, ocr, away_from_keyboard_enable, previous_answer, Captcha_Browser, ocr_captcha_image_source, domain_name)
if is_form_sumbited:
# start next loop.
@ -10854,13 +10859,17 @@ def ticketplus_order_expansion_auto_select(driver, config_dict, area_keyword_ite
matched_blocks = None
if show_debug_message:
print("current_layout_style:", current_layout_style)
area_list = None
try:
# style 2: .text-title
my_css_selector = "div.rwd-margin > div.text-title"
if current_layout_style == 1:
# style 1: .text-title
my_css_selector = "div.v-expansion-panels > div.v-expansion-panel"
# PS: price info header format also is div.v-expansion-panels > div.v-expansion-panel
my_css_selector = "div.seats-area > div.v-expansion-panel"
area_list = driver.find_elements(By.CSS_SELECTOR, my_css_selector)
except Exception as exc:
if current_layout_style == 1:
@ -10941,6 +10950,7 @@ def ticketplus_order_expansion_auto_select(driver, config_dict, area_keyword_ite
print("area_list_count is None.")
pass
is_price_panel_expanded = False
if not formated_area_list is None:
area_list_count = len(formated_area_list)
if show_debug_message:
@ -10989,6 +10999,9 @@ def ticketplus_order_expansion_auto_select(driver, config_dict, area_keyword_ite
matched_blocks.append(row)
if auto_select_mode == CONST_FROM_TOP_TO_BOTTOM:
if ' aria-expanded="true"' in row_html:
print(row_html)
is_price_panel_expanded = True
break
if show_debug_message:
@ -11008,11 +11021,19 @@ def ticketplus_order_expansion_auto_select(driver, config_dict, area_keyword_ite
# for style_1, need click once.
if show_debug_message:
print("current_layout_style:", current_layout_style)
print("is_price_panel_expanded:", is_price_panel_expanded)
if not is_price_panel_expanded:
if current_layout_style==1:
if not target_area is None:
try:
target_area.click()
#PS: must click on button instead of div to expand lay.
my_css_selector = 'button'
target_button = target_area.find_element(By.CSS_SELECTOR, my_css_selector)
target_button.click()
print("clicked on button.")
#target_area.click()
except Exception as exc:
print("click target_area link fail")
print(exc)
@ -11032,6 +11053,7 @@ def ticketplus_order_expansion_auto_select(driver, config_dict, area_keyword_ite
is_price_assign_by_bot = False
if not target_area is None:
for retry_index in range(2):
# PS: each price have each price div, so need pass parent div to increase ticket number.
is_price_assign_by_bot = ticketplus_assign_ticket_number(target_area, config_dict)
return is_need_refresh, is_price_assign_by_bot