diff options
| author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-11-30 15:28:05 +0100 |
|---|---|---|
| committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-11-30 15:28:05 +0100 |
| commit | 8158bcf6da8163fd35f26b59a08fc7f5a9abce11 (patch) | |
| tree | 2fa97f7ab34d187606ae0ceb1061979a610d44b3 /crates | |
| parent | build(treewide): Update (diff) | |
| download | yt-8158bcf6da8163fd35f26b59a08fc7f5a9abce11.zip | |
fix(treewide): Avoid using deprecated functions or patterns
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/libmpv2/src/mpv/events.rs | 2 | ||||
| -rw-r--r-- | crates/libmpv2/src/mpv/protocol.rs | 2 | ||||
| -rw-r--r-- | crates/yt_dlp/src/info_json.rs | 2 | ||||
| -rw-r--r-- | crates/yt_dlp/src/lib.rs | 16 | ||||
| -rw-r--r-- | crates/yt_dlp/src/options.rs | 4 | ||||
| -rw-r--r-- | crates/yt_dlp/src/post_processors/dearrow.rs | 2 |
6 files changed, 14 insertions, 14 deletions
diff --git a/crates/libmpv2/src/mpv/events.rs b/crates/libmpv2/src/mpv/events.rs index f10ff6e..9f6324a 100644 --- a/crates/libmpv2/src/mpv/events.rs +++ b/crates/libmpv2/src/mpv/events.rs @@ -238,7 +238,7 @@ impl EventContext { /// Returns `Some(Err(...))` if there was invalid utf-8, or if either an /// `MPV_EVENT_GET_PROPERTY_REPLY`, `MPV_EVENT_SET_PROPERTY_REPLY`, `MPV_EVENT_COMMAND_REPLY`, /// or `MPV_EVENT_PROPERTY_CHANGE` event failed, or if `MPV_EVENT_END_FILE` reported an error. - pub fn wait_event(&mut self, timeout: f64) -> Option<Result<Event>> { + pub fn wait_event(&mut self, timeout: f64) -> Option<Result<Event<'_>>> { let event = unsafe { *libmpv2_sys::mpv_wait_event(self.ctx.as_ptr(), timeout) }; // debug!("Got an event from mpv: {:#?}", event); diff --git a/crates/libmpv2/src/mpv/protocol.rs b/crates/libmpv2/src/mpv/protocol.rs index ee33411..070fb66 100644 --- a/crates/libmpv2/src/mpv/protocol.rs +++ b/crates/libmpv2/src/mpv/protocol.rs @@ -24,7 +24,7 @@ impl Mpv { /// /// # Panics /// Panics if a context already exists - pub fn create_protocol_context<T, U>(&self) -> ProtocolContext<T, U> + pub fn create_protocol_context<T, U>(&self) -> ProtocolContext<'_, T, U> where T: RefUnwindSafe, U: RefUnwindSafe, diff --git a/crates/yt_dlp/src/info_json.rs b/crates/yt_dlp/src/info_json.rs index 3ed08ee..402acb4 100644 --- a/crates/yt_dlp/src/info_json.rs +++ b/crates/yt_dlp/src/info_json.rs @@ -29,7 +29,7 @@ pub fn json_loads( .call((self_str,), None) .expect("Vaild json is always a valid dict"); - dict.downcast_into().expect("Should always be a dict") + dict.cast_into().expect("Should always be a dict") } /// # Panics 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)) } diff --git a/crates/yt_dlp/src/options.rs b/crates/yt_dlp/src/options.rs index ad30301..4b8906e 100644 --- a/crates/yt_dlp/src/options.rs +++ b/crates/yt_dlp/src/options.rs @@ -104,11 +104,11 @@ impl YoutubeDL { /// If a python call fails. #[allow(clippy::too_many_lines)] pub fn from_options(options: YoutubeDLOptions) -> Result<Self, build::Error> { - pyo3::prepare_freethreaded_python(); + Python::initialize(); let output_options = options.options.clone(); - let yt_dlp_module = Python::with_gil(|py| { + let yt_dlp_module = Python::attach(|py| { let opts = json_loads(options.options, py); { diff --git a/crates/yt_dlp/src/post_processors/dearrow.rs b/crates/yt_dlp/src/post_processors/dearrow.rs index f35f301..7787d68 100644 --- a/crates/yt_dlp/src/post_processors/dearrow.rs +++ b/crates/yt_dlp/src/post_processors/dearrow.rs @@ -58,7 +58,7 @@ inst = DeArrow() None, )?; - Ok(scope.get_item(intern!(py, "inst"))?.downcast_into()?) + Ok(scope.get_item(intern!(py, "inst"))?.cast_into()?) } /// # Errors |
