get_srt
This commit is contained in:
parent
5103e8f81b
commit
b4c4a2fabb
2 changed files with 12 additions and 6 deletions
|
@ -9,6 +9,8 @@ from django.conf import settings
|
||||||
import item.models
|
import item.models
|
||||||
import itemlist.models
|
import itemlist.models
|
||||||
|
|
||||||
|
from ...render import get_srt
|
||||||
|
|
||||||
|
|
||||||
def resolve_roman(s):
|
def resolve_roman(s):
|
||||||
extra = re.compile('^\d+(.*?)$').findall(s)
|
extra = re.compile('^\d+(.*?)$').findall(s)
|
||||||
|
@ -101,8 +103,7 @@ class Command(BaseCommand):
|
||||||
os.symlink(src, target)
|
os.symlink(src, target)
|
||||||
subs = []
|
subs = []
|
||||||
for sub in vo.annotations.filter(layer="subtitles").exclude(value="").order_by("start"):
|
for sub in vo.annotations.filter(layer="subtitles").exclude(value="").order_by("start"):
|
||||||
sdata = sub.json(keys=['in', 'out', 'value'])
|
sdata = get_srt(sub)
|
||||||
sdata['value'] = sdata['value'].replace('<br/>', '<br>').replace('<br>\n', '\n').replace('<br>', '\n')
|
|
||||||
subs.append(sdata)
|
subs.append(sdata)
|
||||||
voice_over[fragment_id][batch] = {
|
voice_over[fragment_id][batch] = {
|
||||||
"src": target,
|
"src": target,
|
||||||
|
|
13
render.py
13
render.py
|
@ -538,6 +538,14 @@ def render_all(options):
|
||||||
json.dump(_CACHE, fd)
|
json.dump(_CACHE, fd)
|
||||||
|
|
||||||
|
|
||||||
|
def get_srt(sub, offset=0):
|
||||||
|
sdata = sub.json(keys=['in', 'out', 'value'])
|
||||||
|
sdata['value'] = sdata['value'].replace('<br/>', '<br>').replace('<br>\n', '\n').replace('<br>', '\n')
|
||||||
|
if offset:
|
||||||
|
sdata["in"] += offset
|
||||||
|
sdata["out"] += offset
|
||||||
|
return sdata
|
||||||
|
|
||||||
def update_subtitles(options):
|
def update_subtitles(options):
|
||||||
import item.models
|
import item.models
|
||||||
|
|
||||||
|
@ -563,10 +571,7 @@ def update_subtitles(options):
|
||||||
vo = item.models.Item.objects.filter(data__icontains='2-Whispered', data__title__startswith=fragment_id + '_').first()
|
vo = item.models.Item.objects.filter(data__icontains='2-Whispered', data__title__startswith=fragment_id + '_').first()
|
||||||
if vo:
|
if vo:
|
||||||
for sub in vo.annotations.filter(layer="subtitles").exclude(value="").order_by("start"):
|
for sub in vo.annotations.filter(layer="subtitles").exclude(value="").order_by("start"):
|
||||||
sdata = sub.json(keys=['in', 'out', 'value'])
|
sdata = get_srt(sub, offset)
|
||||||
sdata['value'] = sdata['value'].replace('<br/>', '<br>').replace('<br>\n', '\n').replace('<br>', '\n')
|
|
||||||
sdata["in"] += offset
|
|
||||||
sdata["out"] += offset
|
|
||||||
subs.append(sdata)
|
subs.append(sdata)
|
||||||
offset += clip['duration']
|
offset += clip['duration']
|
||||||
path = folder / "front.srt"
|
path = folder / "front.srt"
|
||||||
|
|
Loading…
Reference in a new issue