Skip to content

Commit

Permalink
[sankaku] handle empty tags (fixes #1617)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Jun 14, 2021
1 parent b56e245 commit 9ed1370
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions gallery_dl/extractor/sankaku.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,16 @@ def _file_url(self, post):
def _prepare(post):
post["created_at"] = post["created_at"]["s"]
post["date"] = text.parse_timestamp(post["created_at"])
post["tags"] = [tag["name"] for tag in post["tags"]]
post["tags"] = [tag["name"] for tag in post["tags"] if tag["name"]]
post["tag_string"] = " ".join(post["tags"])

def _extended_tags(self, post):
tags = collections.defaultdict(list)
types = self.TAG_TYPES
for tag in post["tags"]:
tags[types[tag["type"]]].append(tag["name"])
name = tag["name"]
if name:
tags[types[tag["type"]]].append(name)
for key, value in tags.items():
post["tags_" + key] = value
post["tag_string_" + key] = " ".join(value)
Expand Down Expand Up @@ -160,6 +162,15 @@ class SankakuPostExtractor(SankakuExtractor):
"pattern": r"https://s\.sankakucomplex\.com"
r"/data/13/3c/133cda3bfde249c504284493903fb985\.jpg",
}),
# empty tags (#1617)
("https://sankaku.app/post/show/20758561", {
"options": (("tags", True),),
"count": 1,
"keyword": {
"tags": list,
"tags_general": ["key(mangaka)", "key(mangaka)"],
},
}),
("https://beta.sankakucomplex.com/post/show/360451"),
("https://chan.sankakucomplex.com/post/show/360451"),
)
Expand Down

0 comments on commit 9ed1370

Please sign in to comment.