dont wrap in lang="None"

This commit is contained in:
j 2024-07-08 15:35:02 +01:00
parent 1788f4bac6
commit d43642c070

View file

@ -22,7 +22,6 @@ logger = logging.getLogger(__name__)
def extract_subtitles(item, user, layer, translate, gpu=False): def extract_subtitles(item, user, layer, translate, gpu=False):
if "language" not in item.data: if "language" not in item.data:
logger.error("skip item without language %s", item.public_id)
language = None language = None
else: else:
language = ox.iso.langTo2Code(item.data["language"][0]) language = ox.iso.langTo2Code(item.data["language"][0])
@ -69,7 +68,7 @@ def extract_subtitles(item, user, layer, translate, gpu=False):
if not annotations: if not annotations:
logger.error("no subtitles detected %s", item.public_id) logger.error("no subtitles detected %s", item.public_id)
return True return True
if language != "en": if language and language != "en":
for annotation in annotations: for annotation in annotations:
annotation["value"] = '<span lang="%s">%s</span>' % (language, annotation["value"]) annotation["value"] = '<span lang="%s">%s</span>' % (language, annotation["value"])