-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathid3zhconv.py
33 lines (25 loc) · 948 Bytes
/
id3zhconv.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
from zhconv import convert
import eyed3
import os
simplifiedOption = None
while simplifiedOption != 1 and simplifiedOption != 2:
input_value = input("请选择 1:转换到繁体 2:转换到简体 \nPlease Enter 1 or 2: ")
try:
simplifiedOption = int(input_value)
except ValueError:
print("{input} is not a number, please enter number 1 or 2 only".format(input=input_value))
files = os.listdir()
files = [fi for fi in files if fi.endswith(".mp3")]
if simplifiedOption==1:
convertTo = 'zh-hant'
else:
convertTo = 'zh-hans'
for mp3file in files:
audiofile = eyed3.load(mp3file)
tagToConvert = ['artist', 'album','album_artist',"title"]
for tag in tagToConvert:
if getattr(audiofile.tag, tag) is not None:
setattr(audiofile.tag, tag, convert(getattr(audiofile.tag, tag), convertTo))
audiofile.tag.save()
for fi in files:
os.rename(fi, convert(fi, convertTo))