about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-03-21 19:41:54 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-03-21 19:41:54 +0100
commit5b5caee512dd82bc5106e69259ba916cd143deda (patch)
tree9f6924a8c1d1057cddfbccb2cafd2e34553ac840
parentchore(treewide): Migrate to rust edition 2024 (diff)
downloadyt-5b5caee512dd82bc5106e69259ba916cd143deda.zip
refactor(yt_dlp): Remove the unneeded `async` from the public functions
-rw-r--r--crates/yt_dlp/src/lib.rs10
-rw-r--r--yt/src/download/mod.rs10
-rw-r--r--yt/src/select/cmds/add.rs11
-rw-r--r--yt/src/storage/subscriptions.rs2
-rw-r--r--yt/src/subscribe/mod.rs2
-rw-r--r--yt/src/update/updater.rs3
6 files changed, 17 insertions, 21 deletions
diff --git a/crates/yt_dlp/src/lib.rs b/crates/yt_dlp/src/lib.rs
index 40610c2..c6d9290 100644
--- a/crates/yt_dlp/src/lib.rs
+++ b/crates/yt_dlp/src/lib.rs
@@ -332,9 +332,8 @@ pub fn add_hooks<'a>(opts: Bound<'a, PyDict>, py: Python<'_>) -> PyResult<Bound<
 ///
 /// It will also download the videos if 'download'.
 /// Returns the resolved `ie_result`.
-#[allow(clippy::unused_async)]
 #[allow(clippy::missing_panics_doc)]
-pub async fn process_ie_result(
+pub fn process_ie_result(
     yt_dlp_opts: &Map<String, Value>,
     ie_result: InfoJson,
     download: bool,
@@ -378,9 +377,8 @@ pub async fn process_ie_result(
 ///
 /// @param `extra_info`   Dictionary containing the extra values to add to the info (For internal use only)
 /// @`force_generic_extractor`  Force using the generic extractor (Deprecated; use `ie_key`='Generic')
-#[allow(clippy::unused_async)]
 #[allow(clippy::missing_panics_doc)]
-pub async fn extract_info(
+pub fn extract_info(
     yt_dlp_opts: &Map<String, Value>,
     url: &Url,
     download: bool,
@@ -460,7 +458,7 @@ pub fn unsmuggle_url(smug_url: &Url) -> PyResult<Url> {
 ///
 /// # Panics
 /// Only if `yt_dlp` changes their `info_json` schema.
-pub async fn download(
+pub fn download(
     urls: &[Url],
     download_options: &Map<String, Value>,
 ) -> Result<Vec<PathBuf>, YtDlpError> {
@@ -468,7 +466,7 @@ pub async fn download(
 
     for url in urls {
         info!("Started downloading url: '{}'", url);
-        let info_json = extract_info(download_options, url, true, true).await?;
+        let info_json = extract_info(download_options, url, true, true)?;
 
         // Try to work around yt-dlp type weirdness
         let result_string = if let Some(filename) = info_json.filename {
diff --git a/yt/src/download/mod.rs b/yt/src/download/mod.rs
index 984d400..871e869 100644
--- a/yt/src/download/mod.rs
+++ b/yt/src/download/mod.rs
@@ -109,7 +109,7 @@ impl Downloader {
             }
         }
         let cache_allocation = Self::get_current_cache_allocation(app).await?;
-        let video_size = self.get_approx_video_size(app, next_video).await?;
+        let video_size = self.get_approx_video_size(app, next_video)?;
 
         if video_size >= max_cache_size {
             error!(
@@ -291,7 +291,7 @@ impl Downloader {
         dir_size(read_dir_result).await
     }
 
-    async fn get_approx_video_size(&mut self, app: &App, video: &Video) -> Result<u64> {
+    fn get_approx_video_size(&mut self, app: &App, video: &Video) -> Result<u64> {
         if let Some(value) = self.video_size_cache.get(&video.extractor_hash) {
             Ok(*value)
         } else {
@@ -301,9 +301,8 @@ impl Downloader {
             };
             let opts = &download_opts(app, &add_opts);
 
-            let result = yt_dlp::extract_info(opts, &video.url, false, true)
-                .await
-                .with_context(|| {
+            let result =
+                yt_dlp::extract_info(opts, &video.url, false, true).with_context(|| {
                     format!("Failed to extract video information: '{}'", video.title)
                 })?;
 
@@ -344,7 +343,6 @@ impl Downloader {
         let addional_opts = get_video_yt_dlp_opts(app, &video.extractor_hash).await?;
 
         let result = yt_dlp::download(&[video.url.clone()], &download_opts(app, &addional_opts))
-            .await
             .with_context(|| format!("Failed to download video: '{}'", video.title))?;
 
         assert_eq!(result.len(), 1);
diff --git a/yt/src/select/cmds/add.rs b/yt/src/select/cmds/add.rs
index da58ec2..8b183f0 100644
--- a/yt/src/select/cmds/add.rs
+++ b/yt/src/select/cmds/add.rs
@@ -42,7 +42,6 @@ pub(super) async fn add(
                 .unreachable("`yt_dlp` should guarantee that this is Some at this point");
 
             let entry = yt_dlp::extract_info(opts, &url, false, true)
-                .await
                 .with_context(|| format!("Failed to fetch entry for url: '{url}'"))?;
 
             add_entry(app, entry).await?;
@@ -90,12 +89,14 @@ pub(super) async fn add(
             Ok(())
         }
 
-        let opts = download_opts(app, &video_database::YtDlpOptions {
-            subtitle_langs: String::new(),
-        });
+        let opts = download_opts(
+            app,
+            &video_database::YtDlpOptions {
+                subtitle_langs: String::new(),
+            },
+        );
 
         let entry = yt_dlp::extract_info(&opts, &url, false, true)
-            .await
             .with_context(|| format!("Failed to fetch entry for url: '{url}'"))?;
 
         match entry._type {
diff --git a/yt/src/storage/subscriptions.rs b/yt/src/storage/subscriptions.rs
index 3673eee..37b57fc 100644
--- a/yt/src/storage/subscriptions.rs
+++ b/yt/src/storage/subscriptions.rs
@@ -49,7 +49,7 @@ pub async fn check_url(url: &Url) -> Result<bool> {
         unreachable!("This is hardcoded");
     };
 
-    let info = yt_dlp::extract_info(&yt_opts, url, false, false).await?;
+    let info = yt_dlp::extract_info(&yt_opts, url, false, false)?;
 
     debug!("{:#?}", info);
 
diff --git a/yt/src/subscribe/mod.rs b/yt/src/subscribe/mod.rs
index 455ccb1..d77e2bc 100644
--- a/yt/src/subscribe/mod.rs
+++ b/yt/src/subscribe/mod.rs
@@ -158,7 +158,7 @@ async fn actual_subscribe(app: &App, name: Option<String>, url: Url) -> Result<(
             unreachable!("This is hardcoded")
         };
 
-        let info = yt_dlp::extract_info(&yt_opts, &url, false, false).await?;
+        let info = yt_dlp::extract_info(&yt_opts, &url, false, false)?;
 
         if info._type == Some(InfoType::Playlist) {
             info.title.expect("This should be some for a playlist")
diff --git a/yt/src/update/updater.rs b/yt/src/update/updater.rs
index 2b13378..fe96da3 100644
--- a/yt/src/update/updater.rs
+++ b/yt/src/update/updater.rs
@@ -107,7 +107,6 @@ impl<'a> Updater<'a> {
         }
 
         let info = yt_dlp::extract_info(yt_dlp_opts, &sub.url, false, false)
-            .await
             .with_context(|| format!("Failed to get playlist '{}'.", sub.name))?;
 
         let entries = info.entries.unwrap_or(vec![]);
@@ -133,7 +132,7 @@ impl<'a> Updater<'a> {
             let base: Result<Vec<(&Subscription, InfoJson)>, YtDlpError> =
                 stream::iter(valid_entries)
                     .map(|(sub, entry)| async move {
-                        match process_ie_result(yt_dlp_opts, entry, false).await {
+                        match process_ie_result(yt_dlp_opts, entry, false) {
                             Ok(output) => Ok((sub, output)),
                             Err(err) => Err(err),
                         }