This commit is contained in:
katboi01 2025-01-24 13:31:49 +01:00
parent 222c73f667
commit 358657c3d8
5 changed files with 18 additions and 15 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*.cfg
*__pycache__*

View File

@ -3,9 +3,9 @@ import sys
import wmi
import hashlib
import requests
import dmmUpdater
import subprocess
import urllib.parse
import dmmUpdater
from uuid import getnode
from bs4 import BeautifulSoup
from pypasser import reCaptchaV3
@ -28,12 +28,12 @@ def retrieve_login_token(session : requests.Session):
print("Retrieving login form")
url = "https://accounts.dmm.com/service/login/password"
result = session.get(url)
result.raise_for_status()
page = BeautifulSoup(result.content, 'html.parser')
token = page.find('input', attrs={"name":"token"}).get("value")
return token
except Exception as e:
print("Failed to retrieve login form:", e)
return None
def retrieve_captcha_token():
try:
@ -41,7 +41,6 @@ def retrieve_captcha_token():
return captcha
except Exception as e:
print("Failed to solve captcha:", e)
return None
def retrieve_auth_keys(login, password, token, captcha, session : requests.Session):
try:
@ -50,11 +49,11 @@ def retrieve_auth_keys(login, password, token, captcha, session : requests.Sessi
data = f"token={token}&login_id={login}&password={password}&prompt=&device=games-player&recaptchaToken={captcha}"
headers = {"Content-Type": "application/x-www-form-urlencoded"}
result = session.post(url, data, headers=headers)
result.raise_for_status()
cookies = result.cookies.get_dict()
return cookies["login_secure_id"], cookies["login_session_id"]
except Exception as e:
print("Failed to log in:", e)
return None, None
def retrieve_update_params(game_id, login_secure, login_session, use_proxy):
try:
@ -64,7 +63,7 @@ def retrieve_update_params(game_id, login_secure, login_session, use_proxy):
cookies = {"login_secure_id":login_secure, "login_session_id":login_session}
url = "https://katworks.sytes.net/KF/Api/DMM/filelist" if use_proxy else "https://apidgp-gameplayer.games.dmm.com/v5/r2/filelist/cl"
result = requests.post(url, cookies=cookies, headers=headers, json=data)
result.raise_for_status()
data = result.json()["data"]
game_version = data["latest_version"]
print("Latest version:", game_version)
@ -74,7 +73,6 @@ def retrieve_update_params(game_id, login_secure, login_session, use_proxy):
return file_list_url, file_list_params
except Exception as e:
print("Failed to retrieve update file list:", e)
return
def retrieve_launch_params(game_id, mac_addr, hdd_serial, motherboard, login_secure, login_session, use_proxy):
try:
@ -84,12 +82,11 @@ def retrieve_launch_params(game_id, mac_addr, hdd_serial, motherboard, login_sec
cookies = {"login_secure_id":login_secure, "login_session_id":login_session}
url = "https://katworks.sytes.net/KF/Api/DMM/launch" if use_proxy else "https://apidgp-gameplayer.games.dmm.com/v5/r2/launch/cl"
result = requests.post(url, cookies=cookies, headers=headers, json=data)
result.raise_for_status()
data = result.json()["data"]
return data["execute_args"]
except Exception as e:
print("Failed to retrieve launch arguments:", e)
return None
def main(args):
if len(args) != 7:
@ -120,7 +117,6 @@ def main(args):
if token == None or captcha == None:
return
#auth keys are also saved as cookies in session
login_secure, login_session = retrieve_auth_keys(login, password, token, captcha, session)
if not use_proxy: input("Enable VPN now and press Enter")
@ -129,12 +125,16 @@ def main(args):
file_list_url, file_access_params = retrieve_update_params(game_id, login_secure, login_session, use_proxy)
if file_list_url == None or file_access_params == None:
return
dmmUpdater.update_game(os.path.dirname(exe_location), file_list_url, file_access_params)
execute_args = retrieve_launch_params(game_id, mac_addr, hdd_serial, motherboard, login_secure, login_session, use_proxy)
if execute_args == None:
return
if not use_proxy: input("Disable VPN now and press Enter")
if update_game:
dmmUpdater.update_game(os.path.dirname(exe_location), file_list_url, file_access_params)
print("Starting game")
args = [exe_location] + execute_args.split()
print(args)

View File

@ -22,7 +22,9 @@ def progressbar(it, prefix="", size=60, out=sys.stdout): # Python3.3+
def get_file_list(url):
url = "https://apidgp-gameplayer.games.dmm.com" + url
print("Retrieving file list from " + url)
data = requests.get(url).json()["data"]
result = requests.get(url)
result.raise_for_status()
data = result.json()["data"]
return data["domain"], data["file_list"]
def get_file_hash(file_path):
@ -37,11 +39,12 @@ def get_file_hash(file_path):
return file_hash.hexdigest()
def update_game(game_path, files_url, files_param):
print("Updating game")
server_url, server_files = get_file_list(files_url)
server_file_dict = {file["local_path"]: file for file in server_files}
local_files = [os.path.join(dp, f).replace("\\", "/") for dp, dn, filenames in os.walk(game_path) for f in filenames]
local_file_dict = {"/" + os.path.relpath(r, game_path).replace("\\", "/"): {"abs_path":r, "hash":""} for r in local_files if not "BepInEx" in r}
local_file_dict = {"/" + os.path.relpath(r, game_path).replace("\\", "/"): {"abs_path":r, "hash":""} for r in local_files}
files_to_download = []
files_to_delete = []

View File

@ -11,7 +11,6 @@ IF NOT EXIST %file_name% (
set /p dmm_login=DMM Login:
set /p dmm_password=DMM Password:
set /p confirm="Your login tokens will be sent through Katboi's VPN machine, is that ok? Personal VPN is required if not (yes/no):"
echo !confirm!
if /i "!confirm!"=="yes" (
set use_proxy=true
) else (

View File

@ -11,7 +11,6 @@ IF NOT EXIST %file_name% (
set /p dmm_login=DMM Login:
set /p dmm_password=DMM Password:
set /p confirm="Your login tokens will be sent through Katboi's VPN machine, is that ok? Personal VPN is required if not (yes/no):"
echo !confirm!
if /i "!confirm!"=="yes" (
set use_proxy=true
) else (