From ea322a054ec9fac381abc837a5afa13cc68bf425 Mon Sep 17 00:00:00 2001 From: j Date: Mon, 12 Jan 2026 22:30:32 +0000 Subject: [PATCH] add support for data annotations --- pandora/annotation/models.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pandora/annotation/models.py b/pandora/annotation/models.py index 452df4e0..2df6a09d 100644 --- a/pandora/annotation/models.py +++ b/pandora/annotation/models.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- +import json import re import unicodedata @@ -138,7 +139,13 @@ class Annotation(models.Model): set_public_id = not self.id or not self.public_id layer = self.get_layer() if self.value: - self.value = utils.cleanup_value(self.value, layer['type']) + 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']) findvalue = self.value try: @@ -393,7 +400,11 @@ class Annotation(models.Model): # them specially. See Item.add_empty_clips if l.get('isSubtitles') and 'id' in j and not self.value: del j['id'] - + if l['type'] == "data" and "value" in j: + try: + j["value"] = json.loads(j["value"]) + except: + pass return j def __str__(self):