diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-08-23 09:06:57 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-08-23 09:06:57 +0200 |
commit | 9a53a739b0f0e1a6741ec6f1bef6a572a8743182 (patch) | |
tree | c7bb929ba53ffa8ece689f60e21f8fed9104c0e5 /src/storage/video_database/downloader.rs | |
parent | fix(storage/downloader): Sort the next videos to be downloaded like in the se... (diff) | |
download | yt-9a53a739b0f0e1a6741ec6f1bef6a572a8743182.tar.gz yt-9a53a739b0f0e1a6741ec6f1bef6a572a8743182.zip |
refactor(storage/downloader): Remove unused `get_next_video_watchable`
Diffstat (limited to 'src/storage/video_database/downloader.rs')
-rw-r--r-- | src/storage/video_database/downloader.rs | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/src/storage/video_database/downloader.rs b/src/storage/video_database/downloader.rs index c2c148d..bba2b0a 100644 --- a/src/storage/video_database/downloader.rs +++ b/src/storage/video_database/downloader.rs @@ -80,63 +80,6 @@ pub async fn get_next_uncached_video(app: &App) -> Result<Option<Video>> { } } -/// Returns to next video which can be watched (i.e. is cached). -/// This respects the priority assigned by select. -pub async fn get_next_video_watchable(app: &App) -> Result<Option<Video>> { - let result = query!( - r#" - SELECT * - FROM videos - WHERE status = 'Watching' AND cache_path IS NOT NULL - ORDER BY priority ASC - LIMIT 1; - "# - ) - .fetch_one(&app.database) - .await; - - if let Err(sqlx::Error::RowNotFound) = result { - Ok(None) - } else { - let base = result?; - - let thumbnail_url = if let Some(url) = &base.thumbnail_url { - Some(Url::parse(&url).expect("Parsing this as url should always work")) - } else { - None - }; - - let status_change = if base.status_change == 1 { - true - } else { - assert_eq!(base.status_change, 0, "Can only be 1 or 0"); - false - }; - - let video = Video { - cache_path: base.cache_path.as_ref().map(|val| PathBuf::from(val)), - description: base.description.clone(), - duration: base.duration, - extractor_hash: ExtractorHash::from_hash( - base.extractor_hash - .parse() - .expect("The db extractor_hash should be valid blake3 hash"), - ), - last_status_change: base.last_status_change, - parent_subscription_name: base.parent_subscription_name.clone(), - priority: base.priority, - publish_date: base.publish_date, - status: VideoStatus::from_db_integer(base.status), - status_change, - thumbnail_url, - title: base.title.clone(), - url: Url::parse(&base.url).expect("Parsing this as url should always work"), - }; - - Ok(Some(video)) - } -} - /// Update the cached path of a video. Will be set to NULL if the path is None /// This will also set the status to `Cached` when path is Some, otherwise it set's the status to /// `Watch`. |