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