A simple python library for sending requests to your yt-dlp-host API
MIT License
This is a Python library for interacting with the yt-dlp-host API.
You can install the library using pip:
pip install yt-dlp-host-api
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.get_keys()
key = client.get_key("user_key")
client.delete_key("user_key")
client.get_video(url, video_format="bestvideo", audio_format="bestaudio")
: Simple way to get the result of get_videoclient.get_audio(url, audio_format="bestaudio")
: Simple way to get the result of get_audioclient.get_live_video(url, duration, start=0, video_format="bestvideo", audio_format="bestaudio")
: Simple way to get the result of get_live_videoclient.get_live_audio(url, duration, start=0, audio_format="bestaudio")
: Simple way to get the result of get_live_audioclient.get_info(url)
: Simple way to get the result of get_infoclient.send_task.get_video(url, video_format="bestvideo", audio_format="bestaudio")
: Initiates a get_video taskclient.send_task.get_audio(url, audio_format="bestaudio")
: Initiates a get_audio taskclient.send_task.get_live_video(url, duration, start=0, video_format="bestvideo", audio_format="bestaudio")
: Initiates a get_video taskclient.send_task.get_live_audio(url, duration, start=0, audio_format="bestaudio")
: Initiates a get_audio taskclient.send_task.get_info(url)
: Initiates a get_info taskclient.check_permissions(permissions)
: Checks for all permissions in the listtask.get_status()
: Get the current status of a tasktask.get_result()
: Wait for and return the result of a taskresult.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)client.create_key(name, permissions)
: Create a new API keyclient.get_keys()
: List all existing API keysclient.get_key(name)
: Get API key by key nameclient.delete_key(name)
: Delete an API keyThe library uses exceptions to handle errors. Catch yt_dlp_host_api.exceptions.APIError
to handle API-related errors.
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.