Skip to main content

devgagantools

PyPI Version Python Versions License Downloads

devgagantools is a Python library designed for fast and efficient file upload and download operations. It includes features like progress tracking, customizable file names, and human-readable file size formatting. The library is asynchronous and integrates seamlessly with Telegram bots or other projects requiring file management.


Features

  • Fast File Downloads: Asynchronous file downloading with real-time progress updates.
  • Fast File Uploads: Asynchronous file uploading with customizable filenames and progress tracking.
  • Progress Bar: Dynamic progress bar for file operations.
  • Human-Readable Sizes: Easily convert file sizes to human-readable formats.
  • Custom Timing: Control update intervals for progress tracking.

Installation

To install the library once it's published to PyPI, use:

pip install devgagantools

Usage

1. Fast Download

You can use the devgagantools download functionality by providing the required parameters:

  • client: The Telegram client instance (e.g., Pyrogram Client).
  • msg: The Telegram message containing the file to download.
  • reply (Optional): The reply message to update with progress.
  • download_folder (Optional): Folder where the file will be saved (default: downloads/).
  • name (Optional): A custom filename for the downloaded file (default: original file name).
  • progress_bar_function (Optional): A function to customize the progress bar display.

Example

download_location = await devgagantools.fast_download(
    client=client,
    msg=message,
    reply=reply_message,  # Optional
    download_folder="my_files/",  # Optional
    name="custom_filename.mp4",  # Optional
    user_id=1234 # must pass int
)
print(f"File downloaded to: {download_location}")

2. Fast Upload

You can upload files using the following arguments:

  • client: The Telegram client instance (e.g., Pyrogram Client).
  • file_location: The local file path to upload.
  • reply (Optional): The reply message to update with progress.
  • name (Optional): A custom name for the uploaded file (default: original file name).
  • progress_bar_function (Optional): A function to customize the progress bar display.

Example

uploaded_file = await devgagantools.fast_upload(
    client=client,
    file_location="my_files/custom_filename.mp4",
    reply=reply_message,  # Optional
    name="uploaded_file.mp4",  # Optional
    user_id=12344 # must pass
)
print(f"File uploaded successfully: {uploaded_file}")

Parameters for Progress Bar Customization

You can use a custom progress bar function for more control over how the progress is displayed. The function must accept two arguments:

  • done: Bytes downloaded or uploaded so far.
  • total: Total size of the file in bytes.

Example of a custom progress bar function:

def custom_progress_bar(done, total):
    percent = round(done / total * 100, 2)
    return f"Progress: {percent}% ({done}/{total} bytes)"

Pass this function as the progress_bar_function argument in the download or upload methods.


Human-Readable File Sizes

The library also provides a utility to convert file sizes into human-readable formats:

from devgagantools import human_readable_size

size = human_readable_size(1048576)  # Output: '1.00 MB'

Dependencies

  • telethon: For Telegram client and file management.
  • pathlib, os, time, datetime: Standard Python libraries for file and time management.

License

This project is licensed under the MIT License.


Contributions

Contributions are welcome! Feel free to fork the repository, make your changes, and submit a pull request.

Special Thanks

  • Mautrix Telegram Bridge

Contacts

  • Contact us on telegram for any query Team Spy

Metadata

Release files for devgagantools 4.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for devgagantools 4.0.1
File Size Uploaded
devgagantools-4.0.1.tar.gz 10.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for devgagantools 4.0.1
File Interpreter ABI Platform
devgagantools-4.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 20.1 kB

Release files / devgagantools-4.0.1.tar.gz

Download URL devgagantools-4.0.1.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d23a6e01094007b802d429ec8d72739b23e3e628064c12128c607782bba02666
BLAKE2b-256 checksum
How to use checksums
f195a9e1165465780a4f855390f7a93e49d26139a698a788aed935dc8518564c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.5

Release files / devgagantools-4.0.1-py3-none-any.whl

Download URL devgagantools-4.0.1-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
99aa0082d97344d5dac95ba5a6037721236f49ee69a1ad77ea99b8f1137148d6
BLAKE2b-256 checksum
How to use checksums
f951f9de538caa35a019f62131f165bc35971d9332636d24daa995ffffdd484d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.5

Release history Release notifications | RSS feed

This release

4.0.1 This release

2 release files

3.0.1

1 release file

2.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page