-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess.py
60 lines (53 loc) · 1.73 KB
/
process.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
import mutagen
from mutagen.id3 import APIC, ID3
import glob
from deflacue import deflacue
from mutagen.flac import FLAC, Picture
import os
import chardet
#不自动删除处理后的源文件 True为删除,False为不删除
ifdelete = False
# CUE处理工具箱
bias = "pro_"
count = 0
for k in glob.glob("*"):
try:
if k.split("\\")[-1] == "deflacue":
continue
if os.path.isdir(k):
os.rename(k, bias + str(count))
count += 1
except:
break
arr = []
for a in glob.glob("*"):
if os.path.isdir(a):
arr.append(a)
for k in arr:
g = glob.glob(k + "/*")
img = [x for x in g if any(x.endswith(e) for e in ['.png', '.bmp', '.jpg'])]
cue = list(filter(lambda x: ".cue" in x or ".cue" in x, g))
music = [x for x in g if any(x.endswith(e) for e in ['.ape', '.tak', '.wav'])]
for c in cue:
cuen = os.getcwd() + '\\' + c
with open(cuen, 'rb') as f:
data = f.read()
encoding = chardet.detect(data)['encoding']
try:
process = deflacue.Deflacue(source_path=cuen, encoding=encoding)
process.process_cue(cue_file=cuen, target_path=k, delete=ifdelete, music=music, img=img, needImage=True)
except:
print("分割错误:文件来源-" + c)
# if len(img) == 0:
# continue
# for audiopath in g:
# if audiopath.split("\\")[-1].split(".")[-1] != "flac":
# continue
# audio = FLAC(audiopath)
# with open(img[0],'rb') as image:
# picture = Picture()
# picture.data = image.read()
# picture.type = 3
# picture.mime = "image/jpeg"
# audio.add_picture(picture)
# audio.save()