From 6059ffccf8bd2a78423af4810a781a547c29dd17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Fri, 20 Dec 2024 15:37:49 +0100 Subject: [PATCH] [deviantart] improve 'tiptap' to HTML conversion (#6686) - fix "KeyError: 'attrs'" for links without 'href' - support 'strike' text markers - support 'heading' content blocks --- gallery_dl/extractor/deviantart.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/gallery_dl/extractor/deviantart.py b/gallery_dl/extractor/deviantart.py index ea3f13df..69934b45 100644 --- a/gallery_dl/extractor/deviantart.py +++ b/gallery_dl/extractor/deviantart.py @@ -451,6 +451,26 @@ class DeviantartExtractor(Extractor): elif type == "text": self._tiptap_process_text(html, content) + elif type == "heading": + attrs = content["attrs"] + level = str(attrs.get("level") or "3") + + html.append("') + html.append('') + + children = content.get("content") + if children: + for block in children: + self._tiptap_process_content(html, block) + + html.append("") + elif type == "hardBreak": html.append("

") @@ -478,8 +498,9 @@ class DeviantartExtractor(Extractor): for mark in marks: type = mark["type"] if type == "link": + attrs = mark.get("attrs") or {} html.append('') close.append("") elif type == "bold": @@ -491,6 +512,9 @@ class DeviantartExtractor(Extractor): elif type == "underline": html.append("") close.append("") + elif type == "strike": + html.append("") + close.append("") elif type == "textStyle" and len(mark) <= 1: pass else: