code cleanup (#66)

Co-authored-by: eli <frozenpandaman@users.noreply.github.com>
This commit is contained in:
Sou Niyari 2022-10-28 06:45:20 +09:00 committed by GitHub
parent 9999e5586f
commit 2d59ff653c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

View File

@ -89,22 +89,22 @@ def get_web_view_ver(bhead=[], gtoken=""):
'X-Requested-With': 'com.nintendo.znca',
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-Mode': 'no-cors',
'Sec-Fetch-Dest': 'script'
'Sec-Fetch-Dest': 'script',
'Referer': SPLATNET3_URL # sending w/o lang, na_country, na_lang params
}
if bhead:
app_head["User-Agent"] = bhead.get("User-Agent")
app_head["Referer"] = bhead.get("Referer")
app_head["Accept-Encoding"] = bhead.get("Accept-Encoding")
app_head["Accept-Language"] = bhead.get("Accept-Language")
main_js_body = requests.get(main_js_url, headers=app_head, cookies=app_cookies)
if main_js_body.status_code != 200:
return iksm.WEB_VIEW_VER_FALLBACK
return WEB_VIEW_VER_FALLBACK
pattern = r"\b(?P<revision>[0-9a-f]{40})\b.*revision_info_not_set\"\),.*?=\"(?P<version>\d+\.\d+\.\d+)"
match = re.search(pattern, main_js_body.text)
if match is None:
return iksm.WEB_VIEW_VER_FALLBACK
return WEB_VIEW_VER_FALLBACK
version, revision = match.group("version"), match.group("revision")
ver_string = f"{version}-{revision[:8]}"

5
s3s.py
View File

@ -88,7 +88,7 @@ def headbutt():
'Authorization': f'Bearer {BULLETTOKEN}', # update every time it's called with current global var
'Accept-Language': USER_LANG,
'User-Agent': APP_USER_AGENT,
'X-Web-View-Ver': iksm.WEB_VIEW_VERSION,
'X-Web-View-Ver': iksm.get_web_view_ver(),
'Content-Type': 'application/json',
'Accept': '*/*',
'Origin': iksm.SPLATNET3_URL,
@ -105,8 +105,7 @@ def prefetch_checks(printout=False):
if printout:
print("Validating your tokens...", end='\r')
global WEB_VIEW_VERSION
WEB_VIEW_VERSION = iksm.get_web_view_ver()
iksm.get_web_view_ver() # setup
if SESSION_TOKEN == "" or GTOKEN == "" or BULLETTOKEN == "":
gen_new_tokens("blank")