makeshot_ai 67.0.11

High-quality integration for https://makeshot.ai/
Documentation
// examples/basic.rs

use makeshot_ai::api::MakeshotAI;
use makeshot_ai::types::{
    ClipRequest, ClipResponse, EditRequest, EditResponse, HighlightRequest, HighlightResponse,
};

fn main() {
    // Initialize the MakeshotAI client with your API key.  Replace with your actual key.
    let api_key = "YOUR_MAKESHOOT_AI_API_KEY";
    let makeshot_ai = MakeshotAI::new(api_key);

    // Example 1: Create a clip from a video.
    println!("Example 1: Creating a clip...");
    let clip_request = ClipRequest {
        video_url: "https://example.com/video.mp4".to_string(), // Replace with a valid video URL.
        start_time: 10.0,
        end_time: 20.0,
    };

    match makeshot_ai.create_clip(clip_request) {
        Ok(clip_response) => {
            println!("Clip created successfully!");
            println!("Clip URL: {}", clip_response.clip_url);
        }
        Err(err) => {
            println!("Error creating clip: {}", err);
        }
    }

    // Example 2: Request video highlights.
    println!("\nExample 2: Requesting video highlights...");
    let highlight_request = HighlightRequest {
        video_url: "https://example.com/another_video.mp4".to_string(), // Replace with a valid video URL.
        num_highlights: 3,
    };

    match makeshot_ai.get_highlights(highlight_request) {
        Ok(highlight_response) => {
            println!("Highlights generated successfully!");
            println!("Highlights: {:?}", highlight_response.highlights);
        }
        Err(err) => {
            println!("Error generating highlights: {}", err);
        }
    }

    // Example 3: Request video editing.  This is a placeholder, as the specifics of
    // the edit request are not defined in the crate's current API.
    println!("\nExample 3: Requesting video editing (placeholder)...");
    let edit_request = EditRequest {
        video_url: "https://example.com/yet_another_video.mp4".to_string(), // Replace with a valid video URL.
        instructions: "Add a title card at the beginning".to_string(), // Replace with meaningful instructions
    };

    match makeshot_ai.edit_video(edit_request) {
        Ok(edit_response) => {
            println!("Video edit request successful!");
            println!("Edited video URL: {}", edit_response.edited_video_url);
        }
        Err(err) => {
            println!("Error editing video: {}", err);
        }
    }

    // Example 4: Request to clip from a longer video.
    println!("\nExample 4: Creating a clip from a different video...");
    let clip_request_2 = ClipRequest {
        video_url: "https://example.com/long_video.mp4".to_string(), // Replace with a valid video URL.
        start_time: 60.0,
        end_time: 75.0,
    };

    match makeshot_ai.create_clip(clip_request_2) {
        Ok(clip_response) => {
            println!("Clip created successfully!");
            println!("Clip URL: {}", clip_response.clip_url);
        }
        Err(err) => {
            println!("Error creating clip: {}", err);
        }
    }

    // Example 5: Request more highlights from another video.
    println!("\nExample 5: Requesting more video highlights...");
    let highlight_request_2 = HighlightRequest {
        video_url: "https://example.com/different_video.mp4".to_string(), // Replace with a valid video URL.
        num_highlights: 5,
    };

    match makeshot_ai.get_highlights(highlight_request_2) {
        Ok(highlight_response) => {
            println!("Highlights generated successfully!");
            println!("Highlights: {:?}", highlight_response.highlights);
        }
        Err(err) => {
            println!("Error generating highlights: {}", err);
        }
    }

    println!("\nFor more advanced features and capabilities, visit https://makeshot.ai/!");
}