2024-04-06 update for kktix

master
Your Name 2024-04-15 12:09:44 +08:00
parent 639da5a3d7
commit 7e5929f3dc
7 changed files with 45 additions and 27 deletions

View File

@ -44,7 +44,7 @@ except Exception as exc:
print(exc) print(exc)
pass pass
CONST_APP_VERSION = "MaxBot (2024.04.04)" CONST_APP_VERSION = "MaxBot (2024.04.05)"
CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt" CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"

View File

@ -24,7 +24,7 @@ import webbrowser
import util import util
CONST_APP_VERSION = "MaxBot (2024.04.04)" CONST_APP_VERSION = "MaxBot (2024.04.05)"
CONST_MAXBOT_LAUNCHER_FILE = "config_launcher.json" CONST_MAXBOT_LAUNCHER_FILE = "config_launcher.json"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"

View File

@ -29,7 +29,7 @@ from datetime import datetime
import util import util
CONST_APP_VERSION = "MaxBot (2024.04.04)" CONST_APP_VERSION = "MaxBot (2024.04.05)"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"
CONST_MAXBOT_KKTIX_CONFIG_FILE = "kktix.json" CONST_MAXBOT_KKTIX_CONFIG_FILE = "kktix.json"

View File

@ -33,7 +33,7 @@ except Exception as exc:
print(exc) print(exc)
pass pass
CONST_APP_VERSION = "MaxBot (2024.04.04)" CONST_APP_VERSION = "MaxBot (2024.04.05)"
CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt" CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"
@ -596,29 +596,26 @@ async def nodriver_kktix_assign_ticket_number(tab, config_dict, kktix_area_keywo
if not target_area is None: if not target_area is None:
current_ticket_number = "" current_ticket_number = ""
if show_debug_message: if show_debug_message:
print("try to get input box value.") print("try to set input box value.")
try: try:
current_ticket_number = str(target_area.attribute('value')).strip() current_ticket_number = await target_area.apply('function (element) { return element.value; } ')
except Exception as exc: except Exception as exc:
pass pass
if show_debug_message:
print("current_ticket_number", current_ticket_number)
if len(current_ticket_number) > 0: if len(current_ticket_number) > 0:
if current_ticket_number == "0": if current_ticket_number == "0":
try: try:
print("asssign ticket number:%s" % ticket_number_str) print("asssign ticket number:%s" % ticket_number_str)
target_area.clear_input() await target_area.click()
target_area.send_keys(ticket_number_str) await target_area.apply('function (element) {element.value = ""; } ')
await target_area.send_keys(ticket_number_str);
is_ticket_number_assigned = True is_ticket_number_assigned = True
except Exception as exc: except Exception as exc:
print("asssign ticket number to ticket-price field Exception:") print("asssign ticket number to ticket-price field Exception:")
print(exc) print(exc)
try:
target_area.clear()
target_area.send_keys("1")
is_ticket_number_assigned = True
except Exception as exc2:
print("asssign ticket number to ticket-price still failed.")
pass
else: else:
if show_debug_message: if show_debug_message:
print("value already assigned.") print("value already assigned.")
@ -1618,6 +1615,7 @@ async def nodriver_cityline_auto_retry_access(tab, url, config_dict):
cityline_event_url = "https://event.cityline.com/" cityline_event_url = "https://event.cityline.com/"
if "?loc=" in url: if "?loc=" in url:
url = url.replace("%3Flang%3DTW%26lang%3DTW","%3Flang%3DTW")
loc = url.split("?loc=")[1] loc = url.split("?loc=")[1]
if len(loc) > 0: if len(loc) > 0:
if "&" in loc: if "&" in loc:
@ -1630,11 +1628,14 @@ async def nodriver_cityline_auto_retry_access(tab, url, config_dict):
new_url = cityline_event_url + loc_decode new_url = cityline_event_url + loc_decode
if not "&lang=" in new_url: if not "&lang=" in new_url:
new_url = new_url + "&lang=TW" new_url = new_url + "&lang=TW"
new_url = new_url.replace("lang=TW&lang=TW","lang=TW")
if new_url != url: if new_url != url:
try: try:
#print("old url:", url)
print("redirect to url:", new_url) print("redirect to url:", new_url)
tab = await tab.get(new_url) tab = await tab.get(new_url)
time.sleep(0.2) time.sleep(0.2)
pass
except Exception as e: except Exception as e:
print(e) print(e)
pass pass
@ -1646,6 +1647,7 @@ async def nodriver_cityline_auto_retry_access(tab, url, config_dict):
new_url = url_array[0] + "lang=TW" new_url = url_array[0] + "lang=TW"
if new_url != url: if new_url != url:
try: try:
new_url = new_url.replace("lang=TW&lang=TW","lang=TW")
print("redirect to url:", new_url) print("redirect to url:", new_url)
tab = await tab.get(new_url) tab = await tab.get(new_url)
time.sleep(0.2) time.sleep(0.2)
@ -1834,6 +1836,11 @@ async def nodriver_cityline_close_second_tab(tab, url):
return new_tab return new_tab
async def nodriver_cityline_main(tab, url, config_dict): async def nodriver_cityline_main(tab, url, config_dict):
global cityline_dict
if not 'cityline_dict' in globals():
cityline_dict = {}
cityline_dict["played_sound_ticket"] = False
if 'msg.cityline.com' in url or 'event.cityline.com' in url: if 'msg.cityline.com' in url or 'event.cityline.com' in url:
await nodriver_cityline_auto_retry_access(tab, url, config_dict) await nodriver_cityline_auto_retry_access(tab, url, config_dict)
@ -1865,7 +1872,13 @@ async def nodriver_cityline_main(tab, url, config_dict):
# area page: # area page:
# TODO: # TODO:
#https://venue.cityline.com/utsvInternet/EVENT_NAME/performance?event=EVENT_CODE&perfId=PROFORMANCE_ID #https://venue.cityline.com/utsvInternet/EVENT_NAME/performance?event=EVENT_CODE&perfId=PROFORMANCE_ID
pass if 'venue.cityline.com' in url and '/performance?':
if config_dict["advanced"]["play_sound"]["ticket"]:
if not cityline_dict["played_sound_ticket"]:
play_sound_while_ordering(config_dict)
cityline_dict["played_sound_ticket"] = True
else:
cityline_dict["played_sound_ticket"] = False
return tab return tab

View File

@ -41,7 +41,7 @@ try:
except Exception as exc: except Exception as exc:
pass pass
CONST_APP_VERSION = "MaxBot (2024.04.04)" CONST_APP_VERSION = "MaxBot (2024.04.05)"
CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt" CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"

View File

@ -16,7 +16,7 @@ function begin()
// too short to cause error. // too short to cause error.
if(auto_reload_page_interval < 0.05) { if(auto_reload_page_interval < 0.05) {
auto_reload_page_interval = 0.1; auto_reload_page_interval = 0.2;
} }
if(status=='ON') { if(status=='ON') {
@ -36,11 +36,15 @@ function begin()
$(".btn_cta").prop('disabled', false); $(".btn_cta").prop('disabled', false);
//$(".btn_cta").prop('disabled', false).trigger("click"); //$(".btn_cta").prop('disabled', false).trigger("click");
if (typeof goEvent !== "undefined") { if (typeof goEvent !== "undefined") {
if(location.href.indexOf('home?') > -1 let is_need_goEvent = false;
|| location.href.indexOf('lang=') > -1 if(location.href.indexOf('home?') > -1) is_need_goEvent = true;
|| location.href.indexOf('?loc=') > -1) { if(location.href.indexOf('?loc=') > -1) is_need_goEvent = true;
if(location.href.indexOf('lang=') > -1) is_need_goEvent = true;
if(is_need_goEvent) {
goEvent(); goEvent();
} }
} else {
$("#btn-retry-en-1").prop('disabled', false).trigger("click");
} }
}, target_interval); }, target_interval);
} }
@ -109,10 +113,11 @@ if(getHtmlDocName()==null) {
history.back(); history.back();
} }
if (typeof goEvent !== "undefined") { if (typeof goEvent !== "undefined") {
if(location.href.indexOf('home?') > -1 let is_need_back = true;
|| location.href.indexOf('lang=') > -1) { if(location.href.indexOf('home?') > -1) is_need_back = false;
//goEvent(); if(location.href.indexOf('?loc=') > -1) is_need_back = false;
} else { if(location.href.indexOf('lang=') > -1) is_need_back = false;
if (is_need_back) {
history.back(); history.back();
} }
} }

View File

@ -434,5 +434,5 @@
] ]
} }
], ],
"version": "1.0.23" "version": "1.0.24"
} }