From 7c2651fe9744ae98a29553e097977aafa23bd0aa Mon Sep 17 00:00:00 2001 From: CHUN YU YAO Date: Wed, 18 Jan 2023 16:40:41 +0800 Subject: [PATCH] 2023-01-17, support cityline/urbtix account auto keyin. --- chrome_tixcraft.py | 170 +++++++++++++++++++++++++++++++++++++++++++-- settings.json | 2 +- settings.py | 62 ++++++++++++++--- 3 files changed, 220 insertions(+), 14 deletions(-) diff --git a/chrome_tixcraft.py b/chrome_tixcraft.py index 34baca4..24795b3 100644 --- a/chrome_tixcraft.py +++ b/chrome_tixcraft.py @@ -51,7 +51,7 @@ except Exception as exc: import ssl ssl._create_default_https_context = ssl._create_unverified_context -CONST_APP_VERSION = u"MaxBot (2023.01.14) ver.7" +CONST_APP_VERSION = u"MaxBot (2023.01.17)" CONST_HOMEPAGE_DEFAULT = "https://tixcraft.com" @@ -3782,12 +3782,15 @@ def urbtix_ticket_number_auto_select(driver, ticket_number): print("varify site icon pressed.") except Exception as exc: # use plan B + ''' try: print("force to click by js.") driver.execute_script("arguments[0].click();", el_btn) ret = True except Exception as exc: pass + ''' + pass else: if show_debug_message: print("varify site icon is None.") @@ -4035,7 +4038,7 @@ def cityline_date_auto_select(driver, auto_select_mode, date_keyword, auto_reloa if len(formated_area_list) == 0: try: driver.refresh() - time.sleep(0.5) + time.sleep(0.4) except Exception as exc: pass @@ -4585,7 +4588,7 @@ def ibon_date_auto_select(driver, auto_select_mode, date_keyword, auto_reload_co if len(formated_area_list) == 0: try: driver.refresh() - time.sleep(0.5) + time.sleep(0.4) except Exception as exc: pass return ret @@ -4951,6 +4954,110 @@ def kktix_login(driver, account): return ret +def cityline_login(driver, account): + ret = False + el_email = None + try: + el_email = driver.find_element(By.CSS_SELECTOR, 'input.ant-input') + except Exception as exc: + #print("find #email fail") + #print(exc) + pass + + is_visible = False + if el_email is not None: + try: + if el_email.is_enabled(): + is_visible = True + except Exception as exc: + pass + + is_email_sent = False + if is_visible: + try: + inputed_text = el_email.get_attribute('value') + if inputed_text is not None: + if len(inputed_text) == 0: + el_email.send_keys(account) + is_email_sent = True + except Exception as exc: + pass + + el_pass = None + if is_email_sent: + try: + el_pass = driver.find_element(By.CSS_SELECTOR, 'input[type="password"]') + except Exception as exc: + pass + + is_visible = False + if el_pass is not None: + try: + if el_pass.is_enabled(): + is_visible = True + except Exception as exc: + pass + + if is_visible: + try: + el_pass.click() + except Exception as exc: + pass + + return ret + +def urbtix_login(driver, account): + ret = False + el_email = None + try: + el_email = driver.find_element(By.CSS_SELECTOR, 'input[name="loginId"]') + except Exception as exc: + #print("find #email fail") + #print(exc) + pass + + is_visible = False + if el_email is not None: + try: + if el_email.is_enabled(): + is_visible = True + except Exception as exc: + pass + + is_email_sent = False + if is_visible: + try: + inputed_text = el_email.get_attribute('value') + if inputed_text is not None: + if len(inputed_text) == 0: + el_email.send_keys(account) + is_email_sent = True + except Exception as exc: + pass + + el_pass = None + if is_email_sent: + try: + el_pass = driver.find_element(By.CSS_SELECTOR, 'input[name="password"]') + except Exception as exc: + pass + + is_visible = False + if el_pass is not None: + try: + if el_pass.is_enabled(): + is_visible = True + except Exception as exc: + pass + + if is_visible: + try: + el_pass.click() + except Exception as exc: + pass + + return ret + def check_and_play_sound_for_captcha(config_dict): play_captcha_sound = config_dict["advanced"]["play_captcha_sound"]["enable"] captcha_sound_filename = config_dict["advanced"]["play_captcha_sound"]["filename"].strip() @@ -5117,6 +5224,48 @@ def famiticket_main(driver, url, config_dict): if '/Sales/Home/Index/' in url: fami_home(driver, url, config_dict) +def urbtix_performance_confirm_dialog_popup(driver): + ret = False + + el_div = None + try: + el_div = driver.find_element(By.CSS_SELECTOR, 'div.notification-confirm-btn > div.button-text') + except Exception as exc: + #print("find modal-dialog fail") + #print(exc) + pass + + if el_div is not None: + print("bingo, found notification-confirm-btn") + is_visible = False + try: + if el_div.is_enabled(): + if el_div.is_displayed(): + is_visible = True + except Exception as exc: + pass + + if is_visible: + try: + el_div.click() + ret = True + except Exception as exc: + # use plan B + ''' + try: + print("force to click by js.") + driver.execute_script("arguments[0].click();", el_div) + ret = True + except Exception as exc: + pass + ''' + pass + + if ret: + time.sleep(0.4) + + return ret + def urbtix_main(driver, url, config_dict): # http://msg.urbtix.hk waiting_for_access_url = ['/session/landing-timer/','msg.urbtix.hk','busy.urbtix.hk'] @@ -5137,6 +5286,11 @@ def urbtix_main(driver, url, config_dict): pass pass + if '.hk/member-login' in url: + urbtix_account = config_dict["advanced"]["urbtix_account"] + if len(urbtix_account) > 2: + urbtix_login(driver, urbtix_account) + # https://www.urbtix.hk/event-detail/00000/ if '/event-detail/' in url: date_auto_select_enable = config_dict["tixcraft"]["date_auto_select"]["enable"] @@ -5157,7 +5311,12 @@ def urbtix_main(driver, url, config_dict): if is_performace_page: area_auto_select_enable = config_dict["tixcraft"]["area_auto_select"]["enable"] if area_auto_select_enable: - urbtix_performance(driver, config_dict) + + is_confirm_dialog_popup = urbtix_performance_confirm_dialog_popup(driver) + if is_confirm_dialog_popup: + print("is_confirm_dialog_popup! auto press confirm...") + else: + urbtix_performance(driver, config_dict) def check_modal_dialog_popup(driver): ret = False @@ -5185,6 +5344,9 @@ def cityline_main(driver, url, config_dict): # https://www.cityline.com/Login.html?targetUrl=https%3A%2F%2F # ignore url redirect if '/Login.html' in url: + cityline_account = config_dict["advanced"]["cityline_account"] + if len(cityline_account) > 2: + cityline_login(driver, cityline_account) return # https://msg.cityline.com/ diff --git a/settings.json b/settings.json index 3583ef7..9f6deaa 100644 --- a/settings.json +++ b/settings.json @@ -1 +1 @@ -{"homepage": "https://kktix.com", "browser": "chrome", "language": "\u7e41\u9ad4\u4e2d\u6587", "ticket_number": 2, "pass_1_seat_remaining": true, "auto_check_agree": true, "ocr_captcha": {"enable": true, "force_submit": false, "image_source": "canvas"}, "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true, "area_mode": "from top to bottom", "area_keyword_1": "", "area_keyword_1_and": "", "area_keyword_2": "", "area_keyword_2_and": "", "auto_guess_options": true, "user_guess_string": ""}, "tixcraft": {"date_auto_select": {"enable": true, "date_keyword": "", "mode": "from top to bottom"}, "area_auto_select": {"enable": true, "area_keyword_1": "", "area_keyword_2": "", "area_keyword_3": "", "area_keyword_4": "", "mode": "from top to bottom"}, "pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true, "presale_code": ""}, "advanced": {"play_captcha_sound": {"enable": true, "filename": "ding-dong.wav"}, "facebook_account": "", "kktix_account": "", "adblock_plus_enable": false}, "debug": false} \ No newline at end of file +{"homepage": "https://tixcraft.com", "browser": "chrome", "language": "\u7e41\u9ad4\u4e2d\u6587", "ticket_number": 2, "pass_1_seat_remaining": true, "auto_check_agree": true, "ocr_captcha": {"enable": true, "force_submit": false, "image_source": "canvas"}, "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true, "area_mode": "from top to bottom", "area_keyword_1": "", "area_keyword_1_and": "", "area_keyword_2": "", "area_keyword_2_and": "", "auto_guess_options": true, "user_guess_string": ""}, "tixcraft": {"date_auto_select": {"enable": true, "date_keyword": "", "mode": "from top to bottom"}, "area_auto_select": {"enable": true, "area_keyword_1": "", "area_keyword_2": "", "area_keyword_3": "", "area_keyword_4": "", "mode": "from top to bottom"}, "pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true, "presale_code": ""}, "advanced": {"play_captcha_sound": {"enable": true, "filename": "ding-dong.wav"}, "facebook_account": "", "kktix_account": "", "cityline_account": "", "urbtix_account": "", "adblock_plus_enable": false}, "debug": false} \ No newline at end of file diff --git a/settings.py b/settings.py index 9a7c363..f1ba5ca 100644 --- a/settings.py +++ b/settings.py @@ -19,7 +19,7 @@ import json import webbrowser import pyperclip -CONST_APP_VERSION = u"MaxBot (2023.01.14) ver.7" +CONST_APP_VERSION = u"MaxBot (2023.01.17)" CONST_FROM_TOP_TO_BOTTOM = u"from top to bottom" CONST_FROM_BOTTOM_TO_TOP = u"from bottom to top" @@ -93,6 +93,9 @@ def load_translate(): en_us["facebook_account"] = 'Facebook account' en_us["kktix_account"] = 'KKTIX account' + en_us["cityline_account"] = 'cityline account' + en_us["urbtix_account"] = 'URBTIX account' + en_us["play_captcha_sound"] = 'Play sound when captcha' en_us["captcha_sound_filename"] = 'captcha sound filename' en_us["adblock_plus_enable"] = 'Adblock Plus Extension' @@ -151,6 +154,9 @@ def load_translate(): zh_tw["facebook_account"] = 'Facebook 帳號' zh_tw["kktix_account"] = 'KKTIX 帳號' + zh_tw["cityline_account"] = 'cityline 帳號' + zh_tw["urbtix_account"] = 'URBTIX 帳號' + zh_tw["play_captcha_sound"] = '輸入驗證碼時播放音效' zh_tw["captcha_sound_filename"] = '驗證碼用音效檔' zh_tw["adblock_plus_enable"] = 'Adblock 瀏覽器擴充功能' @@ -210,6 +216,9 @@ def load_translate(): zh_cn["facebook_account"] = 'Facebook 帐号' zh_cn["kktix_account"] = 'KKTIX 帐号' + zh_cn["cityline_account"] = 'cityline 帳號' + zh_cn["urbtix_account"] = 'URBTIX 帳號' + zh_cn["play_captcha_sound"] = '输入验证码时播放音效' zh_cn["captcha_sound_filename"] = '验证码用音效档' zh_cn["adblock_plus_enable"] = 'Adblock 浏览器扩充功能' @@ -268,6 +277,9 @@ def load_translate(): ja_jp["facebook_account"] = 'Facebookのアカウント' ja_jp["kktix_account"] = 'KKTIXのアカウント' + ja_jp["cityline_account"] = 'citylineのアカウント' + ja_jp["urbtix_account"] = 'URBTIXのアカウント' + ja_jp["play_captcha_sound"] = 'キャプチャ時に音を鳴らす' ja_jp["captcha_sound_filename"] = 'サウンドファイル名' @@ -346,6 +358,8 @@ def get_default_config(): config_dict["advanced"]["facebook_account"] = "" config_dict["advanced"]["kktix_account"] = "" + config_dict["advanced"]["cityline_account"] = "" + config_dict["advanced"]["urbtix_account"] = "" config_dict["advanced"]["adblock_plus_enable"] = False config_dict['debug']=False @@ -425,6 +439,9 @@ def btn_save_act(language_code, slience_mode=False): global txt_facebook_account global txt_kktix_account + global txt_cityline_account + global txt_urbtix_account + global chk_state_play_captcha_sound global txt_captcha_sound_filename global chk_state_adblock_plus @@ -501,6 +518,8 @@ def btn_save_act(language_code, slience_mode=False): config_dict["advanced"]["facebook_account"] = txt_facebook_account.get().strip() config_dict["advanced"]["kktix_account"] = txt_kktix_account.get().strip() + config_dict["advanced"]["cityline_account"] = txt_cityline_account.get().strip() + config_dict["advanced"]["urbtix_account"] = txt_urbtix_account.get().strip() config_dict["advanced"]["adblock_plus_enable"] = bool(chk_state_adblock_plus.get()) config_dict["ocr_captcha"] = {} @@ -750,10 +769,15 @@ def applyNewLanguage(): global lbl_facebook_account global lbl_kktix_account + global lbl_cityline_account + global lbl_urbtix_account + global lbl_play_captcha_sound global lbl_captcha_sound_filename lbl_facebook_account.config(text=translate[language_code]["facebook_account"]) lbl_kktix_account.config(text=translate[language_code]["kktix_account"]) + lbl_cityline_account.config(text=translate[language_code]["cityline_account"]) + lbl_urbtix_account.config(text=translate[language_code]["urbtix_account"]) lbl_play_captcha_sound.config(text=translate[language_code]["play_captcha_sound"]) lbl_captcha_sound_filename.config(text=translate[language_code]["captcha_sound_filename"]) @@ -1522,15 +1546,11 @@ def AdvancedTab(root, config_dict, language_code, UI_PADDING_X): frame_group_header = Frame(root) group_row_count = 0 - facebook_account = "" - kktix_account = "" play_captcha_sound = False captcha_sound_filename = CONST_CAPTCHA_SOUND_FILENAME_DEFAULT adblock_plus_enable = False if 'advanced' in config_dict: - facebook_account = config_dict["advanced"]["facebook_account"].strip() - kktix_account = config_dict["advanced"]["kktix_account"].strip() if 'play_captcha_sound' in config_dict["advanced"]: if 'enable' in config_dict["advanced"]["play_captcha_sound"]: play_captcha_sound = config_dict["advanced"]["play_captcha_sound"]["enable"] @@ -1543,8 +1563,10 @@ def AdvancedTab(root, config_dict, language_code, UI_PADDING_X): print("==[advanced]==") print("browser", config_dict['browser']) print("language", config_dict['language']) - print("facebook_account", facebook_account) - print("kktix_account", kktix_account) + print("facebook_account", config_dict["advanced"]["facebook_account"].strip()) + print("kktix_account", config_dict["advanced"]["kktix_account"].strip()) + print("cityline_account", config_dict["advanced"]["cityline_account"].strip()) + print("urbtix_account", config_dict["advanced"]["urbtix_account"].strip()) print("play_captcha_sound", play_captcha_sound) print("captcha_sound_filename", captcha_sound_filename) print("adblock_plus_enable", adblock_plus_enable) @@ -1586,7 +1608,7 @@ def AdvancedTab(root, config_dict, language_code, UI_PADDING_X): lbl_facebook_account.grid(column=0, row=group_row_count, sticky = E) global txt_facebook_account - txt_facebook_account_value = StringVar(frame_group_header, value=facebook_account) + txt_facebook_account_value = StringVar(frame_group_header, value=config_dict["advanced"]["facebook_account"].strip()) txt_facebook_account = Entry(frame_group_header, width=20, textvariable = txt_facebook_account_value) txt_facebook_account.grid(column=1, row=group_row_count, sticky = W) @@ -1597,10 +1619,32 @@ def AdvancedTab(root, config_dict, language_code, UI_PADDING_X): lbl_kktix_account.grid(column=0, row=group_row_count, sticky = E) global txt_kktix_account - txt_kktix_account_value = StringVar(frame_group_header, value=kktix_account) + txt_kktix_account_value = StringVar(frame_group_header, value=config_dict["advanced"]["kktix_account"].strip()) txt_kktix_account = Entry(frame_group_header, width=20, textvariable = txt_kktix_account_value) txt_kktix_account.grid(column=1, row=group_row_count, sticky = W) + group_row_count +=1 + + global lbl_cityline_account + lbl_cityline_account = Label(frame_group_header, text=translate[language_code]['cityline_account']) + lbl_cityline_account.grid(column=0, row=group_row_count, sticky = E) + + global txt_cityline_account + txt_cityline_account_value = StringVar(frame_group_header, value=config_dict["advanced"]["cityline_account"].strip()) + txt_cityline_account = Entry(frame_group_header, width=20, textvariable = txt_cityline_account_value) + txt_cityline_account.grid(column=1, row=group_row_count, sticky = W) + + group_row_count +=1 + + global lbl_urbtix_account + lbl_urbtix_account = Label(frame_group_header, text=translate[language_code]['urbtix_account']) + lbl_urbtix_account.grid(column=0, row=group_row_count, sticky = E) + + global txt_urbtix_account + txt_urbtix_account_value = StringVar(frame_group_header, value=config_dict["advanced"]["urbtix_account"].strip()) + txt_urbtix_account = Entry(frame_group_header, width=20, textvariable = txt_urbtix_account_value) + txt_urbtix_account.grid(column=1, row=group_row_count, sticky = W) + group_row_count+=1 CONST_OCR_CAPTCH_IMAGE_SOURCE_NON_BROWSER = "NonBrowser"