Skip to content

Commit

Permalink
fix: return error on sanity level limit
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
y-young committed Aug 5, 2023
1 parent b764680 commit 4b6365f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions nazurin/sites/pixiv/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
)
from .models import PixivIllust, PixivImage

SANITY_LEVEL_LIMITED = "https://s.pximg.net/common/images/limit_sanity_level_360.png"


class Pixiv:
api = AppPixivAPI()
Expand Down Expand Up @@ -261,6 +263,13 @@ def get_images(self, illust) -> List[PixivImage]:
width = height = 0
else:
url = illust.meta_single_page.original_image_url
if url == SANITY_LEVEL_LIMITED:
logger.warning(
"Artwork {} is not available due to sanity level limit: {}",
illust.id,
illust,
)
raise NazurinError("Artwork not available due to sanity level limit.")
destination, filename = self.get_storage_dest(url, illust)
imgs.append(
PixivImage(
Expand Down

0 comments on commit 4b6365f

Please sign in to comment.