Add endpoint to get information for a video

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/1/head
trivernis 3 years ago
parent 2181d1d7b4
commit 97ceeaccb3
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -1,6 +1,7 @@
use crate::error::ApiResult;
use crate::models::{
Anime, AnimeSynonym, Artist, Image, Resource, SearchResponse, Series, Song, Theme, ThemeEntry,
Video,
};
use reqwest::Response;
use serde::de::DeserializeOwned;
@ -117,6 +118,12 @@ impl AnimeThemesClient {
self.entry_by_id_with_include("theme", id, include).await
}
/// Returns a video by basename
pub async fn video(&self, basename: &str, include: &[&str]) -> ApiResult<Video> {
self.entry_by_id_with_include("video", basename, include)
.await
}
/// Generic endpoint with the format /<endpoint>/<id> returning the type on the json field <endpoint>
async fn entry_by_id_with_include<T: DeserializeOwned, I: Display>(
&self,

@ -111,6 +111,7 @@ pub struct Video {
pub source: Option<VideoSource>,
pub overlap: VideoOverlap,
pub link: String,
pub entries: Option<Vec<ThemeEntry>>,
}
#[derive(Debug, Clone, Deserialize)]

@ -91,3 +91,14 @@ async fn it_returns_themes_by_id() {
assert!(result.entries.is_some())
}
#[tokio::test]
async fn it_returns_videos_by_basename() {
let client = AnimeThemesClient::default();
let result = client
.video("KimiUso-OP2.webm", &["entries"])
.await
.unwrap();
assert!(result.entries.is_some())
}

Loading…
Cancel
Save