First functional version

This commit is contained in:
VC
2023-09-29 18:10:10 +02:00
parent 2a3ebf6fe4
commit e664853728
8 changed files with 304 additions and 5 deletions

View File

@@ -14,6 +14,7 @@ pub struct PeerTubeVideo {
pub description: String,
#[serde(rename = "streamingPlaylists")]
pub streaming_playlists: Option<Vec<PeerTubeVideoStreamingPlaylists>>,
pub tags: Option<Vec<String>>,
}
#[derive(Debug, Deserialize)]
@@ -36,7 +37,7 @@ 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))?
let body = reqwest::blocking::get(format!("{}/api/v1/videos?count=1&sort=publishedAt", u))?
.json::<PeerTubeVideos>()?;
let vid = get_video_detail(u, &body.data[0].uuid)?;
@@ -45,7 +46,7 @@ pub fn get_latest_video(u: &str) -> Result<PeerTubeVideo, Box<dyn Error>> {
}
/// This returns the direct download URL for with the maximum resolution
pub fn get_max_resolution_dl(p: &Vec<PeerTubeVideoStreamingPlaylists>) -> String {
pub fn get_max_resolution_dl(p: &[PeerTubeVideoStreamingPlaylists]) -> String {
let mut res = 0;
let mut dl_url = String::new();