Mithronn / rusty_ytdl

A Rust library for Youtube video searcher and downloader
https://docs.rs/rusty_ytdl
MIT License
107 stars 20 forks source link

Getting 'called `Result::unwrap()` on an `Err` value: VideoIsPrivate'. What I am do wrong? #39

Closed rogerpadilla closed 1 month ago

rogerpadilla commented 3 months ago

Below is my code, i mostly copied it from the samples.

Please help me to understand why I am always getting this error message (i've tried different videos that i can watch):

called `Result::unwrap()` on an `Err` value: VideoIsPrivate
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Code:

use rusty_ytdl::Video;
// use rusty_ytdl::{choose_format,VideoOptions};

// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
async fn greet(name: String) -> String {
    let url = "https://www.youtube.com/watch?v=FZ8BxMU3BYc"; // FZ8BxMU3BYc works too!
                                                                   // Also works with live videos!!
    let video = Video::new(url).unwrap();

    let video_info = video.get_info().await.unwrap();
    println!("{:#?}", video_info);

    format!("Hello, {}! You've been greeted from Rust!", name)
}

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
    tauri::Builder::default()
        .plugin(tauri_plugin_shell::init())
        .invoke_handler(tauri::generate_handler![greet])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}
Mithronn commented 1 month ago

Videos are not VideoIsPrivate. There is a lack of error handling. The error actually occurs due to YouTube's bot protection system. With this #46 PR, you can send your PO token to prevent this error.