Skip to content

Commit

Permalink
Fix various issues caused by the previous unlisted post PR (#1376)
Browse files Browse the repository at this point in the history
* ADD: Download from unlisted post by ID

* FIX: referer is used before initiating

* fixes #1375 attempt to download images with string ID as unlisted even if it is not
  • Loading branch information
OozoraHaruto authored Sep 28, 2024
1 parent 512687b commit 625d119
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
5 changes: 3 additions & 2 deletions PixivBrowserFactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,11 +642,12 @@ def getImagePage(self,
bookmark_count=-1,
image_response_count=-1,
manga_series_order=-1,
manga_series_parent=None) -> Tuple[PixivImage, str]:
manga_series_parent=None,
is_unlisted=False) -> Tuple[PixivImage, str]:
image = None
response = None
PixivHelper.get_logger().debug("Getting image page: %s", image_id)
if isinstance(image_id, int):
if not is_unlisted:
# https://www.pixiv.net/en/artworks/76656661
url = f"https://www.pixiv.net{self._locale}/artworks/{image_id}"
else:
Expand Down
10 changes: 6 additions & 4 deletions PixivImageHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def process_image(caller,
reencoding=False,
manga_series_order=-1,
manga_series_parent=None,
ui_prefix="") -> int:
ui_prefix="",
is_unlisted=False) -> int:
# caller function/method
# TODO: ideally to be removed or passed as argument
db: PixivDBManager = caller.__dbManager__
Expand All @@ -54,9 +55,9 @@ def process_image(caller,
parse_medium_page = None
image = None
result = None
if isinstance(image_id, int):
if not is_unlisted:
# https://www.pixiv.net/en/artworks/76656661
url = f"https://www.pixiv.net/artworks/{image_id}"
referer = f"https://www.pixiv.net/artworks/{image_id}"
else:
# https://www.pixiv.net/artworks/unlisted/SbliQHtJS5MMu3elqDFZ
referer = f"https://www.pixiv.net/artworks/unlisted/{image_id}"
Expand Down Expand Up @@ -88,7 +89,8 @@ def process_image(caller,
from_bookmark=bookmark,
bookmark_count=bookmark_count,
manga_series_order=manga_series_order,
manga_series_parent=manga_series_parent)
manga_series_parent=manga_series_parent,
is_unlisted=is_unlisted)
if len(title_prefix) > 0:
caller.set_console_title(f"{title_prefix} ImageId: {image.imageId}")
else:
Expand Down
6 changes: 4 additions & 2 deletions PixivUtil2.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,8 @@ def menu_download_by_unlisted_image_id(opisvalid, args, options):
__config__,
artist=None,
image_id=image_id,
useblacklist=False)
useblacklist=False,
is_unlisted=True)
except BaseException:
PixivHelper.print_and_log('error', f"Image ID: {image_id} is not valid")
global ERROR_CODE
Expand All @@ -761,7 +762,8 @@ def menu_download_by_unlisted_image_id(opisvalid, args, options):
__config__,
artist=None,
image_id=image_id,
useblacklist=False)
useblacklist=False,
is_unlisted=True)


def menu_ugoira_reencode(opisvalid, args, options):
Expand Down

0 comments on commit 625d119

Please sign in to comment.