add support for data annotations

This commit is contained in:
j 2026-01-12 22:30:32 +00:00
commit ea322a054e

View file

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import json
import re import re
import unicodedata import unicodedata
@ -138,6 +139,12 @@ class Annotation(models.Model):
set_public_id = not self.id or not self.public_id set_public_id = not self.id or not self.public_id
layer = self.get_layer() layer = self.get_layer()
if self.value: if self.value:
if layer['type'] == "data" and not isinstance(self.value, str):
try:
self.value = json.dumps(self.value, ensure_ascii=False)
except:
pass
else:
self.value = utils.cleanup_value(self.value, layer['type']) self.value = utils.cleanup_value(self.value, layer['type'])
findvalue = self.value findvalue = self.value
@ -393,7 +400,11 @@ class Annotation(models.Model):
# them specially. See Item.add_empty_clips # them specially. See Item.add_empty_clips
if l.get('isSubtitles') and 'id' in j and not self.value: if l.get('isSubtitles') and 'id' in j and not self.value:
del j['id'] del j['id']
if l['type'] == "data" and "value" in j:
try:
j["value"] = json.loads(j["value"])
except:
pass
return j return j
def __str__(self): def __str__(self):