diff --git a/chrome_tixcraft.py b/chrome_tixcraft.py index 45f8406..d3e8304 100644 --- a/chrome_tixcraft.py +++ b/chrome_tixcraft.py @@ -44,7 +44,7 @@ except Exception as exc: print(exc) pass -CONST_APP_VERSION = "MaxBot (2024.04.02)" +CONST_APP_VERSION = "MaxBot (2024.04.03)" CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt" CONST_MAXBOT_CONFIG_FILE = "settings.json" diff --git a/config_launcher.py b/config_launcher.py index e67b0d1..03eb6d8 100644 --- a/config_launcher.py +++ b/config_launcher.py @@ -24,7 +24,7 @@ import webbrowser import util -CONST_APP_VERSION = "MaxBot (2024.04.02)" +CONST_APP_VERSION = "MaxBot (2024.04.03)" CONST_MAXBOT_LAUNCHER_FILE = "config_launcher.json" CONST_MAXBOT_CONFIG_FILE = "settings.json" diff --git a/kktix_status.py b/kktix_status.py index a1c7d20..fdcd058 100644 --- a/kktix_status.py +++ b/kktix_status.py @@ -29,7 +29,7 @@ from datetime import datetime import util -CONST_APP_VERSION = "MaxBot (2024.04.02)" +CONST_APP_VERSION = "MaxBot (2024.04.03)" CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_KKTIX_CONFIG_FILE = "kktix.json" diff --git a/nodriver_tixcraft.py b/nodriver_tixcraft.py index 0879a93..e67e8e8 100644 --- a/nodriver_tixcraft.py +++ b/nodriver_tixcraft.py @@ -22,6 +22,7 @@ import nodriver as uc from nodriver import cdp from nodriver.core.config import Config from urllib3.exceptions import InsecureRequestWarning +import urllib.parse import util from NonBrowser import NonBrowser @@ -32,7 +33,7 @@ except Exception as exc: print(exc) pass -CONST_APP_VERSION = "MaxBot (2024.04.02)" +CONST_APP_VERSION = "MaxBot (2024.04.03)" CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt" CONST_MAXBOT_CONFIG_FILE = "settings.json" @@ -1606,21 +1607,58 @@ async def nodriver_ibon_main(tab, url, config_dict, ibon_dict, ocr, Captcha_Brow async def nodriver_cityline_auto_retry_access(tab, url, config_dict): - try: - # https://event.cityline.com/utsvInternet/EVENT_NAME/home?lang=TW - if "home?lang=TW" in url: - url_array = url.split("home?lang=TW") - if len(url_array) > 2: - new_url = url_array[0] + "home?lang=TW" - print("redirect to url:", new_url) - tab = await tab.get(new_url) - time.sleep(0.1) + cookies = await tab.browser.cookies.get_all() + is_cookie_exist = False + for cookie in cookies: + if 'my-' in cookie.name: + cookie.value="" + break + await tab.browser.cookies.set_all(cookies) + + + cityline_event_url = "https://event.cityline.com/" + if "?loc=" in url: + loc = url.split("?loc=")[1] + if len(loc) > 0: + if "&" in loc: + loc = url.split("&")[0] + loc_decode = urllib.parse.unquote(loc) + if len(loc_decode) > 0: + if loc_decode[:1]=="/": + loc_decode = loc_decode[1:] + if loc_decode[:6] != "https:": + new_url = cityline_event_url + loc_decode + if not "&lang=" in new_url: + new_url = new_url + "&lang=TW" + if new_url != url: + try: + print("redirect to url:", new_url) + tab = await tab.get(new_url) + time.sleep(0.2) + except Exception as e: + print(e) + pass + + # https://event.cityline.com/utsvInternet/EVENT_NAME/home?lang=TW + if "lang=TW" in url: + url_array = url.split("lang=TW") + if len(url_array) > 2: + new_url = url_array[0] + "lang=TW" + if new_url != url: + try: + print("redirect to url:", new_url) + tab = await tab.get(new_url) + time.sleep(0.2) + except Exception as exc: + print(exc) + pass + try: btn_retry = await tab.query_selector('button') if btn_retry: #print("found button to click.") btn_retry.click() - time.sleep(0.1) + time.sleep(0.2) except Exception as exc: print(exc) pass @@ -1682,7 +1720,8 @@ async def nodriver_cityline_date_auto_select(tab, auto_select_mode, date_keyword my_css_selector = "button.date-time-position" area_list = await tab.query_selector_all(my_css_selector) except Exception as exc: - print(exc) + #print(exc) + pass matched_blocks = None if area_list: @@ -1736,7 +1775,7 @@ async def nodriver_cityline_date_auto_select(tab, auto_select_mode, date_keyword print("not found date-time-position") pass else: - print("date date-time-position is None") + #print("date date-time-position is None") pass target_area = util.get_target_item_from_matched_list(matched_blocks, auto_select_mode) diff --git a/settings.py b/settings.py index 27a5ff5..50c7e51 100644 --- a/settings.py +++ b/settings.py @@ -41,7 +41,7 @@ try: except Exception as exc: pass -CONST_APP_VERSION = "MaxBot (2024.04.02)" +CONST_APP_VERSION = "MaxBot (2024.04.03)" CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt" CONST_MAXBOT_CONFIG_FILE = "settings.json" diff --git a/webdriver/Maxbotplus_1.0.0/js/cityline_msg_front.js b/webdriver/Maxbotplus_1.0.0/js/cityline_msg_front.js index f769173..2344263 100644 --- a/webdriver/Maxbotplus_1.0.0/js/cityline_msg_front.js +++ b/webdriver/Maxbotplus_1.0.0/js/cityline_msg_front.js @@ -24,14 +24,21 @@ function begin() setInterval(() => { //retry(); //console.log("trigger"); + let url = window.location.href; + if(url.indexOf('lang=TW') > -1) { + const myArray = url.split("lang=TW"); + url = url[0]+"lang=TW"; + } $(".eventposter").off(); if (typeof setRetryUrl !== "undefined") { - setRetryUrl(window.location.href); + setRetryUrl(url); } $(".btn_cta").prop('disabled', false); //$(".btn_cta").prop('disabled', false).trigger("click"); if (typeof goEvent !== "undefined") { - if(location.href.indexOf('home?') > -1) { + if(location.href.indexOf('home?') > -1 + || location.href.indexOf('lang=') > -1 + || location.href.indexOf('?loc=') > -1) { goEvent(); } } diff --git a/webdriver/Maxbotplus_1.0.0/manifest.json b/webdriver/Maxbotplus_1.0.0/manifest.json index bf341b4..ac5d90f 100644 --- a/webdriver/Maxbotplus_1.0.0/manifest.json +++ b/webdriver/Maxbotplus_1.0.0/manifest.json @@ -349,6 +349,8 @@ "https://shows.cityline.com/en/*", "https://priority.cityline.com/tc/*", "https://priority.cityline.com/en/*", + "https://sports.cityline.com/tc/*", + "https://sports.cityline.com/en/*", "https://cultural.cityline.com/tc/*", "https://cultural.cityline.com/en/*" ],