aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-06-24 14:49:34 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-06-24 14:49:34 +0200
commit84175a03a71918497aa0c8ee3444736d771cccff (patch)
treecc897fc45f9d1265389b68bd09c4b538bfb7c622
parentfix(yt/update/grouped): Don't drop the verbosity level (diff)
downloadyt-84175a03a71918497aa0c8ee3444736d771cccff.zip
feat(yt/version): Add the (rust)python version again
-rw-r--r--crates/yt/src/version/mod.rs7
-rw-r--r--crates/yt_dlp/src/lib.rs20
2 files changed, 22 insertions, 5 deletions
diff --git a/crates/yt/src/version/mod.rs b/crates/yt/src/version/mod.rs
index 95660c0..2cc41c7 100644
--- a/crates/yt/src/version/mod.rs
+++ b/crates/yt/src/version/mod.rs
@@ -30,17 +30,20 @@ pub async fn show(config: &Config) -> Result<()> {
.context("Failed to determine database version")?
};
- let yt_dlp_version = {
+ let (yt_dlp, python) = {
let yt_dlp = YoutubeDLOptions::new().build()?;
yt_dlp.version()
};
+ let python = python.replace('\n', " ");
+
println!(
"{}: {}
db version: {db_version}
-yt-dlp: {yt_dlp_version}",
+yt-dlp: {yt_dlp}
+python: {python}",
env!("CARGO_PKG_NAME"),
env!("CARGO_PKG_VERSION"),
);
diff --git a/crates/yt_dlp/src/lib.rs b/crates/yt_dlp/src/lib.rs
index a1db606..c412704 100644
--- a/crates/yt_dlp/src/lib.rs
+++ b/crates/yt_dlp/src/lib.rs
@@ -85,11 +85,14 @@ impl std::fmt::Debug for YoutubeDL {
}
impl YoutubeDL {
+ /// Fetch the underlying `yt_dlp` and `python` version.
+ ///
+ ///
/// # Panics
///
/// If `yt_dlp` changed their location or type of `__version__`.
- pub fn version(&self) -> String {
- let str_ref: PyRef<PyStr> = self.interpreter.enter_and_expect(
+ pub fn version(&self) -> (String, String) {
+ let yt_dlp: PyRef<PyStr> = self.interpreter.enter_and_expect(
|vm| {
let version_module = self.yt_dlp_module.get_attr("version", vm)?;
let version = version_module.get_attr("__version__", vm)?;
@@ -98,7 +101,18 @@ impl YoutubeDL {
},
"yt_dlp version location has changed",
);
- str_ref.to_string()
+
+ let python: PyRef<PyStr> = self.interpreter.enter_and_expect(
+ |vm| {
+ let version_module = vm.import("sys", 0)?;
+ let version = version_module.get_attr("version", vm)?;
+ let version = version.downcast().expect("This should always be a string");
+ Ok(version)
+ },
+ "python version location has changed",
+ );
+
+ (yt_dlp.to_string(), python.to_string())
}
/// Download a given list of URLs.