GyrosOfWar / youtube-dl-rs

A youtube-dl wrapper for Rust
132 stars 40 forks source link

Main thread panicked because of "unknown variant" #53

Closed fyrebirdd closed 1 year ago

fyrebirdd commented 1 year ago

Here is the code that i use to fetch the video (video link was: www.youtube.com/watch?v=OeaUG189ojU)

 pub async fn get_video(url:String, path:String) -> Result<(), Box<dyn std::error::Error>>{
    let yt_dlp_path = download_yt_dlp(".").await?;

    let ydl = YoutubeDl::new(url)
        .socket_timeout("15")
        .youtube_dl_path(yt_dlp_path)
        .output_directory(path)
        .run()
        .unwrap();

    let video = ydl.into_single_video().unwrap().title;
    println!("{:?}", video);
    Ok(())
}

Panicked after i tried to unwrap an error from the download:

thread 'main' panicked at 'called Result::unwrap() on an Err value: Json(Error("unknown variant m3u8_native+https, expected one of http, https, rtsp, rtmp, rtmpe, mms, f4m, ism, m3u8, m3u8_native, http_dash_segments, mhtml, https+https, http_dash_segments+https, http_dash_segments+http_dash_segments, m3u8_native+m3u8_native", line: 0, column: 0))'

phfn commented 1 year ago

Have same Issue with https://www.youtube.com/watch?v=b1kbLwvqugk but not with https://www.youtube.com/watch?v=e0cHp7YaINw

use youtube_dl::YoutubeDl;
fn main() {
    YoutubeDl::new("https://www.youtube.com/watch?v=b1kbLwvqugk")
        .run()
        .unwrap();
}

Output with RUST_BACKTRACE=full cargo run

    Finished dev [unoptimized + debuginfo] target(s) in 0.06s
     Running `target/debug/tmp`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Json(Error("unknown variant `m3u8_native+https`, expected one of `http`, `https`, `rtsp`, `rtmp`, `rtmpe`, `mms`, `f4m`, `ism`, `m3u8`, `m3u8_native`, `http_dash_segments`, `mhtml`, `https+https`, `http_dash_segments+https`, `http_dash_segments+http_dash_segments`, `m3u8_native+m3u8_native`", line: 0, column: 0))', src/main.rs:6:10
stack backtrace:
   0:     0x5633410014da - std::backtrace_rs::backtrace::libunwind::trace::haa961b2d483d3e90
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x5633410014da - std::backtrace_rs::backtrace::trace_unsynchronized::h1a659b0d44dbfd29
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x5633410014da - std::sys_common::backtrace::_print_fmt::h6e2ae81ffd13684f
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x5633410014da - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h403c759a154deb85
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x56334102229e - core::fmt::write::he12900d43c51c548
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/fmt/mod.rs:1254:17
   5:     0x563340fff115 - std::io::Write::write_fmt::h47f0cc0b88fb42a3
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/io/mod.rs:1698:15
   6:     0x5633410012a5 - std::sys_common::backtrace::_print::h197c1d5039b68560
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x5633410012a5 - std::sys_common::backtrace::print::ha232b18a41072dba
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x5633410028ff - std::panicking::default_hook::{{closure}}::hb951b850802037a5
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:269:22
   9:     0x56334100263b - std::panicking::default_hook::h740da2ef9c5fd685
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:288:9
  10:     0x563341002ea8 - std::panicking::rust_panic_with_hook::h2950cbf75d44980a
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:691:13
  11:     0x563341002da9 - std::panicking::begin_panic_handler::{{closure}}::h00faa67086f9f336
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:582:13
  12:     0x563341001946 - std::sys_common::backtrace::__rust_end_short_backtrace::hf933def41044b7fe
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:150:18
  13:     0x563341002ab2 - rust_begin_unwind
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
  14:     0x563340f21013 - core::panicking::panic_fmt::h93217666826e7a30
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:67:14
  15:     0x563340f21553 - core::result::unwrap_failed::h0dc659009e5d5c12
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/result.rs:1687:5
  16:     0x563340f22237 - core::result::Result<T,E>::unwrap::h748bd9070e9428ec
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/result.rs:1089:23
  17:     0x563340f2213a - tmp::main::hb6182cb105f42842
                               at /home/phfn/workspace/yotbot_rs2/tmp/src/main.rs:3:5
  18:     0x563340f2184b - core::ops::function::FnOnce::call_once::hb85517c628e0e47d
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/ops/function.rs:250:5
  19:     0x563340f217be - std::sys_common::backtrace::__rust_begin_short_backtrace::h72b0d96ca025497f
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:134:18
  20:     0x563340f22091 - std::rt::lang_start::{{closure}}::hdaa66507eb532d04
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/rt.rs:166:18
  21:     0x563340ffc68c - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h6013d2abb0e25cc1
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/ops/function.rs:287:13
  22:     0x563340ffc68c - std::panicking::try::do_call::hbdb3649b6818522a
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:485:40
  23:     0x563340ffc68c - std::panicking::try::h6813e20f3cd8abd5
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:449:19
  24:     0x563340ffc68c - std::panic::catch_unwind::h9b9b8903ef7b16b1
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panic.rs:140:14
  25:     0x563340ffc68c - std::rt::lang_start_internal::{{closure}}::h7542c5b9f4701b6a
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/rt.rs:148:48
  26:     0x563340ffc68c - std::panicking::try::do_call::hc869cf3a81193c63
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:485:40
  27:     0x563340ffc68c - std::panicking::try::hf467d360431fafbd
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:449:19
  28:     0x563340ffc68c - std::panic::catch_unwind::h85579295c5db6019
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panic.rs:140:14
  29:     0x563340ffc68c - std::rt::lang_start_internal::h8182539e46fc6c6f
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/rt.rs:148:20
  30:     0x563340f2206a - std::rt::lang_start::he94d0c9ff7dacd65
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/rt.rs:165:17
  31:     0x563340f221be - main
  32:     0x7f08bee87850 - <unknown>
  33:     0x7f08bee8790a - __libc_start_main
  34:     0x563340f21695 - _start
  35:                0x0 - <unknown>
phfn commented 1 year ago

A potential workaround: adding extract_audio(true) The following runs without issues

use youtube_dl::YoutubeDl;
fn main() {
    YoutubeDl::new("https://www.youtube.com/watch?v=b1kbLwvqugk")
        .extract_audio(true)
        .run()
        .unwrap();
}
fyrebirdd commented 1 year ago

I fixed by just forking the repo and adding the code in the most recent pull request, fixed all errors i was having :D