Add watch providers (where to stream/rent/buy)
CI / lint (push) Canceled after 0s
CI / typecheck (push) Canceled after 0s
CI / unit-tests (push) Canceled after 0s
CI / integration-tests (push) Canceled after 0s
CI / container-build (push) Canceled after 0s
CI / dependency-audit (push) Canceled after 0s
CI / lint (push) Canceled after 0s
CI / typecheck (push) Canceled after 0s
CI / unit-tests (push) Canceled after 0s
CI / integration-tests (push) Canceled after 0s
CI / container-build (push) Canceled after 0s
CI / dependency-audit (push) Canceled after 0s
New TMDb integration end to end: append_to_response "watch/providers", normalizer parsing grouped by country/monetization type, a WatchProvider catalog entry (external-id keyed, same get_or_create pattern as Company/ Collection/Person) + polymorphic WatchProviderOffering table (new migration 0002), ingestion write (including provider logos via the existing Artwork table), and API exposure -- embedded on movie/series detail plus a dedicated /watch-providers sub-route, shaped to mirror TMDb's own response for easy porting. Note: this data comes from JustWatch via TMDb and carries its own attribution requirement separate from TMDb's general one -- flagged in docs/api.md, must be satisfied before showing this in the frontend. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
74ebad379a
commit
6c95e18aad
@@ -122,6 +122,35 @@ FAKE_MOVIE = {
|
||||
},
|
||||
]
|
||||
},
|
||||
"watch/providers": {
|
||||
"results": {
|
||||
"US": {
|
||||
"link": "https://www.themoviedb.org/movie/603-the-matrix/watch?locale=US",
|
||||
"flatrate": [
|
||||
{
|
||||
"provider_id": 8,
|
||||
"provider_name": "Netflix",
|
||||
"logo_path": "/netflix.jpg",
|
||||
"display_priority": 0,
|
||||
}
|
||||
],
|
||||
"rent": [
|
||||
{
|
||||
"provider_id": 2,
|
||||
"provider_name": "Apple TV",
|
||||
"logo_path": "/appletv.jpg",
|
||||
"display_priority": 1,
|
||||
}
|
||||
],
|
||||
},
|
||||
"GB": {
|
||||
"link": "https://www.themoviedb.org/movie/603-the-matrix/watch?locale=GB",
|
||||
"flatrate": [
|
||||
{"provider_id": 8, "provider_name": "Netflix", "logo_path": "/netflix.jpg"}
|
||||
],
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
FAKE_PERSON = {
|
||||
@@ -276,6 +305,32 @@ def test_normalize_movie_release_dates_skip_entries_without_a_date():
|
||||
assert movie.release_dates == []
|
||||
|
||||
|
||||
def test_normalize_movie_maps_watch_providers_grouped_by_country_and_type():
|
||||
movie = normalize_movie(FAKE_MOVIE)
|
||||
assert len(movie.watch_providers) == 3
|
||||
|
||||
us_flatrate = next(
|
||||
wp for wp in movie.watch_providers if wp.country_code == "US" and wp.monetization_type == "flatrate"
|
||||
)
|
||||
assert us_flatrate.provider.name == "Netflix"
|
||||
assert us_flatrate.provider.external_id == "8"
|
||||
assert us_flatrate.display_priority == 0
|
||||
assert us_flatrate.link == "https://www.themoviedb.org/movie/603-the-matrix/watch?locale=US"
|
||||
|
||||
us_rent = next(wp for wp in movie.watch_providers if wp.monetization_type == "rent")
|
||||
assert us_rent.provider.name == "Apple TV"
|
||||
|
||||
gb_flatrate = next(wp for wp in movie.watch_providers if wp.country_code == "GB")
|
||||
assert gb_flatrate.link == "https://www.themoviedb.org/movie/603-the-matrix/watch?locale=GB"
|
||||
assert gb_flatrate.display_priority is None
|
||||
|
||||
|
||||
def test_normalize_movie_handles_missing_watch_providers():
|
||||
minimal = {**FAKE_MOVIE, "watch/providers": {}}
|
||||
movie = normalize_movie(minimal)
|
||||
assert movie.watch_providers == []
|
||||
|
||||
|
||||
def test_normalize_movie_handles_missing_optional_sections():
|
||||
minimal = {"id": 1, "title": "Minimal Movie"}
|
||||
movie = normalize_movie(minimal)
|
||||
@@ -351,6 +406,16 @@ FAKE_SERIES = {
|
||||
"content_ratings": {
|
||||
"results": [{"iso_3166_1": "US", "rating": "TV-MA"}, {"iso_3166_1": "GB", "rating": "15"}]
|
||||
},
|
||||
"watch/providers": {
|
||||
"results": {
|
||||
"US": {
|
||||
"link": "https://www.themoviedb.org/tv/1396-breaking-bad/watch?locale=US",
|
||||
"flatrate": [
|
||||
{"provider_id": 1899, "provider_name": "Netflix", "logo_path": "/netflix.jpg"}
|
||||
],
|
||||
}
|
||||
}
|
||||
},
|
||||
"seasons": [
|
||||
{
|
||||
"season_number": 1,
|
||||
@@ -483,6 +548,14 @@ def test_normalize_series_content_ratings_skipped_without_first_air_date():
|
||||
assert series.release_dates == []
|
||||
|
||||
|
||||
def test_normalize_series_maps_watch_providers():
|
||||
series = normalize_series(FAKE_SERIES)
|
||||
assert len(series.watch_providers) == 1
|
||||
assert series.watch_providers[0].provider.name == "Netflix"
|
||||
assert series.watch_providers[0].country_code == "US"
|
||||
assert series.watch_providers[0].monetization_type == "flatrate"
|
||||
|
||||
|
||||
def test_normalize_season_maps_episodes():
|
||||
season = normalize_season(FAKE_SEASON)
|
||||
assert season.season_number == 1
|
||||
|
||||
Reference in New Issue
Block a user