mirror of
https://framagit.org/veretcle/tootube.git
synced 2025-07-20 20:41:17 +02:00
feat: async + stream
This commit is contained in:
@@ -36,11 +36,13 @@ pub struct PeerTubeVideoStreamingPlaylistsFilesResolution {
|
||||
}
|
||||
|
||||
/// This gets the last video uploaded to the PeerTube server
|
||||
pub fn get_latest_video(u: &str) -> Result<PeerTubeVideo, Box<dyn Error>> {
|
||||
let body = reqwest::blocking::get(format!("{}/api/v1/videos?count=1&sort=-publishedAt", u))?
|
||||
.json::<PeerTubeVideos>()?;
|
||||
pub async fn get_latest_video(u: &str) -> Result<PeerTubeVideo, Box<dyn Error>> {
|
||||
let body = reqwest::get(format!("{}/api/v1/videos?count=1&sort=-publishedAt", u))
|
||||
.await?
|
||||
.json::<PeerTubeVideos>()
|
||||
.await?;
|
||||
|
||||
let vid = get_video_detail(u, &body.data[0].uuid)?;
|
||||
let vid = get_video_detail(u, &body.data[0].uuid).await?;
|
||||
|
||||
Ok(vid)
|
||||
}
|
||||
@@ -61,9 +63,11 @@ pub fn get_max_resolution_dl(p: &[PeerTubeVideoStreamingPlaylists]) -> String {
|
||||
}
|
||||
|
||||
/// This gets all the crispy details about one particular video
|
||||
fn get_video_detail(u: &str, v: &str) -> Result<PeerTubeVideo, Box<dyn Error>> {
|
||||
let body =
|
||||
reqwest::blocking::get(format!("{}/api/v1/videos/{}", u, v))?.json::<PeerTubeVideo>()?;
|
||||
async fn get_video_detail(u: &str, v: &str) -> Result<PeerTubeVideo, Box<dyn Error>> {
|
||||
let body = reqwest::get(format!("{}/api/v1/videos/{}", u, v))
|
||||
.await?
|
||||
.json::<PeerTubeVideo>()
|
||||
.await?;
|
||||
|
||||
Ok(body)
|
||||
}
|
||||
|
Reference in New Issue
Block a user