From c057fe0c3d50da22e581e20f1a181ae82addaa3d Mon Sep 17 00:00:00 2001 From: chasa <79016507+itschasa@users.noreply.github.com> Date: Tue, 26 Sep 2023 19:58:03 +0100 Subject: [PATCH] v1.2.4 - fix build number fetch --- client_info.py | 25 ++++++++++++++++++++----- main.py | 2 +- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/client_info.py b/client_info.py index 7b281a7..5520b1a 100644 --- a/client_info.py +++ b/client_info.py @@ -19,11 +19,26 @@ from main import request_client def get_client_build_number(): - res = request_client.get("https://discord.com/login").text - file_with_build_num = 'https://discord.com/assets/' + re.compile(r'assets/+([a-z0-9]+)\.js').findall(res)[-2]+'.js' - req_file_build = request_client.get(file_with_build_num).text - index_of_build_num = req_file_build.find('buildNumber')+24 - return int(req_file_build[index_of_build_num:index_of_build_num+6]) + for _ in range(3): + try: + resp = request_client.post('https://cordapi.dolfi.es/api/v2/properties/web', timeout=5) + js = resp.json() + return js['client']['build_number'] + except Exception: + continue + + try: + login_page_request = request_client.get('https://discord.com/login', timeout=7) + login_page = login_page_request.text + build_url = 'https://discord.com/assets/' + re.compile(r'assets/+([a-z0-9]+)\.js').findall(login_page)[-2] + '.js' + build_request = request_client.get(build_url, timeout=7) + build_file = build_request.text + build_index = build_file.find('buildNumber') + 24 + return int(build_file[build_index : build_index + 6]) + + except: + print("Failed to get build number from both dolfies API and Discord, failing back to hardcoded value...") + return 231376 discord_build = get_client_build_number() super_properties = { diff --git a/main.py b/main.py index ebfe22a..503bbb3 100644 --- a/main.py +++ b/main.py @@ -5,7 +5,7 @@ # License v3.0. A copy of this license is available at # https://www.gnu.org/licenses/agpl-3.0.en.html -app_version = "v1.2.4" +app_version = "v1.2.5" import time import sys