Add artist name
This commit is contained in:
parent
36591fda85
commit
1fd60f9207
@ -48,6 +48,7 @@ async def send_command_reply(
|
||||
tmp_dir: str,
|
||||
muted: bool,
|
||||
title: str,
|
||||
art_author: str,
|
||||
url: str,
|
||||
author: discord.User | discord.Member,
|
||||
):
|
||||
@ -77,7 +78,7 @@ async def send_command_reply(
|
||||
elif first:
|
||||
await interaction.followup.send(
|
||||
files=splited_file,
|
||||
content=f"{title} - Submited by {author.mention} - <{url}> {chr(10) + TIPS_MESSAGE if not muted else ''}",
|
||||
content=f"{title} by {art_author} - <{url}> - Submited by {author.mention} {chr(10) + TIPS_MESSAGE if not muted else ''}",
|
||||
)
|
||||
first = False
|
||||
else:
|
||||
|
17
src/main.py
17
src/main.py
@ -55,15 +55,15 @@ async def pixivprev(interaction: discord.Interaction, url: str):
|
||||
if result and match is not None:
|
||||
await interaction.response.defer()
|
||||
with TemporaryDirectory() as tmp_dir:
|
||||
title = pixiv_api.dowload_pixiv_images(
|
||||
data = pixiv_api.dowload_pixiv_images(
|
||||
int(match.group("id")), tmp_dir, REFRESH_TOKEN
|
||||
)
|
||||
if title is None:
|
||||
if data is None:
|
||||
await interaction.response.send_message(
|
||||
"Fail to extract pixiv image", ephemeral=True
|
||||
)
|
||||
return
|
||||
|
||||
(title, author) = data
|
||||
files = os.listdir(tmp_dir)
|
||||
files.sort()
|
||||
await discord_tools.message.send_command_reply(
|
||||
@ -72,6 +72,7 @@ async def pixivprev(interaction: discord.Interaction, url: str):
|
||||
tmp_dir,
|
||||
True,
|
||||
title=title,
|
||||
art_author=author,
|
||||
url=url,
|
||||
author=interaction.user,
|
||||
)
|
||||
@ -85,22 +86,24 @@ async def pixiv_preview(interaction: discord.Interaction, message: discord.Messa
|
||||
if result and match is not None:
|
||||
await interaction.response.defer()
|
||||
with TemporaryDirectory() as tmp_dir:
|
||||
title = pixiv_api.dowload_pixiv_images(
|
||||
data = pixiv_api.dowload_pixiv_images(
|
||||
int(match.group("id")), tmp_dir, REFRESH_TOKEN
|
||||
)
|
||||
if title is None:
|
||||
if data is None:
|
||||
await interaction.response.send_message(
|
||||
"Fail to extract pixiv image", ephemeral=True
|
||||
)
|
||||
return
|
||||
files = os.listdir(tmp_dir)
|
||||
files.sort()
|
||||
(title, author) = data
|
||||
await discord_tools.message.send_command_reply(
|
||||
interaction=interaction,
|
||||
files=files,
|
||||
tmp_dir=tmp_dir,
|
||||
muted=muted,
|
||||
title=title,
|
||||
art_author=author,
|
||||
url=match.group("url"),
|
||||
author=interaction.user,
|
||||
)
|
||||
@ -123,10 +126,10 @@ async def on_message(message: discord.Message):
|
||||
if result and match is not None:
|
||||
with TemporaryDirectory() as tmp_dir:
|
||||
async with message.channel.typing():
|
||||
title = pixiv_api.dowload_pixiv_images(
|
||||
data = pixiv_api.dowload_pixiv_images(
|
||||
int(match.group("id")), tmp_dir, REFRESH_TOKEN
|
||||
)
|
||||
if title is None:
|
||||
if data is None:
|
||||
return
|
||||
files = os.listdir(tmp_dir)
|
||||
files.sort()
|
||||
|
@ -59,7 +59,7 @@ def dowload_pixiv_images(
|
||||
url=illust["meta_single_page"]["original_image_url"], path=dest_folder
|
||||
)
|
||||
logging.info("Download finished !")
|
||||
return illust["title"]
|
||||
return (illust["title"], f"{illust['user']['name']}({illust['user']['account']})")
|
||||
|
||||
|
||||
def download_thread(q: Queue[Union[Tuple[str, str, pixivpy3.AppPixivAPI], None]]):
|
||||
|
Loading…
Reference in New Issue
Block a user