import/export subtitles

This commit is contained in:
j 2024-03-22 10:56:50 +01:00
commit 80db2f0255
5 changed files with 116 additions and 5 deletions

View file

@ -353,6 +353,7 @@ def render(root, scene, prefix=''):
files.append(path)
return files
def get_fragments(clips, voice_over, prefix):
import itemlist.models
import item.models
@ -590,6 +591,7 @@ def update_subtitles(options):
prefix = Path(options['prefix'])
duration = int(options['duration'])
base = int(options['offset'])
lang = options["lang"]
_cache = os.path.join(prefix, "cache.json")
if os.path.exists(_cache):
@ -609,7 +611,7 @@ def update_subtitles(options):
vo = item.models.Item.objects.filter(data__batch__icontains=batch, data__title__startswith=fragment_id + '_').first()
if vo:
#print("%s => %s %s" % (clip['src'], vo, vo.get('batch')))
for sub in vo.annotations.filter(layer="subtitles").exclude(value="").order_by("start"):
for sub in vo.annotations.filter(layer="subtitles").filter(languages=lang).exclude(value="").order_by("start"):
sdata = get_srt(sub, offset)
subs.append(sdata)
else: