Update chrome_tixcraft.py

master
Max 2023-12-13 19:30:00 +08:00 committed by GitHub
parent 65a33116f2
commit aef141c3b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 34 additions and 14 deletions

View File

@ -11267,7 +11267,7 @@ def ticketplus_order_expansion_panel(driver, config_dict, current_layout_style):
if is_need_refresh: if is_need_refresh:
try: try:
# vue mode, refresh need more condition to check. # vue mode, refresh need more condition to check.
#driver.refresh() driver.refresh()
pass pass
except Exception as exc: except Exception as exc:
pass pass
@ -11316,13 +11316,10 @@ def ticketplus_order_exclusive_code(driver, config_dict, fail_list):
return is_answer_sent, fail_list, is_question_popup return is_answer_sent, fail_list, is_question_popup
def ticketplus_order_get_ticket_area_detla(driver):
def ticketplus_order_auto_reload_coming_soon(driver): target_count=0
is_vue_ready = False getSeatsByTicketAreaIdUrl = ""
try: try:
getSeatsByTicketAreaIdUrl = ""
#r = driver.execute_script("return window.performance.getEntries();")
logs = driver.get_log("performance") logs = driver.get_log("performance")
url_list = [] url_list = []
for log in logs: for log in logs:
@ -11333,12 +11330,30 @@ def ticketplus_order_auto_reload_coming_soon(driver):
if 'request' in network_log["params"]: if 'request' in network_log["params"]:
if 'url' in network_log["params"]["request"]: if 'url' in network_log["params"]["request"]:
if 'apis.ticketplus.com.tw/config/api/' in network_log["params"]["request"]["url"]: if 'apis.ticketplus.com.tw/config/api/' in network_log["params"]["request"]["url"]:
#print("url:", network_log["params"]["request"]["url"])
if 'get?ticketAreaId=' in network_log["params"]["request"]["url"]: if 'get?ticketAreaId=' in network_log["params"]["request"]["url"]:
#print("url:", network_log["params"]["request"]["url"])
target_count+=1
getSeatsByTicketAreaIdUrl = network_log["params"]["request"]["url"] getSeatsByTicketAreaIdUrl = network_log["params"]["request"]["url"]
is_vue_ready = True except Exception as e:
break #raise e
pass
return target_count, getSeatsByTicketAreaIdUrl
def ticketplus_order_auto_reload_coming_soon(driver, delta):
is_vue_ready = False
target_count = 0
try:
getSeatsByTicketAreaIdUrl = ""
#r = driver.execute_script("return window.performance.getEntries();")
target_count, getSeatsByTicketAreaIdUrl = ticketplus_order_get_ticket_area_detla(driver)
if target_count > delta:
is_vue_ready = True
print("is_vue_ready:", is_vue_ready, getSeatsByTicketAreaIdUrl)
if is_vue_ready: if is_vue_ready:
js = """var t = JSON.parse(Cookies.get("user")) ? JSON.parse(Cookies.get("user")).access_token : ""; js = """var t = JSON.parse(Cookies.get("user")) ? JSON.parse(Cookies.get("user")).access_token : "";
fetch("%s",{headers: { fetch("%s",{headers: {
@ -11349,7 +11364,8 @@ return response.json();
console.log(data); console.log(data);
if(data.result.product.length>0) if(data.result.product.length>0)
if(data.result.product[0].status=="pending") { if(data.result.product[0].status=="pending") {
location.reload(); console.log("pending, start to reload");
location.reload();
} }
}).catch(function (err){ }).catch(function (err){
console.log(err); console.log(err);
@ -11361,6 +11377,8 @@ console.log(err);
#print(exc) #print(exc)
pass pass
return target_count
def ticketplus_order(driver, config_dict, ocr, Captcha_Browser, ticketplus_dict): def ticketplus_order(driver, config_dict, ocr, Captcha_Browser, ticketplus_dict):
show_debug_message = True # debug. show_debug_message = True # debug.
@ -11907,10 +11925,11 @@ def ticketplus_main(driver, url, config_dict, ocr, Captcha_Browser, ticketplus_d
is_button_pressed = ticketplus_accept_realname_card(driver) is_button_pressed = ticketplus_accept_realname_card(driver)
is_button_pressed = ticketplus_accept_order_fail(driver) is_button_pressed = ticketplus_accept_order_fail(driver)
ticketplus_order_auto_reload_coming_soon(driver) ticketplus_dict["delta"] = ticketplus_order_auto_reload_coming_soon(driver, ticketplus_dict["delta"])
is_captcha_sent, ticketplus_dict = ticketplus_order(driver, config_dict, ocr, Captcha_Browser, ticketplus_dict) is_captcha_sent, ticketplus_dict = ticketplus_order(driver, config_dict, ocr, Captcha_Browser, ticketplus_dict)
else: else:
ticketplus_dict["delta"], getSeatsByTicketAreaIdUrl = ticketplus_order_get_ticket_area_detla(driver)
ticketplus_dict["fail_list"]=[] ticketplus_dict["fail_list"]=[]
#https://ticketplus.com.tw/confirm/xx/oo #https://ticketplus.com.tw/confirm/xx/oo
@ -11920,7 +11939,7 @@ def ticketplus_main(driver, url, config_dict, ocr, Captcha_Browser, ticketplus_d
is_event_page = True is_event_page = True
if is_event_page: if is_event_page:
print("is_popup_confirm",ticketplus_dict["is_popup_confirm"]) #print("is_popup_confirm",ticketplus_dict["is_popup_confirm"])
if not ticketplus_dict["is_popup_confirm"]: if not ticketplus_dict["is_popup_confirm"]:
ticketplus_dict["is_popup_confirm"] = True ticketplus_dict["is_popup_confirm"] = True
play_sound_while_ordering(config_dict) play_sound_while_ordering(config_dict)
@ -11958,7 +11977,7 @@ def get_current_url(driver):
if window_handles_count==0: if window_handles_count==0:
try: try:
driver_log = driver.get_log('driver')[-1]['message'] driver_log = driver.get_log('driver')[-1]['message']
print("get_log:", driver_log) #print("get_log:", driver_log)
if DISCONNECTED_MSG in driver_log: if DISCONNECTED_MSG in driver_log:
print('quit bot by NoSuchWindowException') print('quit bot by NoSuchWindowException')
is_quit_bot = True is_quit_bot = True
@ -12074,6 +12093,7 @@ def main(args):
ticketplus_dict = {} ticketplus_dict = {}
ticketplus_dict["fail_list"]=[] ticketplus_dict["fail_list"]=[]
ticketplus_dict["delta"]=0
ticketplus_dict["is_popup_confirm"] = False ticketplus_dict["is_popup_confirm"] = False
ocr = None ocr = None