Discord Image Uploader
is an efficient Python module designed to upload images to Discord via a webhook. The module ensures image validation, robust error handling, and implements efficient request streaming and concurrent retries for failed uploads.
To install Discord Image Uploader
, use PDM (Python Development Master):
-
Install PDM:
- Follow the installation instructions here.
-
Clone the Repository:
- Clone the
Discord Image Uploader
repository to your local machine.
- Clone the
-
Install Dependencies:
-
Navigate to the repository's root directory and run:
pdm install
-
-
Configure Webhook URL:
- Replace
YOUR_WEBHOOK_URL_HERE
inWEBHOOK_URL
with your Discord webhook URL.
- Replace
-
Place Images:
- Place images in
./images/
directory.
- Place images in
-
Run the Module:
- Execute
pdm run ./src/discord_aiu.py
. The module will validate and upload the images, logging the process.
- Execute
-
Check Logs:
- Review
image_uploader.log
for logs and metrics related to the uploads.
- Review
-
Request Streaming: Utilizes
requests.Session
for efficient connection handling. -
Session Reuse: The same session is used for resending failed images, ensuring connection reuse.
-
Concurrent Retries: Failed images are retried concurrently using
ThreadPoolExecutor
. -
Image Validation: Validates image size and dimensions before upload.
-
Error Handling: Appropriately logs errors.
-
Periodic Metrics Logging: Logs metrics periodically during the upload process.
This project is licensed under the GNU Affero General Public License (APL).