pixivcord/pixiv.py
sclement 7f8949271f
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
Fix single image download
2023-10-30 15:35:26 +01:00

28 lines
801 B
Python

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"]
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"]