2024-04-03, update for cityline.

master
Your Name 2024-04-12 15:46:24 +08:00
parent da36916d69
commit a4382e4f71
7 changed files with 67 additions and 19 deletions

View File

@ -44,7 +44,7 @@ except Exception as exc:
print(exc) print(exc)
pass 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_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.02)" CONST_APP_VERSION = "MaxBot (2024.04.03)"
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.02)" CONST_APP_VERSION = "MaxBot (2024.04.03)"
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

@ -22,6 +22,7 @@ import nodriver as uc
from nodriver import cdp from nodriver import cdp
from nodriver.core.config import Config from nodriver.core.config import Config
from urllib3.exceptions import InsecureRequestWarning from urllib3.exceptions import InsecureRequestWarning
import urllib.parse
import util import util
from NonBrowser import NonBrowser from NonBrowser import NonBrowser
@ -32,7 +33,7 @@ except Exception as exc:
print(exc) print(exc)
pass 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_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt"
CONST_MAXBOT_CONFIG_FILE = "settings.json" 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): async def nodriver_cityline_auto_retry_access(tab, url, config_dict):
try: cookies = await tab.browser.cookies.get_all()
# https://event.cityline.com/utsvInternet/EVENT_NAME/home?lang=TW is_cookie_exist = False
if "home?lang=TW" in url: for cookie in cookies:
url_array = url.split("home?lang=TW") if 'my-' in cookie.name:
if len(url_array) > 2: cookie.value=""
new_url = url_array[0] + "home?lang=TW" break
print("redirect to url:", new_url) await tab.browser.cookies.set_all(cookies)
tab = await tab.get(new_url)
time.sleep(0.1)
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') btn_retry = await tab.query_selector('button')
if btn_retry: if btn_retry:
#print("found button to click.") #print("found button to click.")
btn_retry.click() btn_retry.click()
time.sleep(0.1) time.sleep(0.2)
except Exception as exc: except Exception as exc:
print(exc) print(exc)
pass 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" my_css_selector = "button.date-time-position"
area_list = await tab.query_selector_all(my_css_selector) area_list = await tab.query_selector_all(my_css_selector)
except Exception as exc: except Exception as exc:
print(exc) #print(exc)
pass
matched_blocks = None matched_blocks = None
if area_list: 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") print("not found date-time-position")
pass pass
else: else:
print("date date-time-position is None") #print("date date-time-position is None")
pass pass
target_area = util.get_target_item_from_matched_list(matched_blocks, auto_select_mode) target_area = util.get_target_item_from_matched_list(matched_blocks, auto_select_mode)

View File

@ -41,7 +41,7 @@ try:
except Exception as exc: except Exception as exc:
pass 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_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"

View File

@ -24,14 +24,21 @@ function begin()
setInterval(() => { setInterval(() => {
//retry(); //retry();
//console.log("trigger"); //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(); $(".eventposter").off();
if (typeof setRetryUrl !== "undefined") { if (typeof setRetryUrl !== "undefined") {
setRetryUrl(window.location.href); setRetryUrl(url);
} }
$(".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) { if(location.href.indexOf('home?') > -1
|| location.href.indexOf('lang=') > -1
|| location.href.indexOf('?loc=') > -1) {
goEvent(); goEvent();
} }
} }

View File

@ -349,6 +349,8 @@
"https://shows.cityline.com/en/*", "https://shows.cityline.com/en/*",
"https://priority.cityline.com/tc/*", "https://priority.cityline.com/tc/*",
"https://priority.cityline.com/en/*", "https://priority.cityline.com/en/*",
"https://sports.cityline.com/tc/*",
"https://sports.cityline.com/en/*",
"https://cultural.cityline.com/tc/*", "https://cultural.cityline.com/tc/*",
"https://cultural.cityline.com/en/*" "https://cultural.cityline.com/en/*"
], ],