use video url as preview if duration <=2min

This commit is contained in:
Simon
2025-11-13 17:21:50 +00:00
parent d9b505e516
commit 35cd6a440f
2 changed files with 13 additions and 1 deletions

View File

@@ -1287,6 +1287,18 @@ async fn videos_post(
.await;
});
//###
for video in videos.items.iter_mut() {
if video.duration <= 120 {
let mut preview_url = video.url.clone();
if let Some(x) = &video.formats {
// preview is a String here, so use it directly
preview_url = x[0].url.clone();
}
video.preview = Some(preview_url);
}
}
Ok(web::HttpResponse::Ok().json(&videos))
}