about summary refs log tree commit diff stats
path: root/crates/yt_dlp/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--crates/yt_dlp/src/lib.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/crates/yt_dlp/src/lib.rs b/crates/yt_dlp/src/lib.rs
index 6be5e87..4b252de 100644
--- a/crates/yt_dlp/src/lib.rs
+++ b/crates/yt_dlp/src/lib.rs
@@ -115,7 +115,7 @@ impl YoutubeDL {
     /// # Errors
     /// If python attribute access fails.
     pub fn version(&self) -> Result<(String, String), PythonError> {
-        Python::with_gil(|py| {
+        Python::attach(|py| {
             let yt_dlp = py
                 .import(intern!(py, "yt_dlp"))
                 .wrap_exc(py)?
@@ -189,7 +189,7 @@ impl YoutubeDL {
         download: bool,
         process: bool,
     ) -> Result<InfoJson, extract_info::Error> {
-        Python::with_gil(|py| {
+        Python::attach(|py| {
             let inner = self
                 .inner
                 .bind(py)
@@ -202,14 +202,14 @@ impl YoutubeDL {
                     py_kw_args!(py => download = download, process = process),
                 )
                 .wrap_exc(py)?
-                .downcast_into::<PyDict>()
+                .cast_into::<PyDict>()
                 .expect("This is a dict");
 
             // Resolve the generator object
             if let Ok(generator) = result.get_item(intern!(py, "entries")) {
                 if generator.is_instance_of::<PyList>() {
                     // already resolved. Do nothing
-                } else if let Ok(generator) = generator.downcast::<PyIterator>() {
+                } else if let Ok(generator) = generator.cast::<PyIterator>() {
                     // A python generator object.
                     let max_backlog = json_try_get!(self.options, "playlistend", as_u64)
                         .map_or(10000, |playlistend| {
@@ -269,7 +269,7 @@ impl YoutubeDL {
         ie_result: InfoJson,
         download: bool,
     ) -> Result<InfoJson, process_ie_result::Error> {
-        Python::with_gil(|py| {
+        Python::attach(|py| {
             let inner = self
                 .inner
                 .bind(py)
@@ -282,7 +282,7 @@ impl YoutubeDL {
                     py_kw_args!(py => download = download),
                 )
                 .wrap_exc(py)?
-                .downcast_into::<PyDict>()
+                .cast_into::<PyDict>()
                 .expect("This is a dict");
 
             let result = self.prepare_info_json(&result, py)?;
@@ -296,7 +296,7 @@ impl YoutubeDL {
     /// # Errors
     /// If python operations fail.
     pub fn close(&self) -> Result<(), close::Error> {
-        Python::with_gil(|py| {
+        Python::attach(|py| {
             debug!("Closing YoutubeDL.");
 
             let inner = self
@@ -324,7 +324,7 @@ impl YoutubeDL {
 
         let value = sanitize.call((info,), None).wrap_exc(py)?;
 
-        let result = value.downcast::<PyDict>().expect("This should stay a dict");
+        let result = value.cast::<PyDict>().expect("This should stay a dict");
 
         Ok(json_dumps(result))
     }