This commit is contained in:
j 2017-05-21 22:48:54 +02:00
parent d4a78ebbd1
commit 14b278fdd1

View file

@ -90,7 +90,15 @@ def render_subtitles(item_json, output_json, output_srt):
'value': [], 'value': [],
'ids': [] 'ids': []
} }
subs[sub_id]['value'].append(sub['value'].replace('<br>', '')) is_korean = 'lang="ko"' in sub['value']
value = sub['value'].replace('<br>', '')
value = value.replace('<span lang="ko">', '').replace('</span>', '').strip()
# just use strip_tags?
# value = ox.strip_tags(ox.decode_html(sub['value']))
if is_korean:
subs[sub_id]['value'].append(value)
else:
subs[sub_id]['value'].insert(0, value)
subs[sub_id]['ids'].append(sub['id']) subs[sub_id]['ids'].append(sub['id'])
position += clip['duration'] position += clip['duration']
subs = sorted(subs.values(), key=lambda c: (c['in'], c['out'])) subs = sorted(subs.values(), key=lambda c: (c['in'], c['out']))
@ -103,6 +111,7 @@ def render_subtitles(item_json, output_json, output_srt):
with open(output_json, 'w') as fd: with open(output_json, 'w') as fd:
json.dump(subtitles, fd, indent=4, ensure_ascii=False) json.dump(subtitles, fd, indent=4, ensure_ascii=False)
if __name__ == '__main__': if __name__ == '__main__':
if os.path.exists('subtitles.json'): if os.path.exists('subtitles.json'):
items = json.load(open('subtitles.json')) items = json.load(open('subtitles.json'))