From 84175a03a71918497aa0c8ee3444736d771cccff Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Tue, 24 Jun 2025 14:49:34 +0200 Subject: feat(yt/version): Add the (rust)python version again --- crates/yt_dlp/src/lib.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'crates/yt_dlp/src/lib.rs') 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 = self.interpreter.enter_and_expect( + pub fn version(&self) -> (String, String) { + let yt_dlp: PyRef = 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 = 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. -- cgit 1.4.1