-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
53 lines (50 loc) · 1.79 KB
/
test.py
File metadata and controls
53 lines (50 loc) · 1.79 KB
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
import os
import subprocess
from setupparser import args
def main():
ext = [".wav", ".mp3"]
input_path = os.path.normpath(args.input_path)
isDIRTF = os.path.isdir(args.input_path)
if isDIRTF:
outputFolder = os.path.join(input_path, "JSON")
os.mkdir(outputFolder)
for root, dirs, files in os.walk(input_path):
for filename in files:
file = os.path.join(root, filename)
if filename.endswith(".wav") or filename.endswith(".mp3"):
name = os.path.basename(file)
outname1 = name.replace(".wav", "")
outname2 = outname1.replace(".mp3", "")
outname = outname2 + ".json"
output = os.path.join(outputFolder, outname)
command = (
args.mediainfo_path,
"-i",
file,
"--LogFile=",
output,
)
with open(output, "w") as f:
subprocess.run(command, stdout=f)
else:
pass
else:
pass
else:
if input_path.endswith(".wav") or input_path.endswith(".mp3"):
name = os.path.basename(input_path)
outname1 = name.replace(".wav", "")
outname2 = outname1.replace(".mp3", "")
outname = outname2 + ".json"
output = os.path.join(outputFolder, outname)
command = (
args.mediainfo_path,
"-i",
file,
"--LogFile=",
output,
)
with open(output, "w") as f:
subprocess.run(command, stdout=f)
else:
pass