about summary refs log tree commit diff stats
path: root/crates/yt_dlp/src/lib.rs
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 /crates/yt_dlp/src/lib.rs
parentfix(yt/update/grouped): Don't drop the verbosity level (diff)
downloadyt-84175a03a71918497aa0c8ee3444736d771cccff.zip
feat(yt/version): Add the (rust)python version again
Diffstat (limited to '')
-rw-r--r--crates/yt_dlp/src/lib.rs20
1 files changed, 17 insertions, 3 deletions
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.