Skip to content

Commit

Permalink
[deviantart] provide 'date' metadata (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Apr 29, 2019
1 parent 5018781 commit 9544683
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions gallery_dl/extractor/deviantart.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from ..cache import cache, memcache
import itertools
import mimetypes
import datetime
import time
import math
import re
Expand Down Expand Up @@ -107,6 +106,8 @@ def prepare(self, deviation):
deviation["da_category"] = deviation["category"]
deviation["published_time"] = text.parse_int(
deviation["published_time"])
deviation["date"] = text.parse_timestamp(
deviation["published_time"])

@staticmethod
def commit(deviation, target):
Expand All @@ -120,7 +121,6 @@ def _commit_journal_html(self, deviation, journal):
url = deviation["url"]
thumbs = deviation["thumbs"]
html = journal["html"]
date = datetime.datetime.utcfromtimestamp(deviation["published_time"])
shadow = SHADOW_TEMPLATE.format_map(thumbs[0]) if thumbs else ""

if "css" in journal:
Expand All @@ -131,7 +131,7 @@ def _commit_journal_html(self, deviation, journal):
if html.find('<div class="boxtop journaltop">', 0, 250) != -1:
needle = '<div class="boxtop journaltop">'
header = HEADER_CUSTOM_TEMPLATE.format(
title=title, url=url, date=str(date),
title=title, url=url, date=deviation["date"],
)
else:
needle = '<div usr class="gr">'
Expand All @@ -151,7 +151,7 @@ def _commit_journal_html(self, deviation, journal):
url=url,
userurl="{}/{}/".format(self.root, urlname),
username=username,
date=date,
date=deviation["date"],
categories=categories,
)

Expand All @@ -168,15 +168,14 @@ def _commit_journal_html(self, deviation, journal):

@staticmethod
def _commit_journal_text(deviation, journal):
date = datetime.datetime.utcfromtimestamp(deviation["published_time"])
content = "\n".join(
text.unescape(text.remove_html(txt))
for txt in journal["html"].rpartition("<script")[0].split("<br />")
)
txt = JOURNAL_TEMPLATE_TEXT.format(
title=deviation["title"],
username=deviation["author"]["username"],
date=date,
date=deviation["date"],
content=content,
)

Expand Down Expand Up @@ -232,6 +231,7 @@ class DeviantartGalleryExtractor(DeviantartExtractor):
"width": int,
},
"da_category": str,
"date": "type:datetime",
"deviationid": str,
"?download_filesize": int,
"extension": str,
Expand Down

0 comments on commit 9544683

Please sign in to comment.