thumbnails
Some checks failed
ci/woodpecker/push/build Pipeline failed

This commit is contained in:
JMARyA 2025-01-06 13:57:36 +01:00
parent 14483ceec4
commit c816b5d790
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
2 changed files with 13 additions and 0 deletions

View file

@ -159,6 +159,13 @@ impl Library {
.unwrap()
}
pub async fn get_all_videos(&self) -> Vec<Video> {
sqlx::query_as("SELECT * FROM videos")
.fetch_all(&self.conn)
.await
.unwrap()
}
pub async fn get_newly_added(&self, n: i64) -> Vec<Video> {
sqlx::query_as("SELECT * FROM videos ORDER BY date_added DESC LIMIT $1;")
.bind(n)

View file

@ -35,6 +35,12 @@ async fn launch() -> _ {
library
.scan_dir(&Path::new(&dir_path.clone()).to_path_buf())
.await;
// Ensure thumbnails
for video in library.get_all_videos().await {
log::info!("Ensure thumbnail for {} [{}]", video.title, video.id);
library.get_thumbnail(&video).await;
}
});
let cors = rocket_cors::CorsOptions {