Skip to main content

Interact with Pixeldrain using Python Synchronously and Asynchronously!

Project description

Pixeldrain Reloaded

This is a Python library for interacting with Pixeldrain, a simple file sharing service. It provides synchronous and asynchronous functions for uploading, downloading, and retrieving information about files on Pixeldrain; anonymously and with an API key.

Installation

pip install pixeldrain-reloaded

Documentation

get_info(file_id)

Get information about a file on Pixeldrain.

  • Parameters:

    • file_id (str): The ID of the file.
  • Returns:

    • dict: A dictionary containing file information.

upload_file(file_path, returns=None, filename=None, api_key=None)

Upload a file to Pixeldrain synchronously.

  • Parameters:

    • file_path (str): The path to the file to be uploaded.
    • returns (str, optional): Specifies what to return.
    • filename (str, optional): Name of the file to upload.
    • api_key (str, optional): Pixeldrain API key for authorized uploads.
  • Returns:

    • dict or str: Depending on the 'returns' parameter, returns a dictionary or a string.

download_file(file_id, path, filename=None)

Download a file from Pixeldrain synchronously.

  • Parameters:

    • file_id (str): The ID of the file or a Pixeldrain URL.
    • path (str): The local path to save the downloaded file.
    • filename (str, optional): Name to save the file as (default is Pixeldrain filename).
  • Returns:

    • str: The path to the downloaded file.

Asynchronous functions

The asynchronous version of the library provides the same functionality but is designed for use with asyncio and aiohttp for non-blocking asynchronous operations.

Usage

Synchronous Version

Import the library

import pixeldrain_reloaded as pixeldrain

Get Information about a File

file_info = pixeldrain.Sync.get_info(file_id="your_file_id")
print(file_info)

Upload a File

file_path = "path/to/your/file.txt"
response = pixeldrain.Sync.upload_file(file_path, returns="dict", filename="custom_filename", api_key="your_api_key")
print(response)

Download a File

file_id = "your_file_id"
download_path = "path/to/download"
downloaded_file = pixeldrain.Sync.download_file(file_id, download_path, filename="custom_filename")
print(f"File downloaded to: {downloaded_file}")

Asynchronous Version

Import the library

import pixeldrain_reloaded as pixeldrain

Get Information about a File (Async)

file_info = await pixeldrain.Async.get_info(file_id="your_file_id")
print(file_info)

Upload a File (Async)

file_path = "path/to/your/file.txt"
response = await pixeldrain.Async.upload_file(file_path, returns="dict", filename="custom_filename", api_key="your_api_key")
print(response)

Download a File (Async)

file_id = "your_file_id"
download_path = "path/to/download"
downloaded_file = await pixeldrain.Async.download_file(file_id, download_path, filename="custom_filename")
print(f"File downloaded to: {downloaded_file}")

Special Thanks

FayasNoushad for the original library

License

This library is licensed under the MIT License - see the LICENSE file for details.

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

pixeldrain-reloaded-0.3.tar.gz (6.5 kB view hashes)

Uploaded Source

Built Distribution

pixeldrain_reloaded-0.3-py3-none-any.whl (7.9 kB view hashes)

Uploaded Python 3

Supported by

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