From a4785322a8ac9ba23224b7010eaf519e0b1e96e7 Mon Sep 17 00:00:00 2001 From: qjzcj2008 Date: Sat, 2 Dec 2023 14:52:51 +0800 Subject: [PATCH 1/2] prefer to use NSO ver from f token gen provider --- iksm.py | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/iksm.py b/iksm.py index a6382c6..4733a37 100644 --- a/iksm.py +++ b/iksm.py @@ -5,6 +5,8 @@ import base64, hashlib, json, os, re, sys, urllib import requests from bs4 import BeautifulSoup +from s3s import F_GEN_URL as f_token_gen_url +from s3s import A_VERSION as s3s_ver USE_OLD_NSOAPP_VER = False # Change this to True if you're getting a "9403: Invalid token." error @@ -26,7 +28,7 @@ SPLATNET3_URL = "https://api.lp1.av5ja.srv.nintendo.net" session = requests.Session() def get_nsoapp_version(): - '''Fetches the current Nintendo Switch Online app version from the Apple App Store and sets it globally.''' + '''Fetches the current Nintendo Switch Online app version from f token genaration provider or the Apple App Store and sets it globally.''' if USE_OLD_NSOAPP_VER: return NSOAPP_VER_FALLBACK @@ -35,16 +37,29 @@ def get_nsoapp_version(): if NSOAPP_VERSION != "unknown": # already set return NSOAPP_VERSION else: - try: - page = requests.get("https://apps.apple.com/us/app/nintendo-switch-online/id1234806557") - soup = BeautifulSoup(page.text, 'html.parser') - elt = soup.find("p", {"class": "whats-new__latest__version"}) - ver = elt.get_text().replace("Version ", "").strip() + try: # prefer to use NSO version from F_GEN + f_token_conf_url = f_token_gen_url[:-1] + "config" + f_token_conf_header = {'User-Agent': f's3s/{s3s_ver}'} + f_token_conf_rsp = requests.get(f_token_conf_url,headers=f_token_conf_header) + f_token_conf_json = json.loads(f_token_conf_rsp.text) + ver = f_token_conf_json["nso_version"] NSOAPP_VERSION = ver return NSOAPP_VERSION - except: # error with web request + except: # error with get version from F_GEN fallback to APP Store Update version + try: + page = requests.get("https://apps.apple.com/us/app/nintendo-switch-online/id1234806557") + soup = BeautifulSoup(page.text, 'html.parser') + elt = soup.find("p", {"class": "whats-new__latest__version"}) + ver = elt.get_text().replace("Version ", "").strip() + + NSOAPP_VERSION = ver + + return NSOAPP_VERSION + except: # error with web request + pass + return NSOAPP_VER_FALLBACK From 541378a4da411d8b25110a50032041c91262bba4 Mon Sep 17 00:00:00 2001 From: eli Date: Mon, 11 Dec 2023 11:12:44 +0900 Subject: [PATCH 2/2] update logic & i/o for getting NSO ver from `f` API --- iksm.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/iksm.py b/iksm.py index 4733a37..e06eca7 100644 --- a/iksm.py +++ b/iksm.py @@ -5,7 +5,7 @@ import base64, hashlib, json, os, re, sys, urllib import requests from bs4 import BeautifulSoup -from s3s import F_GEN_URL as f_token_gen_url +from s3s import F_GEN_URL as f_gen_url from s3s import A_VERSION as s3s_ver USE_OLD_NSOAPP_VER = False # Change this to True if you're getting a "9403: Invalid token." error @@ -37,17 +37,17 @@ def get_nsoapp_version(): if NSOAPP_VERSION != "unknown": # already set return NSOAPP_VERSION else: - try: # prefer to use NSO version from F_GEN - f_token_conf_url = f_token_gen_url[:-1] + "config" - f_token_conf_header = {'User-Agent': f's3s/{s3s_ver}'} - f_token_conf_rsp = requests.get(f_token_conf_url,headers=f_token_conf_header) - f_token_conf_json = json.loads(f_token_conf_rsp.text) - ver = f_token_conf_json["nso_version"] + try: # try to get NSO version from f API + f_conf_url = os.path.dirname(f_gen_url) + "/config" # default endpoint for imink API + f_conf_header = {'User-Agent': f's3s/{s3s_ver}'} + f_conf_rsp = requests.get(f_conf_url, headers=f_conf_header) + f_conf_json = json.loads(f_conf_rsp.text) + ver = f_conf_json["nso_version"] NSOAPP_VERSION = ver return NSOAPP_VERSION - except: # error with get version from F_GEN fallback to APP Store Update version + except: # fallback to apple app store try: page = requests.get("https://apps.apple.com/us/app/nintendo-switch-online/id1234806557") soup = BeautifulSoup(page.text, 'html.parser')