This repository has been archived by the owner on Jul 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bms2mp3.py
69 lines (58 loc) · 1.46 KB
/
bms2mp3.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
import os.path
from os import system
from multiprocessing import Pool
from file_utils import get_bms_file_list
def command(info: dict):
dirname = info.get('dir')
filename = info.get('file')
source = f"./bms_files/{dirname}/{filename}"
output = f"./mp3_files/{dirname}/{filename[:-4:]}.mp3"
if not os.path.exists(output):
print(output)
system(f"./bin/bms2mp3 \"{source}\" \"{output}\"")
if __name__ == "__main__":
targets = [
# "0-9",
# "A",
# "B",
# "C",
# "D",
# "E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
#"M",
"N",
"O",
"P",
"Q",
"R",
# "S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z",
# "漢字",
]
if not os.path.isdir("./mp3_files"):
os.mkdir("./mp3_files")
if not os.path.isdir("./bme_files"):
os.mkdir("./bme_files")
for target in targets:
print("Processing", target)
files = sorted(get_bms_file_list(target))
if len(files) == 0:
continue
if not os.path.isdir(f"./mp3_files/{target}"):
os.mkdir(f"./mp3_files/{target}")
if not os.path.isdir(f"./bme_files/{target}"):
os.mkdir(f"./bme_files/{target}")
with Pool(20) as p:
p.map(command, list(map(lambda file: dict(file=file, dir=target), files)))