aboutsummaryrefslogtreecommitdiffstats
path: root/crates/yt_dlp
diff options
context:
space:
mode:
Diffstat (limited to 'crates/yt_dlp')
-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.