1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 02:32:33 +01:00

[warosu] fix crash for threads with deleted posts (#5289)

This commit is contained in:
Mike Fährmann 2024-03-06 01:27:45 +01:00
parent f296067797
commit 24873c2724
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
2 changed files with 21 additions and 5 deletions

View File

@ -64,8 +64,7 @@ class WarosuThreadExtractor(Extractor):
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"]
@ -91,6 +90,11 @@ class WarosuThreadExtractor(Extractor):
"", "<").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

View File

@ -54,6 +54,18 @@ __tests__ = (
"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"),