Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vasysik/yt-dlp-host-api
A simple python library for sending requests to your yt-dlp-host API
https://github.com/vasysik/yt-dlp-host-api
api docker docker-compose library python python-library server youtube youtube-downloader yt-dlp yt-dlp-api yt-dlp-host yt-dlp-server
Last synced: 3 months ago
JSON representation
A simple python library for sending requests to your yt-dlp-host API
- Host: GitHub
- URL: https://github.com/vasysik/yt-dlp-host-api
- Owner: Vasysik
- License: mit
- Created: 2024-08-27T20:06:15.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-09-23T21:24:50.000Z (4 months ago)
- Last Synced: 2024-10-10T00:43:37.138Z (3 months ago)
- Topics: api, docker, docker-compose, library, python, python-library, server, youtube, youtube-downloader, yt-dlp, yt-dlp-api, yt-dlp-host, yt-dlp-server
- Language: Python
- Homepage:
- Size: 19.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [yt-dlp-host](https://github.com/Vasysik/yt-dlp-host) API Client
This is a Python library for interacting with the [yt-dlp-host](https://github.com/Vasysik/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:
```python
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")
```## 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, video_format="bestvideo", audio_format="bestaudio")`: Simple way to get the result of get_video
- `client.get_audio(url, audio_format="bestaudio")`: Simple way to get the result of get_audio
- `client.get_live_video(url, duration, start=0, video_format="bestvideo", audio_format="bestaudio")`: Simple way to get the result of get_live_video
- `client.get_live_audio(url, duration, start=0, audio_format="bestaudio")`: Simple way to get the result of get_live_audio
- `client.get_info(url)`: Simple way to get the result of get_info
- `client.send_task.get_video(url, video_format="bestvideo", audio_format="bestaudio")`: Initiates a get_video task
- `client.send_task.get_audio(url, audio_format="bestaudio")`: Initiates a get_audio task
- `client.send_task.get_live_video(url, duration, start=0, video_format="bestvideo", audio_format="bestaudio")`: Initiates a get_video task
- `client.send_task.get_live_audio(url, duration, start=0, audio_format="bestaudio")`: Initiates a get_audio task
- `client.send_task.get_info(url)`: Initiates a get_info task
- `client.check_permissions(permissions)`: Checks for all permissions in the list### Task
- `task.get_status()`: Get the current status of a task
- `task.get_result()`: Wait for and return the result of a task### TaskResult
- `result.get_file()`: Get the file
- `result.get_file_url()`: Get the URL of the downloaded file
- `result.save_file(path)`: Save the downloaded file to the specified path
- `result.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 key
- `client.get_keys()`: List all existing API keys
- `client.get_key(name)`: Get API key by key name
- `client.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.