-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
27 lines (22 loc) · 992 Bytes
/
main.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
import converter
import os
from srt import SrcFormatBuilder
from converter.draft_content import CaptionsTracker
user_home = os.path.expanduser("~")
jianying_dir = "/Library/Containers/com.lemon.lvpro/Data/Movies/JianyingPro"
base_dir = user_home + jianying_dir + '/User Data/Projects/com.lveditor.draft'
if __name__ == '__main__':
subtitle_file = "draft_info.json"
counter = 0
while True:
capdir = input("请输入字幕文件目录:")
filepath = base_dir + "/" + capdir + "/" + subtitle_file
print('字幕文件:%s' % filepath)
tracks = CaptionsTracker(filepath).read().caption_source
srt_source = SrcFormatBuilder(tracks).build()
with open('./subtitles.srt', 'w', encoding='utf-8') as f:
f.write(srt_source)
f.close()
converter.srt_to_fcpxml('./subtitles.srt', './subtitles.fcpxml')
counter += 1
print('fcpxml字幕文件已生成-%s' % counter)