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