aboutsummaryrefslogtreecommitdiffstats
path: root/src/download
diff options
context:
space:
mode:
Diffstat (limited to 'src/download')
-rw-r--r--src/download/mod.rs22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/download/mod.rs b/src/download/mod.rs
index b2d0b06..51f1a66 100644
--- a/src/download/mod.rs
+++ b/src/download/mod.rs
@@ -71,6 +71,12 @@ pub struct Downloader {
cached_cache_allocation: Option<u64>,
}
+impl Default for Downloader {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
impl Downloader {
pub fn new() -> Self {
Self {
@@ -95,8 +101,8 @@ impl Downloader {
return Ok(CacheSizeCheck::Fits);
}
}
- let cache_allocation = Self::get_current_cache_allocation(&app).await?;
- let video_size = self.get_approx_video_size(&app, &next_video).await?;
+ let cache_allocation = Self::get_current_cache_allocation(app).await?;
+ let video_size = self.get_approx_video_size(app, next_video).await?;
if video_size >= max_cache_size {
error!(
@@ -159,7 +165,7 @@ impl Downloader {
CacheSizeCheck::ExceedsMaxCacheSize => bail!("Giving up."),
};
- if let Some(_) = &self.current_download {
+ if self.current_download.is_some() {
let current_download = self.current_download.take().expect("Is Some");
if current_download.task_handle.is_finished() {
@@ -233,9 +239,9 @@ impl Downloader {
let add_opts = YtDlpOptions {
subtitle_langs: "".to_owned(),
};
- let opts = &download_opts(&app, add_opts);
+ let opts = &download_opts(app, add_opts);
- let result = yt_dlp::extract_info(&opts, &video.url, false, true)
+ let result = yt_dlp::extract_info(opts, &video.url, false, true)
.await
.with_context(|| {
format!("Failed to extract video information: '{}'", video.title)
@@ -274,16 +280,16 @@ impl Downloader {
async fn actually_cache_video(app: &App, video: &Video) -> Result<()> {
debug!("Download started: {}", &video.title);
- let addional_opts = get_video_yt_dlp_opts(&app, &video.extractor_hash).await?;
+ 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))
+ 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);
let result = &result[0];
- set_video_cache_path(app, &video.extractor_hash, Some(&result)).await?;
+ set_video_cache_path(app, &video.extractor_hash, Some(result)).await?;
info!(
"Video '{}' was downlaoded to path: {}",