From 63b6119a44afe2be9563acffd72aa974bb9d7f17 Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Mon, 6 Jan 2025 01:56:28 -0500 Subject: New upstream version 1.28.3. --- gallery_dl/extractor/deviantart.py | 107 +++++++++++++++++++++++++++++++------ 1 file changed, 91 insertions(+), 16 deletions(-) (limited to 'gallery_dl/extractor/deviantart.py') diff --git a/gallery_dl/extractor/deviantart.py b/gallery_dl/extractor/deviantart.py index 69934b4..8172f62 100644 --- a/gallery_dl/extractor/deviantart.py +++ b/gallery_dl/extractor/deviantart.py @@ -440,7 +440,8 @@ class DeviantartExtractor(Extractor): html.append("text-align:") html.append(attrs["textAlign"]) html.append(";") - html.append('margin-inline-start:0px">') + self._tiptap_process_indentation(html, attrs) + html.append('">') for block in children: self._tiptap_process_content(html, block) @@ -460,17 +461,32 @@ class DeviantartExtractor(Extractor): html.append(' style="text-align:') html.append(attrs.get("textAlign") or "left") html.append('">') - html.append('') - - children = content.get("content") - if children: - for block in children: - self._tiptap_process_content(html, block) - + html.append('') + self._tiptap_process_children(html, content) html.append("") + elif type in ("listItem", "bulletList", "orderedList", "blockquote"): + c = type[1] + tag = ( + "li" if c == "i" else + "ul" if c == "u" else + "ol" if c == "r" else + "blockquote" + ) + html.append("<" + tag + ">") + self._tiptap_process_children(html, content) + html.append("") + + elif type == "anchor": + attrs = content["attrs"] + html.append('') + elif type == "hardBreak": html.append("

") @@ -488,6 +504,44 @@ class DeviantartExtractor(Extractor): html.append(user) html.append('') + elif type == "da-gif": + attrs = content["attrs"] + width = str(attrs.get("width") or "") + height = str(attrs.get("height") or "") + url = text.escape(attrs.get("url") or "") + + html.append('
') + + elif type == "da-video": + src = text.escape(content["attrs"].get("src") or "") + html.append('
' + '
') + else: self.log.warning("Unsupported content type '%s'", type) @@ -501,7 +555,13 @@ class DeviantartExtractor(Extractor): attrs = mark.get("attrs") or {} html.append('') + if "target" in attrs: + html.append('" target="') + html.append(attrs["target"]) + html.append('" rel="') + html.append(attrs.get("rel") or + "noopener noreferrer nofollow ugc") + html.append('">') close.append("") elif type == "bold": html.append("") @@ -525,6 +585,18 @@ class DeviantartExtractor(Extractor): else: html.append(text.escape(content["text"])) + def _tiptap_process_children(self, html, content): + children = content.get("content") + if children: + for block in children: + self._tiptap_process_content(html, block) + + def _tiptap_process_indentation(self, html, attrs): + itype = ("text-indent" if attrs.get("indentType") == "line" else + "margin-inline-start") + isize = str((attrs.get("indentation") or 0) * 24) + html.append(itype + ":" + isize + "px") + def _tiptap_process_deviation(self, html, content): dev = content["attrs"]["deviation"] media = dev.get("media") or () @@ -758,19 +830,22 @@ x2="45.4107524%" y2="71.4898596%" id="app-root-3">\ self.api.user_friends_unwatch(username) def _eclipse_media(self, media, format="preview"): - url = [media["baseUri"], ] + url = [media["baseUri"]] formats = { fmt["t"]: fmt for fmt in media["types"] } - tokens = media["token"] - if len(tokens) == 1: - fmt = formats[format] - url.append(fmt["c"].replace("", media["prettyName"])) - url.append("?token=") - url.append(tokens[-1]) + tokens = media.get("token") or () + if tokens: + if len(tokens) <= 1: + fmt = formats[format] + if "c" in fmt: + url.append(fmt["c"].replace( + "", media["prettyName"])) + url.append("?token=") + url.append(tokens[-1]) return "".join(url), formats -- cgit v1.2.3