[deviantart] export journal templates
This commit is contained in:
@@ -292,7 +292,8 @@ class DeviantartExtractor(Extractor):
|
||||
url = deviation["url"]
|
||||
thumbs = deviation.get("thumbs") or deviation.get("files")
|
||||
html = journal["html"]
|
||||
shadow = SHADOW_TEMPLATE.format_map(thumbs[0]) if thumbs else ""
|
||||
tmpl = self.utils("journal")
|
||||
shadow = tmpl.SHADOW.format_map(thumbs[0]) if thumbs else ""
|
||||
|
||||
if not html:
|
||||
self.log.warning("%s: Empty journal content", deviation["index"])
|
||||
@@ -308,14 +309,14 @@ class DeviantartExtractor(Extractor):
|
||||
|
||||
if html.find('<div class="boxtop journaltop">', 0, 250) != -1:
|
||||
needle = '<div class="boxtop journaltop">'
|
||||
header = HEADER_CUSTOM_TEMPLATE.format(
|
||||
header = tmpl.HEADER_CUSTOM.format(
|
||||
title=title, url=url, date=deviation["date"],
|
||||
)
|
||||
else:
|
||||
needle = '<div usr class="gr">'
|
||||
username = deviation["author"]["username"]
|
||||
urlname = deviation.get("username") or username.lower()
|
||||
header = HEADER_TEMPLATE.format(
|
||||
header = tmpl.HEADER.format(
|
||||
title=title,
|
||||
url=url,
|
||||
userurl=f"{self.root}/{urlname}/",
|
||||
@@ -326,9 +327,9 @@ class DeviantartExtractor(Extractor):
|
||||
if needle in html:
|
||||
html = html.replace(needle, header, 1)
|
||||
else:
|
||||
html = JOURNAL_TEMPLATE_HTML_EXTRA.format(header, html)
|
||||
html = tmpl.HTML_EXTRA.format(header, html)
|
||||
|
||||
html = JOURNAL_TEMPLATE_HTML.format(
|
||||
html = tmpl.HTML.format(
|
||||
title=title, html=html, shadow=shadow, css=css, cls=cls)
|
||||
|
||||
deviation["extension"] = "htm"
|
||||
@@ -345,7 +346,7 @@ class DeviantartExtractor(Extractor):
|
||||
text.unescape(text.remove_html(txt))
|
||||
for txt in (head or tail).split("<br />")
|
||||
)
|
||||
txt = JOURNAL_TEMPLATE_TEXT.format(
|
||||
txt = self.utils("journal").TEXT.format(
|
||||
title=deviation["title"],
|
||||
username=deviation["author"]["username"],
|
||||
date=deviation["date"],
|
||||
@@ -1869,6 +1870,9 @@ def _login_impl(extr, username, password):
|
||||
}
|
||||
|
||||
|
||||
_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz"
|
||||
|
||||
|
||||
def id_from_base36(base36):
|
||||
return util.bdecode(base36, _ALPHABET)
|
||||
|
||||
@@ -1877,121 +1881,6 @@ def base36_from_id(deviation_id):
|
||||
return util.bencode(int(deviation_id), _ALPHABET)
|
||||
|
||||
|
||||
_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz"
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Journal Formats #############################################################
|
||||
|
||||
SHADOW_TEMPLATE = """
|
||||
<span class="shadow">
|
||||
<img src="{src}" class="smshadow" width="{width}" height="{height}">
|
||||
</span>
|
||||
<br><br>
|
||||
"""
|
||||
|
||||
HEADER_TEMPLATE = """<div usr class="gr">
|
||||
<div class="metadata">
|
||||
<h2><a href="{url}">{title}</a></h2>
|
||||
<ul>
|
||||
<li class="author">
|
||||
by <span class="name"><span class="username-with-symbol u">
|
||||
<a class="u regular username" href="{userurl}">{username}</a>\
|
||||
<span class="user-symbol regular"></span></span></span>,
|
||||
<span>{date}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
"""
|
||||
|
||||
HEADER_CUSTOM_TEMPLATE = """<div class='boxtop journaltop'>
|
||||
<h2>
|
||||
<img src="https://st.deviantart.net/minish/gruzecontrol/icons/journal.gif\
|
||||
?2" style="vertical-align:middle" alt=""/>
|
||||
<a href="{url}">{title}</a>
|
||||
</h2>
|
||||
Journal Entry: <span>{date}</span>
|
||||
"""
|
||||
|
||||
JOURNAL_TEMPLATE_HTML = """text:<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>{title}</title>
|
||||
<link rel="stylesheet" href="https://st.deviantart.net\
|
||||
/css/deviantart-network_lc.css?3843780832"/>
|
||||
<link rel="stylesheet" href="https://st.deviantart.net\
|
||||
/css/group_secrets_lc.css?3250492874"/>
|
||||
<link rel="stylesheet" href="https://st.deviantart.net\
|
||||
/css/v6core_lc.css?4246581581"/>
|
||||
<link rel="stylesheet" href="https://st.deviantart.net\
|
||||
/css/sidebar_lc.css?1490570941"/>
|
||||
<link rel="stylesheet" href="https://st.deviantart.net\
|
||||
/css/writer_lc.css?3090682151"/>
|
||||
<link rel="stylesheet" href="https://st.deviantart.net\
|
||||
/css/v6loggedin_lc.css?3001430805"/>
|
||||
<style>{css}</style>
|
||||
<link rel="stylesheet" href="https://st.deviantart.net\
|
||||
/roses/cssmin/core.css?1488405371919"/>
|
||||
<link rel="stylesheet" href="https://st.deviantart.net\
|
||||
/roses/cssmin/peeky.css?1487067424177"/>
|
||||
<link rel="stylesheet" href="https://st.deviantart.net\
|
||||
/roses/cssmin/desktop.css?1491362542749"/>
|
||||
<link rel="stylesheet" href="https://static.parastorage.com/services\
|
||||
/da-deviation/2bfd1ff7a9d6bf10d27b98dd8504c0399c3f9974a015785114b7dc6b\
|
||||
/app.min.css"/>
|
||||
</head>
|
||||
<body id="deviantART-v7" class="bubble no-apps loggedout w960 deviantart">
|
||||
<div id="output">
|
||||
<div class="dev-page-container bubbleview">
|
||||
<div class="dev-page-view view-mode-normal">
|
||||
<div class="dev-view-main-content">
|
||||
<div class="dev-view-deviation">
|
||||
{shadow}
|
||||
<div class="journal-wrapper tt-a">
|
||||
<div class="journal-wrapper2">
|
||||
<div class="journal {cls} journalcontrol">
|
||||
{html}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
|
||||
JOURNAL_TEMPLATE_HTML_EXTRA = """\
|
||||
<div id="devskin0"><div class="negate-box-margin" style="">\
|
||||
<div usr class="gr-box gr-genericbox"
|
||||
><i usr class="gr1"><i></i></i
|
||||
><i usr class="gr2"><i></i></i
|
||||
><i usr class="gr3"><i></i></i
|
||||
><div usr class="gr-top">
|
||||
<i usr class="tri"></i>
|
||||
{}
|
||||
</div>
|
||||
</div><div usr class="gr-body"><div usr class="gr">
|
||||
<div class="grf-indent">
|
||||
<div class="text">
|
||||
{} </div>
|
||||
</div>
|
||||
</div></div>
|
||||
<i usr class="gr3 gb"></i>
|
||||
<i usr class="gr2 gb"></i>
|
||||
<i usr class="gr1 gb gb1"></i> </div>
|
||||
</div></div>"""
|
||||
|
||||
JOURNAL_TEMPLATE_TEXT = """text:{title}
|
||||
by {username}, {date}
|
||||
|
||||
{content}
|
||||
"""
|
||||
|
||||
|
||||
def eclipse_media(media, format="preview"):
|
||||
url = [media["baseUri"]]
|
||||
|
||||
|
||||
116
gallery_dl/extractor/utils/deviantart_journal.py
Normal file
116
gallery_dl/extractor/utils/deviantart_journal.py
Normal file
@@ -0,0 +1,116 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2026 Mike Fährmann
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
|
||||
|
||||
SHADOW = """
|
||||
<span class="shadow">
|
||||
<img src="{src}" class="smshadow" width="{width}" height="{height}">
|
||||
</span>
|
||||
<br><br>
|
||||
"""
|
||||
|
||||
HEADER = """<div usr class="gr">
|
||||
<div class="metadata">
|
||||
<h2><a href="{url}">{title}</a></h2>
|
||||
<ul>
|
||||
<li class="author">
|
||||
by <span class="name"><span class="username-with-symbol u">
|
||||
<a class="u regular username" href="{userurl}">{username}</a>\
|
||||
<span class="user-symbol regular"></span></span></span>,
|
||||
<span>{date}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
"""
|
||||
|
||||
HEADER_CUSTOM = """<div class='boxtop journaltop'>
|
||||
<h2>
|
||||
<img src="https://st.deviantart.net/minish/gruzecontrol/icons/journal.gif\
|
||||
?2" style="vertical-align:middle" alt=""/>
|
||||
<a href="{url}">{title}</a>
|
||||
</h2>
|
||||
Journal Entry: <span>{date}</span>
|
||||
"""
|
||||
|
||||
HTML = """text:<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>{title}</title>
|
||||
<link rel="stylesheet" href="https://st.deviantart.net\
|
||||
/css/deviantart-network_lc.css?3843780832"/>
|
||||
<link rel="stylesheet" href="https://st.deviantart.net\
|
||||
/css/group_secrets_lc.css?3250492874"/>
|
||||
<link rel="stylesheet" href="https://st.deviantart.net\
|
||||
/css/v6core_lc.css?4246581581"/>
|
||||
<link rel="stylesheet" href="https://st.deviantart.net\
|
||||
/css/sidebar_lc.css?1490570941"/>
|
||||
<link rel="stylesheet" href="https://st.deviantart.net\
|
||||
/css/writer_lc.css?3090682151"/>
|
||||
<link rel="stylesheet" href="https://st.deviantart.net\
|
||||
/css/v6loggedin_lc.css?3001430805"/>
|
||||
<style>{css}</style>
|
||||
<link rel="stylesheet" href="https://st.deviantart.net\
|
||||
/roses/cssmin/core.css?1488405371919"/>
|
||||
<link rel="stylesheet" href="https://st.deviantart.net\
|
||||
/roses/cssmin/peeky.css?1487067424177"/>
|
||||
<link rel="stylesheet" href="https://st.deviantart.net\
|
||||
/roses/cssmin/desktop.css?1491362542749"/>
|
||||
<link rel="stylesheet" href="https://static.parastorage.com/services\
|
||||
/da-deviation/2bfd1ff7a9d6bf10d27b98dd8504c0399c3f9974a015785114b7dc6b\
|
||||
/app.min.css"/>
|
||||
</head>
|
||||
<body id="deviantART-v7" class="bubble no-apps loggedout w960 deviantart">
|
||||
<div id="output">
|
||||
<div class="dev-page-container bubbleview">
|
||||
<div class="dev-page-view view-mode-normal">
|
||||
<div class="dev-view-main-content">
|
||||
<div class="dev-view-deviation">
|
||||
{shadow}
|
||||
<div class="journal-wrapper tt-a">
|
||||
<div class="journal-wrapper2">
|
||||
<div class="journal {cls} journalcontrol">
|
||||
{html}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
|
||||
HTML_EXTRA = """\
|
||||
<div id="devskin0"><div class="negate-box-margin" style="">\
|
||||
<div usr class="gr-box gr-genericbox"
|
||||
><i usr class="gr1"><i></i></i
|
||||
><i usr class="gr2"><i></i></i
|
||||
><i usr class="gr3"><i></i></i
|
||||
><div usr class="gr-top">
|
||||
<i usr class="tri"></i>
|
||||
{}
|
||||
</div>
|
||||
</div><div usr class="gr-body"><div usr class="gr">
|
||||
<div class="grf-indent">
|
||||
<div class="text">
|
||||
{} </div>
|
||||
</div>
|
||||
</div></div>
|
||||
<i usr class="gr3 gb"></i>
|
||||
<i usr class="gr2 gb"></i>
|
||||
<i usr class="gr1 gb gb1"></i> </div>
|
||||
</div></div>"""
|
||||
|
||||
TEXT = """text:{title}
|
||||
by {username}, {date}
|
||||
|
||||
{content}
|
||||
"""
|
||||
Reference in New Issue
Block a user