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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
def get_all_files_in_directory(directory, ext=''):
|
2 |
+
import os
|
3 |
+
import re
|
4 |
+
custom_sort_key_re = re.compile('([0-9]+)')
|
5 |
+
|
6 |
+
def custom_sort_key(s):
|
7 |
+
# 将字符串中的数字部分转换为整数,然后进行排序
|
8 |
+
return [int(x) if x.isdigit() else x for x in custom_sort_key_re.split(s)]
|
9 |
+
|
10 |
+
all_files = []
|
11 |
+
for root, dirs, files in os.walk(directory):
|
12 |
+
for file in files:
|
13 |
+
if file.endswith(ext):
|
14 |
+
file_path = os.path.join(root, file)
|
15 |
+
all_files.append(file_path)
|
16 |
+
return sorted(all_files, key=custom_sort_key)
|
17 |
+
|
18 |
+
|
19 |
+
def clearT():
|
20 |
+
import unicodedata
|
21 |
+
from opencc import OpenCC
|
22 |
+
|
23 |
+
def full2half(input_str):
|
24 |
+
return ''.join([unicodedata.normalize('NFKC', char) for char in input_str])
|
25 |
+
|
26 |
+
cc = OpenCC('t2s') # 't2s'表示繁体转简体
|
27 |
+
|
28 |
+
def _clearT(s):
|
29 |
+
s = cc.convert(full2half(s))
|
30 |
+
return s.strip().strip(r'\n').replace('\n', '\\n')
|
31 |
+
|
32 |
+
return _clearT
|
33 |
+
|
34 |
+
|
35 |
+
clearT = clearT()
|
36 |
+
|
37 |
+
|
38 |
+
def startsWithAny(s: str, keys):
|
39 |
+
for x in keys:
|
40 |
+
if s.startswith(x):
|
41 |
+
return x
|
42 |
+
else:
|
43 |
+
return False
|
44 |
+
|
45 |
+
|
46 |
+
def endsWithAny(s: str, keys):
|
47 |
+
for x in keys:
|
48 |
+
if s.endswith(x):
|
49 |
+
return x
|
50 |
+
else:
|
51 |
+
return False
|
52 |
+
|
53 |
+
|
54 |
+
def startsWithAlnum(s: str, _chrs):
|
55 |
+
retn = ''
|
56 |
+
for char in s:
|
57 |
+
if (char.isalnum()) or (char in _chrs):
|
58 |
+
retn += char
|
59 |
+
else:
|
60 |
+
break
|
61 |
+
return retn
|
62 |
+
|
63 |
+
|
64 |
+
def startsWithCmd(s: str, _chrs=None):
|
65 |
+
if _chrs is None:
|
66 |
+
_chrs = {'_', '@'}
|
67 |
+
cmd = startsWithAlnum(s, _chrs)
|
68 |
+
if cmd:
|
69 |
+
return s.startswith(cmd + ' ')
|
70 |
+
else:
|
71 |
+
return False
|
72 |
+
|
73 |
+
|
74 |
+
import re
|
75 |
+
|
76 |
+
reg_removeWait = re.compile(r'\[.+?]')
|
77 |
+
|
78 |
+
|
79 |
+
def removeWait(_line):
|
80 |
+
_tmp = reg_removeWait.sub('', _line)
|
81 |
+
if _tmp:
|
82 |
+
return _tmp
|
83 |
+
else:
|
84 |
+
return _line
|
85 |
+
|
86 |
+
|
87 |
+
def getCmdArgs(_cmd):
|
88 |
+
_args = ['']
|
89 |
+
_i = -1
|
90 |
+
_inQuota = ''
|
91 |
+
while _i < len(_cmd) - 1:
|
92 |
+
_i += 1
|
93 |
+
char = _cmd[_i]
|
94 |
+
if _inQuota:
|
95 |
+
_args[-1] += char
|
96 |
+
if char == _inQuota:
|
97 |
+
_inQuota = ''
|
98 |
+
elif char == '\\':
|
99 |
+
_i += 1
|
100 |
+
char = _cmd[_i]
|
101 |
+
_args[-1] += char
|
102 |
+
else:
|
103 |
+
pass
|
104 |
+
else:
|
105 |
+
if char == ' ':
|
106 |
+
_args.append('')
|
107 |
+
while _i < len(_cmd) - 1:
|
108 |
+
_i += 1
|
109 |
+
char = _cmd[_i]
|
110 |
+
if char != ' ':
|
111 |
+
_i -= 1
|
112 |
+
break
|
113 |
+
continue
|
114 |
+
elif char in {'"', "'"}:
|
115 |
+
_inQuota = char
|
116 |
+
else:
|
117 |
+
pass
|
118 |
+
_args[-1] += char
|
119 |
+
continue
|
120 |
+
return _args
|
121 |
+
|
122 |
+
|
123 |
+
def args2map(_args):
|
124 |
+
retn = {}
|
125 |
+
for _i in range(1, len(_args)):
|
126 |
+
_arg = _args[_i]
|
127 |
+
if '=' not in _arg:
|
128 |
+
if '=' in _arg:
|
129 |
+
_arg = _arg.replace('=', '=')
|
130 |
+
else:
|
131 |
+
continue
|
132 |
+
_idx = _arg.index('=')
|
133 |
+
_k = _arg[:_idx]
|
134 |
+
if '"' in _k or "'" in _k:
|
135 |
+
continue
|
136 |
+
_v = _arg[_idx + 1:]
|
137 |
+
if _v.startswith('"') or _v.startswith("'"):
|
138 |
+
_v = _v[1:len(_v) - 1]
|
139 |
+
retn[_k] = _v
|
140 |
+
return retn
|
141 |
+
|
142 |
+
|
143 |
+
# =================
|
144 |
+
|
145 |
+
a = get_all_files_in_directory(r'E:\tmp\无颜之月\textchs', ext='.scw.txt')
|
146 |
+
b = r'E:\tmp\无颜之月\text'
|
147 |
+
|
148 |
+
# =================
|
149 |
+
|
150 |
+
sc = {}
|
151 |
+
|
152 |
+
_n = {
|
153 |
+
"【浩一】": "浩一",
|
154 |
+
"【女人】": "女人",
|
155 |
+
"【女孩】": "女孩",
|
156 |
+
"【声音】": "声音",
|
157 |
+
"【铃菜】": "铃菜",
|
158 |
+
"【水菜】": "水菜",
|
159 |
+
"【??】": "?",
|
160 |
+
"【加贺】": "加贺",
|
161 |
+
"【千贺子】": "千贺子",
|
162 |
+
"【泽口】": "泽口",
|
163 |
+
"【本山】": "本山",
|
164 |
+
"【衣绪】": "衣绪",
|
165 |
+
"【知美】": "知美",
|
166 |
+
"【一平】": "一平",
|
167 |
+
"【我】": "我",
|
168 |
+
"【少女】": "少女",
|
169 |
+
"【戴眼镜女孩】": "戴眼镜女孩",
|
170 |
+
"【沙也加】": "沙也加",
|
171 |
+
"【由利子】": "由利子",
|
172 |
+
"【五平】": "五平",
|
173 |
+
"【女性】": "女性",
|
174 |
+
"【千代】": "千代",
|
175 |
+
"【?】": "?",
|
176 |
+
"【男人】": "男人",
|
177 |
+
"【村人】": "村人",
|
178 |
+
"【女人的声音】": "女人的声音",
|
179 |
+
"【善治郎】": "善治郎",
|
180 |
+
"【漆原】": "漆原",
|
181 |
+
"【女孩子】": "女孩子",
|
182 |
+
"【巫女】": "巫女",
|
183 |
+
"【东】": "东",
|
184 |
+
"【女性村人】": "女性村人",
|
185 |
+
"【男人1】": "男人1",
|
186 |
+
"【男人2】": "男人2",
|
187 |
+
"【男人3】": "男人3",
|
188 |
+
"【男人4】": "男人4",
|
189 |
+
"【村人A】": "村人A",
|
190 |
+
"【村人B】": "村人B",
|
191 |
+
"【俺】": "俺"
|
192 |
+
}
|
193 |
+
|
194 |
+
# =================
|
195 |
+
for path in a:
|
196 |
+
name = path[path.rindex('\\'):]
|
197 |
+
name = '0'
|
198 |
+
if name not in sc:
|
199 |
+
sc[name] = []
|
200 |
+
print(name)
|
201 |
+
# =================
|
202 |
+
|
203 |
+
with open(path, 'r', encoding='utf-8') as f:
|
204 |
+
data = list(filter(lambda x: x,
|
205 |
+
(x.rstrip() for x in f.readlines())))
|
206 |
+
|
207 |
+
# =================
|
208 |
+
w_i = -1
|
209 |
+
while w_i < len(data) - 1:
|
210 |
+
w_i += 1
|
211 |
+
line: str = data[w_i]
|
212 |
+
|
213 |
+
# =================
|
214 |
+
if line.startswith('#F'):
|
215 |
+
tmp = line.split('#F')
|
216 |
+
n = tmp[1]
|
217 |
+
line = tmp[-1]
|
218 |
+
if n in _n:
|
219 |
+
n = _n[n]
|
220 |
+
else:
|
221 |
+
_n[n] = clearT(n.strip('【】')).replace('/', '&')
|
222 |
+
print(line)
|
223 |
+
elif line.startswith(' '):
|
224 |
+
n = '旁白'
|
225 |
+
line = line.strip()
|
226 |
+
else:
|
227 |
+
continue
|
228 |
+
d = clearT(line)
|
229 |
+
if d:
|
230 |
+
sc[name].append(n + ':' + d)
|
231 |
+
|
232 |
+
# =================
|
233 |
+
|
234 |
+
for k, v in sc.items():
|
235 |
+
if v:
|
236 |
+
with open(b + f'\\{k}.txt', 'w', encoding='utf-8') as f:
|
237 |
+
f.write('\n'.join(v))
|
238 |
+
|
239 |
+
# =================
|
240 |
+
import json
|
241 |
+
|
242 |
+
tmp = json.dumps(_n, ensure_ascii=False, indent=4)
|