diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-06-13 21:38:51 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-06-13 21:38:51 +0200 |
commit | 22f74fc43b004045d13b0184ae075dea0ebc8eda (patch) | |
tree | bdc2c90706a3df23f038d045f7310f472385d0a7 | |
parent | build(treewide): Update (diff) | |
download | yt-22f74fc43b004045d13b0184ae075dea0ebc8eda.zip |
fix(yt/version): Use yt_dlp's native python version imply
This is just cleaner, compared to running `yt-dlp --version` as command.
Diffstat (limited to '')
-rw-r--r-- | crates/yt/src/version/mod.rs | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/crates/yt/src/version/mod.rs b/crates/yt/src/version/mod.rs index 05d85e0..9a91f3b 100644 --- a/crates/yt/src/version/mod.rs +++ b/crates/yt/src/version/mod.rs @@ -8,26 +8,12 @@ // You should have received a copy of the License along with this program. // If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>. -use std::process::Command; - use anyhow::{Context, Result}; use sqlx::{SqlitePool, sqlite::SqliteConnectOptions}; +use yt_dlp::YoutubeDLOptions; use crate::{config::Config, storage::migrate::get_version_db}; -fn get_cmd_version(cmd: &str) -> Result<String> { - let out = String::from_utf8( - Command::new(cmd) - .arg("--version") - .output() - .with_context(|| format!("Failed to run `{cmd} --version`"))? - .stdout, - ) - .context("Failed to interpret output as utf8")?; - - Ok(out.trim().to_owned()) -} - pub async fn show(config: &Config) -> Result<()> { let db_version = { let options = SqliteConnectOptions::new() @@ -44,16 +30,16 @@ pub async fn show(config: &Config) -> Result<()> { .context("Failed to determine database version")? }; - // TODO(@bpeetz): Use `pyo3`'s build in mechanism instead of executing the python CLI <2025-02-21> - let python_version = get_cmd_version("python")?; - let yt_dlp_version = get_cmd_version("yt-dlp")?; + let yt_dlp_version = { + let yt_dlp = YoutubeDLOptions::new().build()?; + yt_dlp.version() + }; println!( "{}: {} db version: {db_version} -python: {python_version} yt-dlp: {yt_dlp_version}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"), |