forked from GarnetSunset/Ishin-Machine-Translation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autopatcher.py
95 lines (85 loc) · 5.65 KB
/
autopatcher.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import os, sys, requests,shutil,zipfile, io, eboot_translator
from distutils.dir_util import copy_tree
if not os.path.exists("pkgsForUpdate"):
os.makedirs("pkgsForUpdate")
if os.path.exists("patch"):
shutil.rmtree(os.getcwd()+"/patch/")
digitalPS3 = "https://a0.ww.np.dl.playstation.net/tpl/np/NPJB00532/NPJB00532-ver.xml"
response = requests.get(digitalPS3, verify=False)
data = xmltodict.parse(response.content)
digital = []
for item in data["titlepatch"]["tag"]["package"]:
digital.append(item["@url"])
discPS3 = "https://a0.ww.np.dl.playstation.net/tpl/np/BLJM61149/BLJM61149-ver.xml"
response = requests.get(digitalPS3, verify=False)
data = xmltodict.parse(response.content)
disc = []
for item in data["titlepatch"]["tag"]["package"]:
disc.append(item["@url"])
r = requests.get("https://raw.githubusercontent.com/windsurfer1122/PSN_get_pkg_info/master/PSN_get_pkg_info.py", allow_redirects=True)
open("pkgsForUpdate/PSN_get_pkg_info.py", 'wb').write(r.content)
r = requests.get("https://cdn.discordapp.com/attachments/732351773687414825/824632561245356062/pkgsForUpdate.zip")
z = zipfile.ZipFile(io.BytesIO(r.content))
z.extractall("pkgsForUpdate")
discOrDigital = input("Do you have the bluray, digital, or PS4 version of Ishin?\nType \"B\" for BluRay, type \"D\" for Digital, type \"P\" for PS4\n> ")
if discOrDigital == "B":
for url in disc:
r = requests.get(url, allow_redirects=True)
open("pkgsForUpdate/"+url.rsplit('/', 1)[-1], 'wb').write(r.content)
elif discOrDigital == "D":
for url in digital:
r = requests.get(url, allow_redirects=True)
open("pkgsForUpdate/"+url.rsplit('/', 1)[-1], 'wb').write(r.content)
else:
print("incorrect input")
sys.exit()
for file in os.listdir("pkgsForUpdate"):
if file.endswith(".pkg"):
with open(os.devnull, 'wb') as devnull:
os.system("python "+os.getcwd()+"/pkgsForUpdate/PSN_get_pkg_info.py "+os.getcwd()+"/pkgsForUpdate/"+file+" --content "+os.getcwd()+"/pkgsForUpdate/update")
os.remove(os.getcwd()+"/pkgsForUpdate/"+file)
directory_contents = os.listdir(os.getcwd()+"/pkgsForUpdate/update/")
copy_tree(os.getcwd()+"/pkgsForUpdate/update/"+directory_contents[0], os.getcwd()+"/patch/")
shutil.rmtree(os.getcwd()+"/pkgsForUpdate/update/"+directory_contents[0])
copy_tree(os.getcwd()+"/mainDIR/", os.getcwd()+"/patch/")
files_in_directory = os.listdir(os.getcwd()+"/patch/")
os.chdir("pkgsForUpdate")
shutil.move("make_package_npdrm_retail.exe", "../patch/make_package_npdrm_retail.exe")
if discOrDigital == "B":
os.system("scetool -d ../patch/USRDIR/EBOOT.BIN ../patch/USRDIR/EBOOT_DECR.BIN")
shutil.copyfile("../patch/USRDIR/EBOOT.BIN","../patch/USRDIR/EBOOT_BKP.BIN")
eboot_translator.replace_strings("../ishin_translation.xlsx","../patch/USRDIR/EBOOT_DECR.BIN",ignore_length=False,output="../patch/USRDIR/EBOOT_Translated.BIN",version="Disc")
os.system("scetool.exe -v --sce-type=SELF --skip-sections=TRUE --key-revision=01 --self-auth-id=1010000001000003 --self-app-version=0001000000000000 --self-add-shdrs=TRUE --self-vendor-id=01000002 --self-type=NPDRM --self-fw-version=0003004000000000 --np-license-type=FREE --np-content-id=NPJB00532 --np-app-type=EXEC --np-real-fname=EBOOT.BIN --encrypt ../patch/USRDIR/EBOOT_Translated.BIN ../patch/USRDIR/EBOOT.BIN")
shutil.move("../patch/PARAM.SFO_B", "../patch/PARAM.SFO")
if os.path.isfile("../patch/JP0177-NPJB00532_00-RYUISHINRETAIL00.pkg"):
os.remove("../patch/JP0177-NPJB00532_00-RYUISHINRETAIL00.pkg")
text_file = open("../patch/package.conf", "wt")
packageconf = "Content-ID = JP0177-BLJM61149_00-GAMEVER0108WEEK8-A0108-V0100-PE\nk_licensee = 0x00000000000000000000000000000000\nDRM_Type = Free\nContent_Type = GameData\nPackageVersion = 01.69"
text_file.write(packageconf)
text_file.close()
if discOrDigital == "D":
os.system("decrypt_eboot.exe ../patch/USRDIR/EBOOT.BIN ../patch/USRDIR/EBOOT_DECR.BIN JP0177-NPJB00532_00-RYUISHINRETAIL00.rap")
shutil.copyfile("../patch/USRDIR/EBOOT.BIN","../patch/USRDIR/EBOOT_BKP.BIN")
eboot_translator.replace_strings("../ishin_translation.xlsx","../patch/USRDIR/EBOOT_DECR.BIN",ignore_length=False,output="../patch/USRDIR/EBOOT_Translated.BIN",version="PSN")
os.system("scetool.exe -v --sce-type=SELF --skip-sections=TRUE --key-revision=01 --self-auth-id=1010000001000003 --self-app-version=0001000000000000 --self-add-shdrs=TRUE --self-vendor-id=01000002 --self-type=NPDRM --self-fw-version=0003004000000000 --np-license-type=FREE --np-content-id=BLJM61149 --np-app-type=EXEC --np-real-fname=EBOOT.BIN --encrypt ../patch/USRDIR/EBOOT_Translated.BIN ../patch/USRDIR/EBOOT.BIN")
shutil.move("../patch/PARAM.SFO_D", "../patch/PARAM.SFO")
if os.path.isfile("../patch/JP0177-NPJB00532_00-RYUISHINRETAIL00.pkg"):
os.remove("../patch/JP0177-NPJB00532_00-RYUISHINRETAIL00.pkg")
text_file = open("../patch/package.conf", "wt")
packageconf = "Content-ID = JP0177-NPJB00532_00-RYUISHINRETAIL00\nk_licensee = 0x00000000000000000000000000000000\nDRM_Type = Free\nContent_Type = GameExec\nPackageVersion = 01.69"
text_file.write(packageconf)
text_file.close()
if discOrDigital == "P":
print("illdoitlater")
os.chdir("../patch/")
if os.path.exists("USRDIR/data/"):
shutil.rmtree("USRDIR/data/")
shutil.copytree("../export/data/", "USRDIR/data/")
os.system("make_package_npdrm_retail.exe")
os.chdir("..")
filtered_files = [file for file in files_in_directory if file.endswith(".psd")]
for file in filtered_files:
path_to_file = os.path.join(os.getcwd()+"/patch/", file)
os.remove(path_to_file)
os.remove(os.getcwd()+"/patch/make_package_npdrm_retail.exe")
shutil.rmtree(os.getcwd()+"/pkgsForUpdate/")