Skip to content

Commit

Permalink
[warosu] fix crash for threads with deleted posts (#5289)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Mar 6, 2024
1 parent f296067 commit 24873c2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
14 changes: 9 additions & 5 deletions gallery_dl/extractor/warosu.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ def posts(self, page):
def parse(self, post):
"""Build post object by extracting data from an HTML post"""
data = self._extract_post(post)
if "<span> File:" in post:
self._extract_image(post, data)
if "<span> File:" in post and self._extract_image(post, data):
part = data["image"].rpartition("/")[2]
data["tim"], _, data["extension"] = part.partition(".")
data["ext"] = "." + data["extension"]
Expand All @@ -91,6 +90,11 @@ def _extract_image(self, post, data):
"", "<").rstrip().rpartition(".")[0])
extr("<br>", "")

data["image"] = url = extr("<a href=", ">")
if url[0] == "/":
data["image"] = self.root + url
url = extr("<a href=", ">")
if url:
if url[0] == "/":
data["image"] = self.root + url
else:
data["image"] = url
return True
return False
12 changes: 12 additions & 0 deletions test/results/warosu.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@
"w" : 450,
},

{
"#url" : "https://warosu.org/jp/thread/45886210",
"#comment" : "deleted post (#5289)",
"#category": ("", "warosu", "thread"),
"#class" : warosu.WarosuThreadExtractor,
"#count" : "> 150",

"board" : "jp",
"board_name": "Otaku Culture",
"title" : "/07/th Expansion Thread",
},

{
"#url" : "https://warosu.org/ic/thread/4604652",
"#category": ("", "warosu", "thread"),
Expand Down

0 comments on commit 24873c2

Please sign in to comment.