Fix single image download
This commit is contained in:
parent
e78d40f0b8
commit
7f8949271f
10
main.py
10
main.py
@ -40,7 +40,7 @@ async def on_message(message: discord.Message):
|
||||
) is not None:
|
||||
with TemporaryDirectory() as tmp_dir:
|
||||
async with message.channel.typing():
|
||||
pixiv.dowload_pixiv_images(
|
||||
title = pixiv.dowload_pixiv_images(
|
||||
int(match.group("id")), tmp_dir, REFRESH_TOKEN
|
||||
)
|
||||
files = os.listdir(tmp_dir)
|
||||
@ -62,7 +62,7 @@ async def on_message(message: discord.Message):
|
||||
splited_embed = to_send_embed[:4]
|
||||
to_send_embed = to_send_embed[4:]
|
||||
for embed in splited_embed:
|
||||
embed.title = f"Part {i}/{parts}"
|
||||
embed.title = f"{title} - Part {i}/{parts}"
|
||||
if i == 1:
|
||||
await message.reply(
|
||||
files=splited_file, embeds=splited_embed
|
||||
@ -74,10 +74,14 @@ async def on_message(message: discord.Message):
|
||||
|
||||
i = i + 1
|
||||
for embed in to_send_embed:
|
||||
embed.title = f"Part {i}/{parts}"
|
||||
embed.title = f"{title} - Part {i}/{parts}"
|
||||
await message.channel.send(
|
||||
files=to_send_files, embeds=to_send_embed
|
||||
)
|
||||
else:
|
||||
for embed in to_send_embed:
|
||||
embed.title = title
|
||||
await message.reply(files=to_send_files, embeds=to_send_embed)
|
||||
|
||||
|
||||
client.run(DISCORD_TOKEN)
|
||||
|
19
pixiv.py
19
pixiv.py
@ -12,9 +12,16 @@ def dowload_pixiv_images(
|
||||
json_result = api.illust_detail(illust_id)
|
||||
illust = json_result.illust
|
||||
pages = illust["meta_pages"]
|
||||
print(f"Dowloading image to {dest_folder}")
|
||||
for page in pages:
|
||||
url = page["image_urls"]["original"]
|
||||
print(url)
|
||||
api.download(url=url, path=dest_folder)
|
||||
print("Dowload finished !")
|
||||
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"]
|
||||
|
Loading…
Reference in New Issue
Block a user