use video url as preview if duration <=2min
This commit is contained in:
12
src/api.rs
12
src/api.rs
@@ -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))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user