Skip to main content

This repository aimed to be fast uploading and fast downloading via Telethon (user and bots both supported)

Project description

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
)
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
)
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.

Contacts

  • Contact us on telegram for any query

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

devgagantools-2.0.1.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

devgagantools-2.0.1-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file devgagantools-2.0.1.tar.gz.

File metadata

  • Download URL: devgagantools-2.0.1.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for devgagantools-2.0.1.tar.gz
Algorithm Hash digest
SHA256 668aa0867cde7ff8761f8f29521e79a8cd0951c4a0375b0a201018ceab71df14
MD5 7c5ee2d8d9bf8cfbb36ba99a9bef2d70
BLAKE2b-256 9b08090270c59331c433247107fd73fab4b9d9e9c6bb847a1b08a81f8d5e3d5f

See more details on using hashes here.

File details

Details for the file devgagantools-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: devgagantools-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for devgagantools-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e9e7e0f7507a63ba21ab2b3c19d9a2f6830de2d63cea5c9bf5212d8fd595dba5
MD5 a0144de3d5598a5acc0220b3e9a8cb9e
BLAKE2b-256 ae70ef7fc7dcad15272d1f9e79546ee3ce8977c64e0c620e79ad0f378873ffcc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page