Skip to main content

simple_downloader/
simple_downloader.rs

1use anyhow::Result;
2use rtkd::TikTokDownloader;
3use std::env;
4
5#[tokio::main]
6async fn main() -> Result<()> {
7    // Get video URL and output path from command line arguments
8    let args: Vec<String> = env::args().collect();
9    if args.len() < 3 {
10        eprintln!("Usage: {} <tiktok_url> <output_path>", args[0]);
11        std::process::exit(1);
12    }
13    
14    let tiktok_url = &args[1];
15    let output_path = &args[2];
16    
17    // Replace this with your actual TikTok cookie
18    let cookie = "cookie string from webui";
19    
20    println!("Initializing TikTok downloader...");
21    
22    // Initialize downloader with the cookie
23    let downloader = TikTokDownloader::builder()
24        .with_cookie(cookie)
25        .build()?;
26    
27    println!("Downloading video from {} to {}", tiktok_url, output_path);
28    
29    // Download the video
30    downloader.download_video(tiktok_url, output_path).await?;
31    
32    println!("Download complete!");
33    Ok(())
34}