Search API with classified releases (#65)
This commit was merged in pull request #65.
This commit is contained in:
@@ -8,7 +8,7 @@ use serde::de::DeserializeOwned;
|
||||
|
||||
use crate::cache::Cache;
|
||||
use crate::error::{Error, Result};
|
||||
use crate::model::{Movie, MovieSearchResult, RawMovie, RawSearchPage};
|
||||
use crate::model::{Movie, MovieSearchResult, RawFindPage, RawMovie, RawSearchPage};
|
||||
|
||||
/// TMDB's v3 API root.
|
||||
pub const DEFAULT_BASE_URL: &str = "https://api.themoviedb.org/3/";
|
||||
@@ -89,6 +89,18 @@ impl TmdbClient {
|
||||
Ok(page.results.into_iter().map(Into::into).collect())
|
||||
}
|
||||
|
||||
/// Resolve an `IMDb` title id through TMDB's external-id index.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Any of [`Error`]; see its variants for what callers should distinguish.
|
||||
pub async fn find_movie_by_imdb(&self, imdb_id: &str) -> Result<Vec<MovieSearchResult>> {
|
||||
let path = format!("find/{}", imdb_id.trim());
|
||||
let params = [("external_source", "imdb_id".to_owned())];
|
||||
let page: RawFindPage = self.get_json(&path, ¶ms).await?;
|
||||
Ok(page.movie_results.into_iter().map(Into::into).collect())
|
||||
}
|
||||
|
||||
/// Full detail for one movie, including the digital release date.
|
||||
///
|
||||
/// One HTTP call: release dates come back appended to the same response
|
||||
|
||||
@@ -107,6 +107,12 @@ pub(crate) struct RawSearchPage {
|
||||
pub(crate) results: Vec<RawSearchResult>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub(crate) struct RawFindPage {
|
||||
#[serde(default)]
|
||||
pub(crate) movie_results: Vec<RawSearchResult>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub(crate) struct RawSearchResult {
|
||||
id: u32,
|
||||
|
||||
Reference in New Issue
Block a user