forked from moux23333/H-SR-cutscene-extractor
-
Notifications
You must be signed in to change notification settings - Fork 1
/
experimental.py
147 lines (130 loc) · 6.41 KB
/
experimental.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import os
import subprocess
import time
import customtkinter as ctk
import win10toast
from customtkinter import filedialog
from usm import demux
fildiag = ctk.CTk()
fildiag.withdraw()
ctk.set_appearance_mode("dark")
ctk.set_default_color_theme("blue")
gui = ctk.CTk()
gui.geometry("300x400")
gui.title("HSR CG Extractor")
odir = r"./output"
fngivf = ""
fngacn = ""
fngaen = ""
fngajp = ""
fngakor = ""
ofimerg = None
usmfile = ""
converted_files = []
startstr = """
██╗░░██╗██╗░██████╗██████╗░
██║░░██║╚═╝██╔════╝██╔══██╗
███████║░░░╚█████╗░██████╔╝
██╔══██║░░░░╚═══██╗██╔══██╗
██║░░██║██╗██████╔╝██║░░██║
╚═╝░░╚═╝╚═╝╚═════╝░╚═╝░░╚═╝
░█████╗░░██████╗░ ███████╗██╗░░██╗████████╗██████╗░░█████╗░░█████╗░████████╗░█████╗░██████╗░
██╔══██╗██╔════╝░ ██╔════╝╚██╗██╔╝╚══██╔══╝██╔══██╗██╔══██╗██╔══██╗╚══██╔══╝██╔══██╗██╔══██╗
██║░░╚═╝██║░░██╗░ █████╗░░░╚███╔╝░░░░██║░░░██████╔╝███████║██║░░╚═╝░░░██║░░░██║░░██║██████╔╝
██║░░██╗██║░░╚██╗ ██╔══╝░░░██╔██╗░░░░██║░░░██╔══██╗██╔══██║██║░░██╗░░░██║░░░██║░░██║██╔══██╗
╚█████╔╝╚██████╔╝ ███████╗██╔╝╚██╗░░░██║░░░██║░░██║██║░░██║╚█████╔╝░░░██║░░░╚█████╔╝██║░░██║
░╚════╝░░╚═════╝░ ╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░░╚═╝╚═╝░░╚═╝░╚════╝░░░░╚═╝░░░░╚════╝░╚═╝░░╚═╝
Credits to BUnipendix for the decryptor
"""
def extvid(usm_path, output_dir="./output"):
a = demux.UsmDemuxer(usm_path)
video_name, audio_names = a.export(output_dir)
return video_name, audio_names
def meraud(ad, v, otfi):
cmd = ['./ffmpeg.exe', '-i', v, '-i', ad, '-c:v', 'copy', '-c:a', 'aac', '-strict', 'experimental',
otfi]
subprocess.call(cmd)
def convfi(ifi, ofi):
ffmpeg_cmd = ["ffmpeg", "-i", ifi, ofi]
subprocess.call(ffmpeg_cmd)
time.sleep(2)
inputtt = ""
def openfile():
global inputtt, usmfile
inputtt = filedialog.askopenfilename(filetypes=[("USM files", "*.usm")])
usmfile = os.path.basename(inputtt)
usmtext.configure(text=f"Pick USM File: {usmfile}")
gui.update()
inp2 = 0
def selectlang(c):
global inp2
match c:
case "CN":
inp2 = 0
case "EN":
inp2 = 1
case "JP":
inp2 = 2
case "KOR":
inp2 = 3
def checkbox_event():
print("Checkbox event")
def run():
global fngivf, fngacn, fngaen, fngajp, fngakor, ofimerg, inp2, inputtt
ext = extvid(inputtt)
for root, dirs, files in os.walk(odir):
for file in files:
file_path = os.path.join(root, file)
file_name, file_ext = os.path.splitext(file)
match file_ext:
case ".ivf":
output_file = f"./output/converted/{file_name}.mp4"
convfi(file_path, output_file)
converted_files.append(file_path)
fngivf = f"./output/converted/{file_name}.mp4"
case ".adx":
output_file = f"./output/converted/{file_name}.mp3"
convfi(file_path, output_file)
converted_files.append(file_path)
if "_0" in file_name:
fngacn = f"./output/converted/{file_name}.mp3"
ofimerg = f"./output/final/{file_name}-final.mp4"
elif "_1" in file_name:
fngaen = f"./output/converted/{file_name}.mp3"
ofimerg = f"./output/final/{file_name}-final.mp4"
elif "_2" in file_name:
fngajp = f"./output/converted/{file_name}.mp3"
ofimerg = f"./output/final/{file_name}-final.mp4"
elif "_3" in file_name:
fngakor = f"./output/converted/{file_name}.mp3"
ofimerg = f"./output/final/{file_name}-final.mp4"
match inp2:
case 0:
meraud(fngacn, fngivf, ofimerg)
case 1:
meraud(fngaen, fngivf, ofimerg)
case 2:
meraud(fngajp, fngivf, ofimerg)
case 3:
meraud(fngakor, fngivf, ofimerg)
win10toast.ToastNotifier().show_toast("HSR CG Extractor", "Finished", duration=5)
for file_path in converted_files:
os.remove(file_path)
if check_var.get() == "on":
os.system(f"start {ofimerg}")
else:
pass
exit()
os.system("cls")
print(startstr)
usmtext = ctk.CTkLabel(gui, text="Pick USM File:")
usmtext.pack()
label = ctk.CTkLabel(gui, text="CTkLabel", fg_color="transparent")
ctk.CTkButton(gui, text="Browse", command=openfile, state="normal").pack()
ctk.CTkLabel(gui, text="Pick Language:").pack()
ctk.CTkComboBox(gui, values=["CN", "EN", "JP", "KOR"], command=selectlang).pack()
check_var = ctk.StringVar(value="on")
ctk.CTkCheckBox(gui, text="Open CG after done?", command=checkbox_event,
variable=check_var, onvalue="on", offvalue="off").pack()
runbtn = ctk.CTkButton(gui, text="run", command=run).pack()
gui.mainloop()