Search API with classified releases (#65)
ci / rust (push) Failing after 1m1s
ci / web (push) Successful in 49s
e2e / e2e (push) Successful in 1m15s

This commit was merged in pull request #65.
This commit is contained in:
2026-08-22 21:22:12 +01:00
parent 29d6831c83
commit de2a13060c
10 changed files with 1136 additions and 2 deletions
+13 -1
View File
@@ -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, &params).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
+6
View File
@@ -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,