Check if image is visible
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful

This commit is contained in:
sclement 2023-11-01 21:33:13 +01:00
parent 50034cf7b0
commit 61ef3bfd30
6 changed files with 45 additions and 0 deletions

10
.vscode/launch.json vendored
View File

@ -4,6 +4,16 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"connect": { "host": "docker.cloud.home", "port": 5678 },
"pathMappings": [
{ "localRoot": "${workspaceFolder}", "remoteRoot": "." }
],
"justMyCode": true
},
{
"name": "Python: Current File",
"type": "python",

View File

@ -19,4 +19,5 @@ COPY . /app
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
USER appuser
# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug
CMD ["python", "src/main.py"]

11
docker-compose.debug.yml Normal file
View File

@ -0,0 +1,11 @@
version: '3.4'
services:
pixivcord:
image: pixivcord
build:
context: .
dockerfile: ./Dockerfile
command: ["sh", "-c", "pip install debugpy -t /tmp && python /tmp/debugpy --wait-for-client --listen 0.0.0.0:5678 src/main.py "]
ports:
- 5678:5678

8
docker-compose.yml Normal file
View File

@ -0,0 +1,8 @@
version: '3.4'
services:
pixivcord:
image: pixivcord
build:
context: .
dockerfile: ./Dockerfile

View File

@ -52,6 +52,12 @@ async def pixivprev(interaction: discord.Interaction, url: str):
title = pixiv_api.dowload_pixiv_images(
int(match.group("id")), tmp_dir, REFRESH_TOKEN
)
if title is None:
await interaction.response.send_message(
"Fail to extract pixiv image", ephemeral=True
)
return
files = os.listdir(tmp_dir)
files.sort()
await discord_tools.message.send_command_reply(
@ -76,6 +82,11 @@ async def pixiv_preview(interaction: discord.Interaction, message: discord.Messa
title = pixiv_api.dowload_pixiv_images(
int(match.group("id")), tmp_dir, REFRESH_TOKEN
)
if title is None:
await interaction.response.send_message(
"Fail to extract pixiv image", ephemeral=True
)
return
files = os.listdir(tmp_dir)
files.sort()
await discord_tools.message.send_command_reply(
@ -109,6 +120,8 @@ async def on_message(message: discord.Message):
title = pixiv_api.dowload_pixiv_images(
int(match.group("id")), tmp_dir, REFRESH_TOKEN
)
if title is None:
return
files = os.listdir(tmp_dir)
files.sort()
# await send_message.send_message_with_embed(

View File

@ -11,6 +11,8 @@ def dowload_pixiv_images(
# get origin url
json_result = api.illust_detail(illust_id)
illust = json_result.illust
if not illust["visible"]:
return None
pages = illust["meta_pages"]
if len(pages) > 0:
print(f"Dowloading mutiple images to {dest_folder} ({len(pages)})")