korean
This commit is contained in:
parent
d4a78ebbd1
commit
14b278fdd1
1 changed files with 12 additions and 3 deletions
11
subtitles.py
11
subtitles.py
|
@ -90,7 +90,15 @@ def render_subtitles(item_json, output_json, output_srt):
|
|||
'value': [],
|
||||
'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'])
|
||||
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'))
|
||||
|
|
Loading…
Reference in a new issue