boul2gom / yt-dlp

🎬️ A Rust library (with auto dependencies downloading) for yt-dlp
https://crates.io/crates/yt-dlp
GNU General Public License v3.0
6 stars 4 forks source link

A Serde error `invalid type: null, expected a string` on the `release_git_head` field #5

Open matous-volf opened 1 week ago

matous-volf commented 1 week ago

Using rustc 1.82.0 (f6e511eec 2024-10-15). Combining the examples from the docs.

Cargo.toml:

[package]
name = "temp"
version = "0.1.0"
edition = "2021"

[dependencies]
tokio = { version = "1.41.0", features = ["rt", "rt-multi-thread", "macros"] }
yt-dlp = { version = "1.2.3", features = ["tracing"] }
tracing-subscriber = "0.3.18"

main.rs:

use yt_dlp::Youtube;
use std::path::PathBuf;

#[tokio::main]
pub async fn main() -> Result<(), Box<dyn std::error::Error>> {
    tracing_subscriber::fmt::init();

    let executables_dir = PathBuf::from("libs");
    let output_dir = PathBuf::from("output");

    let fetcher = Youtube::with_new_binaries(executables_dir, output_dir).await?;

    let url = String::from("https://www.youtube.com/watch?v=dQw4w9WgXcQ");
    fetcher.download_video_from_url(url, "my-video.mp4").await?;
    Ok(())
}

Logs:

DEBUG download_video_from_url{self=Youtube { libraries: Libraries { youtube: "libs/yt-dlp", ffmpeg: "libs/ffmpeg" }, output_dir: "output", args: [] } url="https://www.youtube.com/watch?v=dQw4w9WgXcQ" output="my-video.mp4"}: yt_dlp: Downloading video from https://www.youtube.com/watch?v=dQw4w9WgXcQ
DEBUG download_video_from_url{self=Youtube { libraries: Libraries { youtube: "libs/yt-dlp", ffmpeg: "libs/ffmpeg" }, output_dir: "output", args: [] } url="https://www.youtube.com/watch?v=dQw4w9WgXcQ" output="my-video.mp4"}:fetch_video_infos{self=Youtube { libraries: Libraries { youtube: "libs/yt-dlp", ffmpeg: "libs/ffmpeg" }, output_dir: "output", args: [] } url="https://www.youtube.com/watch?v=dQw4w9WgXcQ"}: yt_dlp: Fetching video information for https://www.youtube.com/watch?v=dQw4w9WgXcQ
DEBUG download_video_from_url{self=Youtube { libraries: Libraries { youtube: "libs/yt-dlp", ffmpeg: "libs/ffmpeg" }, output_dir: "output", args: [] } url="https://www.youtube.com/watch?v=dQw4w9WgXcQ" output="my-video.mp4"}:fetch_video_infos{self=Youtube { libraries: Libraries { youtube: "libs/yt-dlp", ffmpeg: "libs/ffmpeg" }, output_dir: "output", args: [] } url="https://www.youtube.com/watch?v=dQw4w9WgXcQ"}:execute: yt_dlp::utils::executor: Executing command: Executor { executable_path: "libs/yt-dlp", timeout: 30s, args: ["--no-progress", "--dump-json", "https://www.youtube.com/watch?v=dQw4w9WgXcQ"] }
Error: Serde(Error("invalid type: null, expected a string", line: 1, column: 509407))

Thank you in advance.

matous-volf commented 1 week ago

Just found out that using a yt-dlp and ffmpeg locally installed in the environment by

let libraries = Libraries::new("yt-dlp".into(), "ffmpeg".into());
let fetcher = Youtube::new(libraries, output_dir).unwrap();

~works~ helps, but not very consistently – some videos can sometimes be downloaded. That is strange, since both local

yt-dlp --version

and the auto downloaded

libs/yt-dlp --version

are 2024.11.04.

matous-volf commented 1 week ago

It seems, that the line and column from the Serde error refer to the field

{
    ...
    "_version": {
        ...
        "release_git_head": null
        ...
    }
}

which in the output of the local yt-dlp does contain a string value.

matous-volf commented 1 week ago

Just found out that using a yt-dlp and ffmpeg locally installed in the environment by

let libraries = Libraries::new("yt-dlp".into(), "ffmpeg".into());
let fetcher = Youtube::new(libraries, output_dir).unwrap();

~works~ helps, but not very consistently – some videos can sometimes be downloaded.

The inconsistency actually turns out to be a separate issue.

boul2gom commented 1 week ago

Thanks for your report. Effectively, this field is supposed to be null because the downloaded version is a release, with no different commit than the head. This will be fixed in a future version, although a major rework is underway, to integrate only the url extraction and decoding part of yt-dlp, and not the whole binary which is slow