├── KKSCF.exe ├── KKSCF.py └── README.md /KKSCF.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FlYiNGPoTAToChiP/KK_SunshineCardFilter/6a07b021561c60565e1648ad15ca05bfd0ed9a38/KKSCF.exe -------------------------------------------------------------------------------- /KKSCF.py: -------------------------------------------------------------------------------- 1 | import os 2 | import re as regex 3 | import codecs 4 | import shutil 5 | import tkinter 6 | from tkinter import Tk, filedialog, messagebox, ttk 7 | 8 | path = os.getcwd() 9 | png_list = [] 10 | png_count = 0 11 | kks_card_list = [] 12 | kks_folder = "_KKS_card_" 13 | kks_folder2 = "_KKS_to_KK_" 14 | do_convert_default = True 15 | 16 | 17 | def get_list(folder_path): 18 | new_list = [] 19 | for (_, _, files) in os.walk(folder_path): 20 | for filename in files: 21 | if regex.match(r".*(\.png)$", filename): 22 | new_list.append(filename) 23 | return new_list 24 | 25 | 26 | def check_png(card_path): 27 | with codecs.open(card_path, "rb") as card: 28 | data = card.read() 29 | card_type = 0 30 | if data.find(b"KoiKatuChara") != -1: 31 | card_type = 1 32 | if data.find(b"KoiKatuCharaSP") != -1: 33 | card_type = 2 34 | elif data.find(b"KoiKatuCharaSun") != -1: 35 | card_type = 3 36 | print(f"[{card_type}] {card_path}") 37 | return card_type 38 | 39 | 40 | def do_convert_check_event(): 41 | print(f"convert = {do_convert.get()}") 42 | 43 | 44 | def convert_kk(card_name, card_path, destination_path): 45 | with codecs.open(card_path, mode="rb") as card: 46 | data = card.read() 47 | 48 | replace_list = [ 49 | [b"\x15\xe3\x80\x90KoiKatuCharaSun", b"\x12\xe3\x80\x90KoiKatuChara"], 50 | [b"Parameter\xa7version\xa50.0.6", b"Parameter\xa7version\xa50.0.5"], 51 | [b"version\xa50.0.6\xa3sex", b"version\xa50.0.5\xa3sex"], 52 | ] 53 | 54 | for text in replace_list: 55 | data = data.replace(text[0], text[1]) 56 | 57 | new_file_path = os.path.normpath(os.path.join(destination_path, f"KKS2KK_{card_name}")) 58 | # print(f"new_file_path {new_file_path}") 59 | 60 | with codecs.open(new_file_path, "wb") as new_card: 61 | new_card.write(data) 62 | 63 | 64 | def c_get_list(): 65 | global path, png_list, png_count, png_count_t 66 | b_sel['state'] = 'disabled' 67 | path = filedialog.askdirectory(title="Select target path (folder contain cards)", mustexist=True) 68 | 69 | if path: 70 | print(f"path: {path}") 71 | os.chdir(path) 72 | else: 73 | print("no path") 74 | b_sel['state'] = 'normal' 75 | return 76 | 77 | png_list = get_list(path) 78 | png_count = len(png_list) 79 | png_count_t.set(f"png found: {png_count}") 80 | 81 | if png_count > 0: 82 | b_p['state'] = 'normal' 83 | else: 84 | b_p['state'] = 'disabled' 85 | 86 | b_sel['state'] = 'normal' 87 | 88 | 89 | def process_png(): 90 | global path, png_list, kks_folder, kks_folder2, kks_card_list, window, png_count, png_count_t 91 | 92 | count = len(png_list) 93 | if count > 0: 94 | bar = ttk.Progressbar(window, maximum=count, length=250) 95 | bar.pack(pady=10) 96 | bar_val = 0 97 | print("0: unknown / 1: kk / 2: kksp / 3: kks") 98 | for png in png_list: 99 | if check_png(png) == 3: 100 | kks_card_list.append(png) 101 | bar_val = bar_val + 1 102 | bar['value'] = bar_val 103 | window.update() 104 | bar.destroy() 105 | else: 106 | messagebox.showinfo("Done", f"no PNG found") 107 | return 108 | 109 | count = len(kks_card_list) 110 | if count > 0: 111 | print(kks_card_list) 112 | 113 | target_folder = os.path.normpath(os.path.join(path, kks_folder)) 114 | target_folder2 = os.path.normpath(os.path.join(path, kks_folder2)) 115 | if not os.path.isdir(target_folder): 116 | os.mkdir(kks_folder) 117 | 118 | is_convert = do_convert.get() 119 | if is_convert: 120 | print(f"do convert is [{is_convert}]") 121 | if not os.path.isdir(target_folder2): 122 | os.mkdir(target_folder2) 123 | 124 | for card in kks_card_list: 125 | source = os.path.normpath(os.path.join(path, card)) 126 | target = os.path.normpath(os.path.join(target_folder, card)) 127 | 128 | # copy & convert before move 129 | if is_convert: 130 | convert_kk(card, source, target_folder2) 131 | 132 | # move file 133 | shutil.move(source, target) 134 | 135 | if is_convert: 136 | messagebox.showinfo("Done", f"[{count}] cards\nmove to [{kks_folder}] folder\nconvert and save to [{kks_folder2}] folder") 137 | else: 138 | messagebox.showinfo("Done", f"[{count}] cards\nmove to [{kks_folder}] folder") 139 | else: 140 | messagebox.showinfo("Done", f"no KKS card found") 141 | 142 | # reset 143 | png_list = [] 144 | kks_card_list = [] 145 | png_count = 0 146 | png_count_t.set(f"png found: 0") 147 | b_p['state'] = 'disabled' 148 | 149 | 150 | window = Tk() 151 | # window.withdraw() 152 | window.title("KKSCF") 153 | w = 300 154 | h = 350 155 | ltx = int((window.winfo_screenwidth() - w) / 2) 156 | lty = int((window.winfo_screenheight() - h) / 2) 157 | window.geometry(f'{w}x{h}+{ltx}+{lty}') 158 | 159 | tkinter.Label(window, text=" ", pady=5).pack() 160 | 161 | b_sel = tkinter.Button(window, text="Select folder contain cards", padx=10, pady=10, relief="raised", bd=3, command=c_get_list) 162 | b_sel.pack() 163 | 164 | tkinter.Label(window, text=" ", pady=5).pack() 165 | 166 | png_count_t = tkinter.StringVar() 167 | png_count_t.set(f"png found: {png_count}") 168 | tkinter.Label(window, textvariable=png_count_t, pady=10).pack() 169 | 170 | tkinter.Label(window, text=" ", pady=5).pack() 171 | 172 | do_convert = tkinter.BooleanVar() 173 | do_convert.set(do_convert_default) 174 | do_convert_check = tkinter.Checkbutton(window, text='copy & convert KKS to KK', variable=do_convert, command=do_convert_check_event) 175 | do_convert_check.pack() 176 | 177 | tkinter.Label(window, text=" ", pady=5).pack() 178 | 179 | b_p = tkinter.Button(window, text="Process", relief="raised", padx=10, pady=10, bd=3, command=process_png) 180 | b_p.pack() 181 | b_p['state'] = 'disabled' 182 | 183 | tkinter.Label(window, text=" ", pady=5).pack() 184 | 185 | window.mainloop() 186 | exit(0) 187 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # KoikatsuSunshine Card Filter & Converter 2 | 3 | check and 4 | 1. move KKS card to a new folder `_KKS_card_` 5 | 2. convert KKS card to KK card `_KKS_to_KK_` (on by default) 6 | 7 | ![](https://i.imgur.com/AvOeUrY.png) 8 | 9 | Python 3.8 10 | 11 | 1. run it 12 | 2. select folder 13 | 3. process 14 | 4. wait 15 | 16 | 2022-12-05: 17 | - kks to kk 18 | - exe (64-bit) 19 | --------------------------------------------------------------------------------