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
orstr
: 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
Built Distribution
Hashes for pixeldrain_reloaded-0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb5ede85a678b9c234f2e75851bffa99559ae4660208c536082820c21ef3d074 |
|
MD5 | 7777e200f8fabf14769024938a8fef4f |
|
BLAKE2b-256 | 9acbb0f08af1a3c99f786c64068ae5a2dd8f710214529a19a864201ee8c83ed2 |