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;
|
.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))
|
Ok(web::HttpResponse::Ok().json(&videos))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ impl VideoItem {
|
|||||||
|
|
||||||
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
|
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
|
||||||
pub struct VideoFormat {
|
pub struct VideoFormat {
|
||||||
url: String,
|
pub url: String,
|
||||||
quality: String,
|
quality: String,
|
||||||
format: String,
|
format: String,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
|||||||
Reference in New Issue
Block a user