[paheal] normalize "No results" output message (#8313)
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
"""Extractors for https://rule34.paheal.net/"""
|
"""Extractors for https://rule34.paheal.net/"""
|
||||||
|
|
||||||
from .common import Extractor, Message
|
from .common import Extractor, Message
|
||||||
from .. import text
|
from .. import text, exception
|
||||||
|
|
||||||
|
|
||||||
class PahealExtractor(Extractor):
|
class PahealExtractor(Extractor):
|
||||||
@@ -97,7 +97,12 @@ class PahealTagExtractor(PahealExtractor):
|
|||||||
base = f"{self.root}/post/list/{self.groups[0]}/"
|
base = f"{self.root}/post/list/{self.groups[0]}/"
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
page = self.request(base + str(pnum)).text
|
try:
|
||||||
|
page = self.request(f"{base}{pnum}").text
|
||||||
|
except exception.HttpError as exc:
|
||||||
|
if exc.status == 404:
|
||||||
|
return
|
||||||
|
raise
|
||||||
|
|
||||||
pos = page.find("id='image-list'")
|
pos = page.find("id='image-list'")
|
||||||
for post in text.extract_iter(
|
for post in text.extract_iter(
|
||||||
@@ -146,4 +151,9 @@ class PahealPostExtractor(PahealExtractor):
|
|||||||
example = "https://rule34.paheal.net/post/view/12345"
|
example = "https://rule34.paheal.net/post/view/12345"
|
||||||
|
|
||||||
def get_posts(self):
|
def get_posts(self):
|
||||||
return (self._extract_post(self.groups[0]),)
|
try:
|
||||||
|
return (self._extract_post(self.groups[0]),)
|
||||||
|
except exception.HttpError as exc:
|
||||||
|
if exc.status == 404:
|
||||||
|
return ()
|
||||||
|
raise
|
||||||
|
|||||||
@@ -60,6 +60,13 @@ __tests__ = (
|
|||||||
"#count" : 200,
|
"#count" : 200,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"#url" : "https://rule34.paheal.net/post/list/non_existant_tag/1",
|
||||||
|
"#category": ("shimmie2", "paheal", "tag"),
|
||||||
|
"#class" : paheal.PahealTagExtractor,
|
||||||
|
"#count" : 0,
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"#url" : "https://rule34.paheal.net/post/view/481609",
|
"#url" : "https://rule34.paheal.net/post/view/481609",
|
||||||
"#category": ("shimmie2", "paheal", "post"),
|
"#category": ("shimmie2", "paheal", "post"),
|
||||||
@@ -116,4 +123,11 @@ __tests__ = (
|
|||||||
"width" : 1768,
|
"width" : 1768,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"#url" : "https://rule34.paheal.net/post/view/7",
|
||||||
|
"#category": ("shimmie2", "paheal", "post"),
|
||||||
|
"#class" : paheal.PahealPostExtractor,
|
||||||
|
"#count" : 0,
|
||||||
|
},
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user