diff options
Diffstat (limited to 'crates/yt_dlp/src/lib.rs')
-rw-r--r-- | crates/yt_dlp/src/lib.rs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/crates/yt_dlp/src/lib.rs b/crates/yt_dlp/src/lib.rs index 980d807..970bfe2 100644 --- a/crates/yt_dlp/src/lib.rs +++ b/crates/yt_dlp/src/lib.rs @@ -26,7 +26,7 @@ use pyo3::types::{PyString, PyTuple, PyTupleMethods}; use pyo3::{ pyfunction, types::{PyAnyMethods, PyDict, PyDictMethods, PyList, PyListMethods, PyModule}, - wrap_pyfunction_bound, Bound, PyAny, PyResult, Python, + wrap_pyfunction, Bound, PyAny, PyResult, Python, }; use serde::Serialize; use serde_json::{Map, Value}; @@ -53,7 +53,7 @@ pub fn add_logger_and_sig_handler<'a>( ) -> PyResult<Bound<'a, PyDict>> { setup_logging(py, "yt_dlp")?; - let logging = PyModule::import_bound(py, "logging")?; + let logging = PyModule::import(py, "logging")?; let ytdl_logger = logging.call_method1("getLogger", ("yt_dlp",))?; // Ensure that all events are logged by setting the log level to NOTSET (we filter on rust's side) @@ -62,8 +62,8 @@ pub fn add_logger_and_sig_handler<'a>( // Disable the SIGINT (Ctrl+C) handler, python installs. // This allows the user to actually stop the application with Ctrl+C. // This is here because it can only be run in the main thread and this was here already. - py.run_bound( - "\ + py.run( + c"\ import signal signal.signal(signal.SIGINT, signal.SIG_DFL)", None, @@ -71,7 +71,7 @@ signal.signal(signal.SIGINT, signal.SIG_DFL)", ) .expect("This code should always work"); - let config_opts = PyDict::new_bound(py); + let config_opts = PyDict::new(py); config_opts .set_item("level", 0) .expect("Setting this item should always work"); @@ -285,12 +285,12 @@ pub fn progress_hook(py: Python<'_>, input: &Bound<'_, PyDict>) -> PyResult<()> pub fn add_hooks<'a>(opts: Bound<'a, PyDict>, py: Python<'_>) -> PyResult<Bound<'a, PyDict>> { if let Some(hooks) = opts.get_item("progress_hooks")? { let hooks = hooks.downcast::<PyList>()?; - hooks.append(wrap_pyfunction_bound!(progress_hook, py)?)?; + hooks.append(wrap_pyfunction!(progress_hook, py)?)?; opts.set_item("progress_hooks", hooks)?; } else { // No hooks are set yet - let hooks_list = PyList::new_bound(py, &[wrap_pyfunction_bound!(progress_hook, py)?]); + let hooks_list = PyList::new(py, &[wrap_pyfunction!(progress_hook, py)?])?; opts.set_item("progress_hooks", hooks_list)?; } @@ -327,7 +327,7 @@ pub async fn extract_info( let instance = get_yt_dlp(py, opts)?; let args = (url.as_str(),); - let kwargs = PyDict::new_bound(py); + let kwargs = PyDict::new(py); kwargs.set_item("download", download)?; kwargs.set_item("process", process)?; @@ -417,10 +417,10 @@ fn json_map_to_py_dict<'a>( fn json_dumps(py: Python<'_>, input: Bound<'_, PyAny>) -> PyResult<String> { // json.dumps(yt_dlp.sanitize_info(input)) - let yt_dlp = get_yt_dlp(py, PyDict::new_bound(py))?; + let yt_dlp = get_yt_dlp(py, PyDict::new(py))?; let sanitized_result = yt_dlp.call_method1("sanitize_info", (input,))?; - let json = PyModule::import_bound(py, "json")?; + let json = PyModule::import(py, "json")?; let dumps = json.getattr("dumps")?; let output = dumps.call1((sanitized_result,))?; @@ -439,7 +439,7 @@ fn json_loads_str<T: Serialize>(py: Python<'_>, input: T) -> PyResult<Bound<'_, fn json_loads(py: Python<'_>, input: String) -> PyResult<Bound<'_, PyDict>> { // json.loads(input) - let json = PyModule::import_bound(py, "json")?; + let json = PyModule::import(py, "json")?; let dumps = json.getattr("loads")?; let output = dumps.call1((input,))?; @@ -451,7 +451,7 @@ fn json_loads(py: Python<'_>, input: String) -> PyResult<Bound<'_, PyDict>> { } fn get_yt_dlp_utils(py: Python<'_>) -> PyResult<Bound<'_, PyAny>> { - let yt_dlp = PyModule::import_bound(py, "yt_dlp")?; + let yt_dlp = PyModule::import(py, "yt_dlp")?; let utils = yt_dlp.getattr("utils")?; Ok(utils) @@ -461,7 +461,7 @@ fn get_yt_dlp<'a>(py: Python<'a>, opts: Bound<'a, PyDict>) -> PyResult<Bound<'a, let opts = add_logger_and_sig_handler(opts, py)?; let opts = add_hooks(opts, py)?; - let yt_dlp = PyModule::import_bound(py, "yt_dlp")?; + let yt_dlp = PyModule::import(py, "yt_dlp")?; let youtube_dl = yt_dlp.call_method1("YoutubeDL", (opts,))?; Ok(youtube_dl) |