aboutsummaryrefslogtreecommitdiffstats
path: root/crates/yt_dlp
diff options
context:
space:
mode:
Diffstat (limited to 'crates/yt_dlp')
-rw-r--r--crates/yt_dlp/src/info_json.rs2
-rw-r--r--crates/yt_dlp/src/lib.rs16
-rw-r--r--crates/yt_dlp/src/options.rs4
-rw-r--r--crates/yt_dlp/src/post_processors/dearrow.rs2
4 files changed, 12 insertions, 12 deletions
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