Skip to content

Commit

Permalink
fix: now pixeldrain require an api key (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
DeadNews authored Oct 11, 2024
1 parent 4958b5f commit 4ff3f6d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Windows executable is attached to the GitHub release.
| [imgchest](https://imgchest.com/) | + | `https://cdn.imgchest.com/files/{id}.png` |
| [imgur](https://imgur.com/) | - | `https://i.imgur.com/{id}.png` |
| [lensdump](https://lensdump.com/) | + | `https://i.lensdump.com/i/{id}.png` |
| [pixeldrain](https://pixeldrain.com/) | - | `https://pixeldrain.com/api/file/{id}` |
| [pixeldrain](https://pixeldrain.com/) | + | `https://pixeldrain.com/api/file/{id}` |
| [pixhost](https://pixhost.to/) | - | `https://img75.pixhost.to/images/69/{id}_img.png` |
| [ptpimg](https://ptpimg.me/) | + | `https://ptpimg.me/{id}.png` |
| [smms](https://sm.ms/) | + | `https://s2.loli.net/2022/07/30/{id}.png` |
Expand Down Expand Up @@ -96,6 +96,7 @@ IMGBB_KEY=
IMGCHEST_KEY=
IMGUR_CLIENT_ID=
LENSDUMP_KEY=
PIXELDRAIN_KEY=
PTPIMG_KEY=
SMMS_KEY=
THUMBSNAP_KEY=
Expand Down
5 changes: 4 additions & 1 deletion src/images_upload_cli/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from re import search
from urllib.parse import urlparse

from httpx import AsyncClient
from httpx import AsyncClient, BasicAuth
from loguru import logger

from images_upload_cli.image import get_img_ext
Expand Down Expand Up @@ -355,8 +355,11 @@ async def pixeldrain_upload(client: AsyncClient, img: bytes) -> str:
Returns:
The URL of the uploaded image, or an empty string if the upload failed.
"""
key = get_env("PIXELDRAIN_KEY")

response = await client.post(
url="https://pixeldrain.com/api/file",
auth=BasicAuth(username="", password=key),
files={"file": img},
)
if response.is_error:
Expand Down
1 change: 1 addition & 0 deletions tests/data/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ IMGBB_KEY=key
IMGCHEST_KEY=key
IMGUR_CLIENT_ID=key
LENSDUMP_KEY=key
PIXELDRAIN_KEY=key
PTPIMG_KEY=key
SMMS_KEY=key
THUMBSNAP_KEY=key
Expand Down

0 comments on commit 4ff3f6d

Please sign in to comment.