Skip to content

Commit

Permalink
[deviantart] fix "KeyError - 'category'" (#5960, #5961)
Browse files Browse the repository at this point in the history
'deviation' objects returned by the OAuth API no longer include a
'category' or 'category_path' value.
  • Loading branch information
mikf committed Aug 8, 2024
1 parent c07a074 commit 269b280
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions gallery_dl/extractor/deviantart.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from .. import text, util, exception
from ..cache import cache, memcache
import collections
import itertools
import mimetypes
import binascii
import time
Expand Down Expand Up @@ -246,7 +245,6 @@ def prepare(self, deviation):
deviation["username"] = deviation["author"]["username"]
deviation["_username"] = deviation["username"].lower()

deviation["da_category"] = deviation["category"]
deviation["published_time"] = text.parse_int(
deviation["published_time"])
deviation["date"] = text.parse_timestamp(
Expand Down Expand Up @@ -301,15 +299,6 @@ def _commit_journal_html(self, deviation, journal):
)
else:
needle = '<div usr class="gr">'
catlist = deviation["category_path"].split("/")
categories = " / ".join(
('<span class="crumb"><a href="{}/{}/"><span>{}</span></a>'
'</span>').format(self.root, cpath, cat.capitalize())
for cat, cpath in zip(
catlist,
itertools.accumulate(catlist, lambda t, c: t + "/" + c)
)
)
username = deviation["author"]["username"]
urlname = deviation.get("username") or username.lower()
header = HEADER_TEMPLATE.format(
Expand All @@ -318,7 +307,6 @@ def _commit_journal_html(self, deviation, journal):
userurl="{}/{}/".format(self.root, urlname),
username=username,
date=deviation["date"],
categories=categories,
)

if needle in html:
Expand Down Expand Up @@ -624,7 +612,7 @@ def deviations(self):
def _make_deviation(self, url, user, index, fmt):
return {
"author" : user,
"category" : "avatar",
"da_category" : "avatar",
"index" : text.parse_int(index),
"is_deleted" : False,
"is_downloadable": False,
Expand Down Expand Up @@ -1773,9 +1761,6 @@ def base36_from_id(deviation_id):
<span class="user-symbol regular"></span></span></span>,
<span>{date}</span>
</li>
<li class="category">
{categories}
</li>
</ul>
</div>
"""
Expand Down

0 comments on commit 269b280

Please sign in to comment.