A Python library for interacting with the yt-dlp-host API
Project description
yt-dlp-host API Client
This is a Python library for interacting with the yt-dlp-host API.
Installation
You can install the library using pip:
pip install yt-dlp-host-api
Usage
Here's a basic example of how to use the library:
import yt_dlp_host_api
# Initialize the API client
api = yt_dlp_host_api.api('http://your-api-url.com')
client = api.get_client('YOUR_API_KEY')
# Download a video
client.get_video(url='https://youtu.be/1FPdtR_5KFo').save_file("test_video.mp4")
print("Video saved to test_video.mp4")
# Download a audio
client.get_audio(url='https://youtu.be/1FPdtR_5KFo').save_file("test_audio.mp3")
print("Audio saved to test_audio.mp3")
# Get info
info_json = client.get_info(url='https://youtu.be/1FPdtR_5KFo').get_json(['qualities', 'title'])
print("Video info:", info_json)
# Admin operations (requires admin API key)
new_key = client.create_key("user_key", ["get_video", "get_audio", "get_info"])
keys = client.list_keys()
key = client.get_key("user_key")
client.delete_key("user_key")
Features
- Download YouTube videos
- Retrieve video information
- Checking client permissions
- Admin operations:
- Create new API keys
- List existing API keys
- Get API key by key name
- Delete API keys
API Reference
Client
client.get_video(url, quality='best')
: Simple way to get the result of get_videoclient.get_audio(url)
: Simple way to get the result of get_audioclient.get_info(url)
: Simple way to get the result of get_infoclient.send_task.get_video(url, quality='best')
: Initiates a get_video taskclient.send_task.get_audio(url, quality='best')
: Initiates a get_audio taskclient.send_task.get_info(url)
: Initiates a get_info taskclient.check_permissions(permissions)
: Checks for all permissions in the list
Task
task.get_status()
: Get the current status of a tasktask.get_result()
: Wait for and return the result of a task
TaskResult
result.get_file()
: Get the fileresult.get_file_url()
: Get the URL of the downloaded fileresult.save_file(path)
: Save the downloaded file to the specified pathresult.get_json(fields=None)
: Get the JSON data for info tasks (optionally filtered by fields)
Admin
client.create_key(name, permissions)
: Create a new API keyclient.list_keys()
: List all existing API keysclient.get_key(name)
: Get API key by key nameclient.delete_key(name)
: Delete an API key
Error Handling
The library uses exceptions to handle errors. Catch yt_dlp_host_api.exceptions.APIError
to handle API-related errors.
Contributing
Contributions to yt-dlp-host-api are welcome! If you have any suggestions, bug reports, or feature requests, please open an issue on the GitHub repository. Pull requests are also encouraged.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for yt_dlp_host_api-0.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0e8f73d5b7c27ffcca56aafadf48f7b10801db6fa9c5fe91fffbebde13a167b |
|
MD5 | f6ceda4e0c05eb86a0ec19991d46743c |
|
BLAKE2b-256 | afe316aa64ab721afa569d3dfa4d434e6f31b0cb367179d1b95b3d636be7195a |