Skip to content

Commit 4b6365f

Browse files
committed
fix: return error on sanity level limit
Sometimes even SFW artworks will return sanity level limited error, e.g. 110355001 this is likely a bug on Pixiv side, we should not save the returned error image.
1 parent b764680 commit 4b6365f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

nazurin/sites/pixiv/api.py

+9
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
)
3333
from .models import PixivIllust, PixivImage
3434

35+
SANITY_LEVEL_LIMITED = "https://s.pximg.net/common/images/limit_sanity_level_360.png"
36+
3537

3638
class Pixiv:
3739
api = AppPixivAPI()
@@ -261,6 +263,13 @@ def get_images(self, illust) -> List[PixivImage]:
261263
width = height = 0
262264
else:
263265
url = illust.meta_single_page.original_image_url
266+
if url == SANITY_LEVEL_LIMITED:
267+
logger.warning(
268+
"Artwork {} is not available due to sanity level limit: {}",
269+
illust.id,
270+
illust,
271+
)
272+
raise NazurinError("Artwork not available due to sanity level limit.")
264273
destination, filename = self.get_storage_dest(url, illust)
265274
imgs.append(
266275
PixivImage(

0 commit comments

Comments
 (0)