Check if image is visible
This commit is contained in:
parent
50034cf7b0
commit
61ef3bfd30
10
.vscode/launch.json
vendored
10
.vscode/launch.json
vendored
@ -4,6 +4,16 @@
|
|||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"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",
|
"name": "Python: Current File",
|
||||||
"type": "python",
|
"type": "python",
|
||||||
|
@ -19,4 +19,5 @@ COPY . /app
|
|||||||
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
|
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
|
||||||
USER appuser
|
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"]
|
CMD ["python", "src/main.py"]
|
||||||
|
11
docker-compose.debug.yml
Normal file
11
docker-compose.debug.yml
Normal 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
8
docker-compose.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
version: '3.4'
|
||||||
|
|
||||||
|
services:
|
||||||
|
pixivcord:
|
||||||
|
image: pixivcord
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: ./Dockerfile
|
13
src/main.py
13
src/main.py
@ -52,6 +52,12 @@ async def pixivprev(interaction: discord.Interaction, url: str):
|
|||||||
title = pixiv_api.dowload_pixiv_images(
|
title = 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:
|
||||||
|
await interaction.response.send_message(
|
||||||
|
"Fail to extract pixiv image", ephemeral=True
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
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(
|
||||||
@ -76,6 +82,11 @@ async def pixiv_preview(interaction: discord.Interaction, message: discord.Messa
|
|||||||
title = pixiv_api.dowload_pixiv_images(
|
title = 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:
|
||||||
|
await interaction.response.send_message(
|
||||||
|
"Fail to extract pixiv image", ephemeral=True
|
||||||
|
)
|
||||||
|
return
|
||||||
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(
|
||||||
@ -109,6 +120,8 @@ async def on_message(message: discord.Message):
|
|||||||
title = pixiv_api.dowload_pixiv_images(
|
title = 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:
|
||||||
|
return
|
||||||
files = os.listdir(tmp_dir)
|
files = os.listdir(tmp_dir)
|
||||||
files.sort()
|
files.sort()
|
||||||
# await send_message.send_message_with_embed(
|
# await send_message.send_message_with_embed(
|
||||||
|
@ -11,6 +11,8 @@ def dowload_pixiv_images(
|
|||||||
# get origin url
|
# get origin url
|
||||||
json_result = api.illust_detail(illust_id)
|
json_result = api.illust_detail(illust_id)
|
||||||
illust = json_result.illust
|
illust = json_result.illust
|
||||||
|
if not illust["visible"]:
|
||||||
|
return None
|
||||||
pages = illust["meta_pages"]
|
pages = illust["meta_pages"]
|
||||||
if len(pages) > 0:
|
if len(pages) > 0:
|
||||||
print(f"Dowloading mutiple images to {dest_folder} ({len(pages)})")
|
print(f"Dowloading mutiple images to {dest_folder} ({len(pages)})")
|
||||||
|
Loading…
Reference in New Issue
Block a user