2023-10-30 14:58:04 +01:00
|
|
|
import pixivpy3
|
|
|
|
|
|
|
|
|
|
|
|
def dowload_pixiv_images(
|
|
|
|
illust_id: int,
|
|
|
|
dest_folder: str,
|
|
|
|
refresh_token: str,
|
|
|
|
):
|
|
|
|
api = pixivpy3.AppPixivAPI()
|
|
|
|
api.auth(refresh_token=refresh_token)
|
|
|
|
# get origin url
|
|
|
|
json_result = api.illust_detail(illust_id)
|
|
|
|
illust = json_result.illust
|
|
|
|
pages = illust["meta_pages"]
|
2023-10-30 15:35:26 +01:00
|
|
|
if len(pages) > 0:
|
|
|
|
print(f"Dowloading mutiple images to {dest_folder}")
|
|
|
|
for page in pages:
|
|
|
|
url = page["image_urls"]["original"]
|
|
|
|
print(url)
|
|
|
|
api.download(url=url, path=dest_folder)
|
|
|
|
else:
|
|
|
|
print(f"Dowloading single image to {dest_folder}")
|
|
|
|
api.download(
|
|
|
|
url=illust["meta_single_page"]["original_image_url"], path=dest_folder
|
|
|
|
)
|
|
|
|
print("Down4load finished !")
|
|
|
|
return illust["title"]
|