This commit is contained in:
j 2023-11-16 09:12:53 +01:00
parent 5103e8f81b
commit b4c4a2fabb
2 changed files with 12 additions and 6 deletions

View file

@ -9,6 +9,8 @@ from django.conf import settings
import item.models
import itemlist.models
from ...render import get_srt
def resolve_roman(s):
extra = re.compile('^\d+(.*?)$').findall(s)
@ -101,8 +103,7 @@ class Command(BaseCommand):
os.symlink(src, target)
subs = []
for sub in vo.annotations.filter(layer="subtitles").exclude(value="").order_by("start"):
sdata = sub.json(keys=['in', 'out', 'value'])
sdata['value'] = sdata['value'].replace('<br/>', '<br>').replace('<br>\n', '\n').replace('<br>', '\n')
sdata = get_srt(sub)
subs.append(sdata)
voice_over[fragment_id][batch] = {
"src": target,

View file

@ -538,6 +538,14 @@ def render_all(options):
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):
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()
if vo:
for sub in vo.annotations.filter(layer="subtitles").exclude(value="").order_by("start"):
sdata = sub.json(keys=['in', 'out', 'value'])
sdata['value'] = sdata['value'].replace('<br/>', '<br>').replace('<br>\n', '\n').replace('<br>', '\n')
sdata["in"] += offset
sdata["out"] += offset
sdata = get_srt(sub, offset)
subs.append(sdata)
offset += clip['duration']
path = folder / "front.srt"