# SupermakerAIVideoDownloader
A robust Elixir library for downloading videos from Supermaker AI. This package provides a simple and efficient way to programmatically retrieve video content.
## Installation
Add `supermaker_ai_video_downloader` to your list of dependencies in `mix.exs`:
elixir
def deps do
[
{:supermaker_ai_video_downloader, "~> 0.1.0"}
]
end
Then, run `mix deps.get` to fetch the dependency.
## Usage
This library provides straightforward functions for interacting with the Supermaker AI video service. Here are some examples:
**1. Basic Video Download:**
elixir
alias SupermakerAIVideoDownloader
video_url = "https://supermaker.ai/video/your_video_id"
case SupermakerAIVideoDownloader.download(video_url, "path/to/save/video.mp4") do
{:ok, file_path} ->
IO.puts "Video downloaded successfully to: #{file_path}"
{:error, reason} ->
IO.puts "Error downloading video: #{reason}"
end
**2. Handling Different Download Outcomes:**
elixir
alias SupermakerAIVideoDownloader
video_url = "https://supermaker.ai/video/another_video_id"
SupermakerAIVideoDownloader.download(video_url, "path/to/save/another_video.mp4")
|> case do
{:ok, file_path} ->
IO.puts "Video saved at #{file_path}"
{:error, :invalid_url} ->
IO.puts "The provided URL is invalid."
{:error, :network_error} ->
IO.puts "A network error occurred during the download."
{:error, reason} ->
IO.puts "An unexpected error occurred: #{reason}"
end
**3. Downloading with Custom Headers (if required):**
elixir
alias SupermakerAIVideoDownloader
video_url = "https://supermaker.ai/video/yet_another_video_id"
headers = [{"Authorization", "Bearer your_api_key"}] # Example: Add authorization headers if needed
SupermakerAIVideoDownloader.download(video_url, "path/to/save/yet_another_video.mp4", headers: headers)
|> case do
{:ok, file_path} ->
IO.puts "Video downloaded successfully!"
{:error, reason} ->
IO.puts "Download failed: #{reason}"
end
**4. Using Pipes for Concise Code:**
elixir
alias SupermakerAIVideoDownloader
"https://supermaker.ai/video/a_video_id"
|> SupermakerAIVideoDownloader.download("path/to/save/a_video.mp4")
|> case do
{:ok, file_path} -> IO.puts "Downloaded to: #{file_path}"
{:error, reason} -> IO.puts "Error: #{reason}"
end
**5. Asynchronously Downloading (Example with `Task`):**
elixir
alias SupermakerAIVideoDownloader
Task.async(fn ->
case SupermakerAIVideoDownloader.download("https://supermaker.ai/video/async_video_id", "path/to/save/async_video.mp4") do
{:ok, file_path} -> IO.puts "Async download complete: #{file_path}"
{:error, reason} -> IO.puts "Async download failed: #{reason}"
end
end)
|> Task.await() # Wait for the task to complete (optional)
## Features
* **Simple API:** Easy-to-use functions for downloading videos.
* **Error Handling:** Comprehensive error reporting for robust applications.
* **Custom Headers:** Supports adding custom HTTP headers for authentication and other purposes.
* **Asynchronous Downloads:** Facilitates non-blocking downloads using Elixir's concurrency features.
* **Efficient Downloading:** Optimized for fast and reliable video retrieval.
## License
MIT
This package is part of the supermaker-ai-video-downloader ecosystem. For advanced features and enterprise-grade tools, visit: https://supermaker.ai/video/