diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-03-21 19:41:54 +0100 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-03-21 19:41:54 +0100 |
commit | 5b5caee512dd82bc5106e69259ba916cd143deda (patch) | |
tree | 9f6924a8c1d1057cddfbccb2cafd2e34553ac840 /yt/src | |
parent | chore(treewide): Migrate to rust edition 2024 (diff) | |
download | yt-5b5caee512dd82bc5106e69259ba916cd143deda.zip |
refactor(yt_dlp): Remove the unneeded `async` from the public functions
Diffstat (limited to 'yt/src')
-rw-r--r-- | yt/src/download/mod.rs | 10 | ||||
-rw-r--r-- | yt/src/select/cmds/add.rs | 11 | ||||
-rw-r--r-- | yt/src/storage/subscriptions.rs | 2 | ||||
-rw-r--r-- | yt/src/subscribe/mod.rs | 2 | ||||
-rw-r--r-- | yt/src/update/updater.rs | 3 |
5 files changed, 13 insertions, 15 deletions
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), } |