[deviantart] fix journal creation if no 'username' is set

This commit is contained in:
Mike Fährmann
2018-08-29 15:59:58 +02:00
parent 6ecb36d88c
commit a493fed376

View File

@@ -141,11 +141,13 @@ class DeviantartExtractor(Extractor):
itertools.accumulate(catlist, lambda t, c: t + "/" + c) itertools.accumulate(catlist, lambda t, c: t + "/" + c)
) )
) )
username = deviation["author"]["username"]
urlname = deviation.get("username") or username.lower()
header = HEADER_TEMPLATE.format( header = HEADER_TEMPLATE.format(
title=title, title=title,
url=url, url=url,
userurl="{}/{}/".format(self.root, deviation["username"]), userurl="{}/{}/".format(self.root, urlname),
username=deviation["author"]["username"], username=username,
date=date, date=date,
categories=categories, categories=categories,
) )
@@ -410,7 +412,7 @@ class DeviantartPopularExtractor(DeviantartExtractor):
pattern = [r"(?:https?://)?www\.deviantart\.com" pattern = [r"(?:https?://)?www\.deviantart\.com"
r"((?:/\w+)*)/(?:popular-([^/?&#]+))/?(?:\?([^#]*))?"] r"((?:/\w+)*)/(?:popular-([^/?&#]+))/?(?:\?([^#]*))?"]
test = [ test = [
("https://www.deviantart.com/popular-8-hours/?q=tree+house", { ("https://www.deviantart.com/popular-24-hours/?q=tree+house", {
"options": (("original", False),), "options": (("original", False),),
}), }),
("https://www.deviantart.com/artisan/popular-all-time/?q=tree", None), ("https://www.deviantart.com/artisan/popular-all-time/?q=tree", None),