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

How to use cookies for private videos #18

Closed LobatoLobato closed 8 months ago

LobatoLobato commented 8 months ago

Which cookies do i need to pass to request options to download private videos?

Mithronn commented 8 months ago

To download private videos first you need to upgrade the package version to 0.7.1 (early versions have issues with downloading private videos)

Example:


    let url = "private video URL";

    let cookies_vec = vec![
        "__Secure-1PAPISID=VALUE",
        "__Secure-1PSID=VALUE",
        "__Secure-1PSIDCC=VALUE",
        "__Secure-1PSIDTS=VALUE",
        "__Secure-3PAPISID=VALUE",
        "__Secure-3PSID=VALUE",
        "__Secure-3PSIDCC=VALUE",
        "__Secure-3PSIDTS=VALUE",
        ].join("; ");

    let video_options = VideoOptions {
        request_options: RequestOptions {
            cookies: Some(cookies_vec),
            ..Default::default()
        },
        ..Default::default()
    };

    let video = Video::new_with_options(url, video_options.clone()).unwrap();

    let video_info = video.get_info().await.unwrap();