From 3b56274713ec57eb5545b677dcbe5fcecb1620de Mon Sep 17 00:00:00 2001 From: j Date: Fri, 17 May 2024 12:08:20 +0200 Subject: [PATCH] import subtitles with language --- pandora/annotation/management/commands/import_srt.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pandora/annotation/management/commands/import_srt.py b/pandora/annotation/management/commands/import_srt.py index 881aa186e..ef309f815 100644 --- a/pandora/annotation/management/commands/import_srt.py +++ b/pandora/annotation/management/commands/import_srt.py @@ -27,6 +27,7 @@ class Command(BaseCommand): parser.add_argument('username', help='username') parser.add_argument('item', help='item') parser.add_argument('layer', help='layer') + parser.add_argument('language', help='language', default="") parser.add_argument('filename', help='filename.srt') def handle(self, *args, **options): @@ -34,6 +35,7 @@ class Command(BaseCommand): public_id = options['item'] layer_id = options['layer'] filename = options['filename'] + language = options.get("language") user = User.objects.get(username=username) item = Item.objects.get(public_id=public_id) @@ -47,6 +49,9 @@ class Command(BaseCommand): for i in range(len(annotations)-1): if annotations[i]['out'] == annotations[i+1]['in']: annotations[i]['out'] = annotations[i]['out'] - 0.001 + if language: + for annotation in annotations: + annotation["value"] = '%s' % (language, annotation["value"]) tasks.add_annotations.delay({ 'item': item.public_id, 'layer': layer_id,