diff --git a/subtitles.py b/subtitles.py
index 513cd6c..f1a23d1 100755
--- a/subtitles.py
+++ b/subtitles.py
@@ -80,7 +80,7 @@ def render_subtitles(item_json, output_json, output_srt):
clip_subtitles.sort(key=lambda c: (c['in'], c['out'], c['id']))
for sub in clip_subtitles:
- sub_in = float('%0.3f'% (sub['in'] + position))
+ sub_in = float('%0.3f' % (sub['in'] + position))
sub_out = float('%0.3f' % (sub['out'] + position))
sub_id = '%0.3f-%0.3f' % (sub_in, sub_out)
if sub_id not in subs:
@@ -90,7 +90,15 @@ def render_subtitles(item_json, output_json, output_srt):
'value': [],
'ids': []
}
- subs[sub_id]['value'].append(sub['value'].replace('
', ''))
+ is_korean = 'lang="ko"' in sub['value']
+ value = sub['value'].replace('
', '')
+ value = value.replace('', '').replace('', '').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'])
position += clip['duration']
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:
json.dump(subtitles, fd, indent=4, ensure_ascii=False)
+
if __name__ == '__main__':
if os.path.exists('subtitles.json'):
items = json.load(open('subtitles.json'))
@@ -112,7 +121,7 @@ if __name__ == '__main__':
json.dump(items, fd, indent=4, ensure_ascii=False)
if len(sys.argv) > 1:
- files = sys.argv[1:]
+ files = sys.argv[1:]
else:
files = glob('output/*/*.json')
for item_json in files: