Skip to content

Commit

Permalink
fix: remove language and region on /images
Browse files Browse the repository at this point in the history
  • Loading branch information
leandcesar committed Jul 23, 2024
1 parent ddffec0 commit 7879120
Show file tree
Hide file tree
Showing 29 changed files with 66 additions and 93 deletions.
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from setuptools import find_packages, setup

with open("README.rst", "r", encoding="utf-8") as readme_file:
Expand Down
2 changes: 0 additions & 2 deletions tests/routes_async/test_async_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ async def test_collection_images(get_data, assert_data):
f"https://api.themoviedb.org/3/collection/{collection_id}/images",
params={
"api_key": "TEST_TMDB_KEY",
"language": "TEST_TMDB_LANGUAGE",
"region": "TEST_TMDB_REGION",
"watch_region": "TEST_TMDB_REGION",
},
)
Expand Down
2 changes: 0 additions & 2 deletions tests/routes_async/test_async_companies.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ async def test_company_images(get_data, assert_data):
f"https://api.themoviedb.org/3/company/{company_id}/images",
params={
"api_key": "TEST_TMDB_KEY",
"language": "TEST_TMDB_LANGUAGE",
"region": "TEST_TMDB_REGION",
"watch_region": "TEST_TMDB_REGION",
},
)
Expand Down
2 changes: 0 additions & 2 deletions tests/routes_async/test_async_episodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ async def test_episode_images(get_data, assert_data):
f"https://api.themoviedb.org/3/tv/{tv_id}/season/{season_id}/episode/{episode_id}/images",
params={
"api_key": "TEST_TMDB_KEY",
"language": "TEST_TMDB_LANGUAGE",
"region": "TEST_TMDB_REGION",
"watch_region": "TEST_TMDB_REGION",
},
)
Expand Down
2 changes: 0 additions & 2 deletions tests/routes_async/test_async_movies.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@ async def test_movie_images(get_data, assert_data):
f"https://api.themoviedb.org/3/movie/{movie_id}/images",
params={
"api_key": "TEST_TMDB_KEY",
"language": "TEST_TMDB_LANGUAGE",
"region": "TEST_TMDB_REGION",
"watch_region": "TEST_TMDB_REGION",
},
)
Expand Down
2 changes: 0 additions & 2 deletions tests/routes_async/test_async_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ async def test_network_images(get_data, assert_data):
f"https://api.themoviedb.org/3/network/{network_id}/images",
params={
"api_key": "TEST_TMDB_KEY",
"language": "TEST_TMDB_LANGUAGE",
"region": "TEST_TMDB_REGION",
"watch_region": "TEST_TMDB_REGION",
},
)
Expand Down
2 changes: 0 additions & 2 deletions tests/routes_async/test_async_people.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ async def test_person_images(get_data, assert_data):
f"https://api.themoviedb.org/3/person/{person_id}/images",
params={
"api_key": "TEST_TMDB_KEY",
"language": "TEST_TMDB_LANGUAGE",
"region": "TEST_TMDB_REGION",
"watch_region": "TEST_TMDB_REGION",
},
)
Expand Down
2 changes: 0 additions & 2 deletions tests/routes_async/test_async_seasons.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ async def test_season_images(get_data, assert_data):
f"https://api.themoviedb.org/3/tv/{tv_id}/season/{season_id}/images",
params={
"api_key": "TEST_TMDB_KEY",
"language": "TEST_TMDB_LANGUAGE",
"region": "TEST_TMDB_REGION",
"watch_region": "TEST_TMDB_REGION",
},
)
Expand Down
2 changes: 0 additions & 2 deletions tests/routes_async/test_async_tv.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,6 @@ async def test_tv_images(get_data, assert_data):
f"https://api.themoviedb.org/3/tv/{tv_id}/images",
params={
"api_key": "TEST_TMDB_KEY",
"language": "TEST_TMDB_LANGUAGE",
"region": "TEST_TMDB_REGION",
"watch_region": "TEST_TMDB_REGION",
},
)
Expand Down
2 changes: 0 additions & 2 deletions tests/routes_sync/test_sync_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ def test_collection_images(get_data, assert_data):
f"https://api.themoviedb.org/3/collection/{collection_id}/images",
params={
"api_key": "TEST_TMDB_KEY",
"language": "TEST_TMDB_LANGUAGE",
"region": "TEST_TMDB_REGION",
"watch_region": "TEST_TMDB_REGION",
},
)
Expand Down
2 changes: 0 additions & 2 deletions tests/routes_sync/test_sync_companies.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ def test_company_images(get_data, assert_data):
f"https://api.themoviedb.org/3/company/{company_id}/images",
params={
"api_key": "TEST_TMDB_KEY",
"language": "TEST_TMDB_LANGUAGE",
"region": "TEST_TMDB_REGION",
"watch_region": "TEST_TMDB_REGION",
},
)
Expand Down
2 changes: 0 additions & 2 deletions tests/routes_sync/test_sync_episodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ def test_episode_images(get_data, assert_data):
f"https://api.themoviedb.org/3/tv/{tv_id}/season/{season_id}/episode/{episode_id}/images",
params={
"api_key": "TEST_TMDB_KEY",
"language": "TEST_TMDB_LANGUAGE",
"region": "TEST_TMDB_REGION",
"watch_region": "TEST_TMDB_REGION",
},
)
Expand Down
2 changes: 0 additions & 2 deletions tests/routes_sync/test_sync_movies.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ def test_movie_images(get_data, assert_data):
f"https://api.themoviedb.org/3/movie/{movie_id}/images",
params={
"api_key": "TEST_TMDB_KEY",
"language": "TEST_TMDB_LANGUAGE",
"region": "TEST_TMDB_REGION",
"watch_region": "TEST_TMDB_REGION",
},
)
Expand Down
2 changes: 0 additions & 2 deletions tests/routes_sync/test_sync_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ def test_network_images(get_data, assert_data):
f"https://api.themoviedb.org/3/network/{network_id}/images",
params={
"api_key": "TEST_TMDB_KEY",
"language": "TEST_TMDB_LANGUAGE",
"region": "TEST_TMDB_REGION",
"watch_region": "TEST_TMDB_REGION",
},
)
Expand Down
2 changes: 0 additions & 2 deletions tests/routes_sync/test_sync_people.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ def test_person_images(get_data, assert_data):
f"https://api.themoviedb.org/3/person/{person_id}/images",
params={
"api_key": "TEST_TMDB_KEY",
"language": "TEST_TMDB_LANGUAGE",
"region": "TEST_TMDB_REGION",
"watch_region": "TEST_TMDB_REGION",
},
)
Expand Down
2 changes: 0 additions & 2 deletions tests/routes_sync/test_sync_seasons.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ def test_season_images(get_data, assert_data):
f"https://api.themoviedb.org/3/tv/{tv_id}/season/{season_id}/images",
params={
"api_key": "TEST_TMDB_KEY",
"language": "TEST_TMDB_LANGUAGE",
"region": "TEST_TMDB_REGION",
"watch_region": "TEST_TMDB_REGION",
},
)
Expand Down
2 changes: 0 additions & 2 deletions tests/routes_sync/test_sync_tv.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,6 @@ def test_tv_images(get_data, assert_data):
f"https://api.themoviedb.org/3/tv/{tv_id}/images",
params={
"api_key": "TEST_TMDB_KEY",
"language": "TEST_TMDB_LANGUAGE",
"region": "TEST_TMDB_REGION",
"watch_region": "TEST_TMDB_REGION",
},
)
Expand Down
1 change: 1 addition & 0 deletions themoviedb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from themoviedb.aiotmdb import aioTMDb # noqa: F401
from themoviedb.schemas import * # noqa: F401, F403
from themoviedb.tmdb import TMDb # noqa: F401
3 changes: 3 additions & 0 deletions themoviedb/routes_async/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ async def request(self, path: str, method: str = "GET", **kwargs) -> Dict[str, A
if v is not None
}
params = {**self._params, **params}
if path.endswith("/images"):
params.pop("region")
params.pop("language")

if self.session is not None:
if json is None:
Expand Down
3 changes: 3 additions & 0 deletions themoviedb/routes_sync/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ def request(self, path: str, method: str = "GET", **kwargs) -> Dict[str, Any]:
json = kwargs.pop("json", None)
params = {k.replace("__", "."): v for k, v in kwargs.items() if v is not None}
params = {**self._params, **params}
if path.endswith("/images"):
params.pop("region")
params.pop("language")

if self.session is not None:
if json is None:
Expand Down
50 changes: 25 additions & 25 deletions themoviedb/schemas/_partial.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class PartialCompany:
def __str__(self) -> str:
return self.name or ""

def logo_url(self, size: Optional[SizeType] = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size}{self.logo_path}" if self.logo_path else None
def logo_url(self, size: SizeType = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size.value}{self.logo_path}" if self.logo_path else None


@dataclass
Expand All @@ -29,11 +29,11 @@ class PartialCollection:
def __str__(self) -> str:
return self.name or ""

def backdrop_url(self, size: Optional[SizeType] = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size}{self.backdrop_path}" if self.backdrop_path else None
def backdrop_url(self, size: SizeType = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size.value}{self.backdrop_path}" if self.backdrop_path else None

def poster_url(self, size: Optional[SizeType] = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size}{self.poster_path}" if self.poster_path else None
def poster_url(self, size: SizeType = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size.value}{self.poster_path}" if self.poster_path else None


@dataclass
Expand Down Expand Up @@ -61,7 +61,7 @@ class PartialMovie:
vote_count: Optional[int] = None
video: Optional[bool] = None
vote_average: Optional[float] = None
media_type: Optional[MediaType] = MediaType.movie
media_type: MediaType = MediaType.movie

def __str__(self) -> str:
return self.title or self.original_title or ""
Expand All @@ -70,11 +70,11 @@ def __str__(self) -> str:
def year(self) -> Optional[int]:
return self.release_date.year if self.release_date else None

def backdrop_url(self, size: Optional[SizeType] = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size}{self.backdrop_path}" if self.backdrop_path else None
def backdrop_url(self, size: SizeType = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size.value}{self.backdrop_path}" if self.backdrop_path else None

def poster_url(self, size: Optional[SizeType] = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size}{self.poster_path}" if self.poster_path else None
def poster_url(self, size: SizeType = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size.value}{self.poster_path}" if self.poster_path else None


@dataclass
Expand All @@ -87,8 +87,8 @@ class PartialNetwork:
def __str__(self) -> str:
return self.name or ""

def logo_url(self, size: Optional[SizeType] = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size}{self.logo_path}" if self.logo_path else None
def logo_url(self, size: SizeType = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size.value}{self.logo_path}" if self.logo_path else None


@dataclass
Expand All @@ -107,7 +107,7 @@ class PartialTV:
vote_count: Optional[int] = None
name: Optional[str] = None
original_name: Optional[str] = None
media_type: Optional[MediaType] = MediaType.tv
media_type: MediaType = MediaType.tv

def __str__(self) -> str:
return self.name or self.original_name or ""
Expand All @@ -116,11 +116,11 @@ def __str__(self) -> str:
def year(self) -> Optional[int]:
return self.first_air_date.year if self.first_air_date else None

def backdrop_url(self, size: Optional[SizeType] = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size}{self.backdrop_path}" if self.backdrop_path else None
def backdrop_url(self, size: SizeType = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size.value}{self.backdrop_path}" if self.backdrop_path else None

def poster_url(self, size: Optional[SizeType] = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size}{self.poster_path}" if self.poster_path else None
def poster_url(self, size: SizeType = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size.value}{self.poster_path}" if self.poster_path else None


@dataclass
Expand All @@ -136,8 +136,8 @@ class PartialSeason:
def __str__(self) -> str:
return self.name or ""

def poster_url(self, size: Optional[SizeType] = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size}{self.poster_path}" if self.poster_path else None
def poster_url(self, size: SizeType = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size.value}{self.poster_path}" if self.poster_path else None


@dataclass
Expand All @@ -159,8 +159,8 @@ class PartialEpisode:
def __str__(self) -> str:
return self.name or ""

def still_url(self, size: Optional[SizeType] = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size}{self.still_path}" if self.still_path else None
def still_url(self, size: SizeType = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size.value}{self.still_path}" if self.still_path else None


@dataclass
Expand All @@ -179,10 +179,10 @@ class PartialPerson:
name: Optional[str] = None
original_name: Optional[str] = None
popularity: Optional[float] = None
media_type: Optional[MediaType] = MediaType.person
media_type: MediaType = MediaType.person

def __str__(self) -> str:
return self.name or self.original_name or ""

def profile_url(self, size: Optional[SizeType] = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size}{self.profile_path}" if self.profile_path else None
def profile_url(self, size: SizeType = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size.value}{self.profile_path}" if self.profile_path else None
40 changes: 20 additions & 20 deletions themoviedb/schemas/credits.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class Cast:
def __str__(self) -> str:
return self.name or self.original_name or ""

def profile_url(self, size: Optional[SizeType] = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size}{self.profile_path}" if self.profile_path else None
def profile_url(self, size: SizeType = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size.value}{self.profile_path}" if self.profile_path else None


@dataclass
Expand All @@ -64,8 +64,8 @@ class Crew:
def __str__(self) -> str:
return self.name or self.original_name or ""

def profile_url(self, size: Optional[SizeType] = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size}{self.profile_path}" if self.profile_path else None
def profile_url(self, size: SizeType = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size.value}{self.profile_path}" if self.profile_path else None


@dataclass
Expand Down Expand Up @@ -114,11 +114,11 @@ class CastMovie:
def __str__(self) -> str:
return self.title or ""

def backdrop_url(self, size: Optional[SizeType] = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size}{self.backdrop_path}" if self.backdrop_path else None
def backdrop_url(self, size: SizeType = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size.value}{self.backdrop_path}" if self.backdrop_path else None

def poster_url(self, size: Optional[SizeType] = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size}{self.poster_path}" if self.poster_path else None
def poster_url(self, size: SizeType = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size.value}{self.poster_path}" if self.poster_path else None


@dataclass
Expand All @@ -145,11 +145,11 @@ class CrewMovie:
def __str__(self) -> str:
return self.title or ""

def backdrop_url(self, size: Optional[SizeType] = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size}{self.backdrop_path}" if self.backdrop_path else None
def backdrop_url(self, size: SizeType = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size.value}{self.backdrop_path}" if self.backdrop_path else None

def poster_url(self, size: Optional[SizeType] = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size}{self.poster_path}" if self.poster_path else None
def poster_url(self, size: SizeType = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size.value}{self.poster_path}" if self.poster_path else None


@dataclass
Expand Down Expand Up @@ -183,11 +183,11 @@ class CastTV:
def __str__(self) -> str:
return self.name or self.original_name or ""

def backdrop_url(self, size: Optional[SizeType] = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size}{self.backdrop_path}" if self.backdrop_path else None
def backdrop_url(self, size: SizeType = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size.value}{self.backdrop_path}" if self.backdrop_path else None

def poster_url(self, size: Optional[SizeType] = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size}{self.poster_path}" if self.poster_path else None
def poster_url(self, size: SizeType = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size.value}{self.poster_path}" if self.poster_path else None


@dataclass
Expand Down Expand Up @@ -215,11 +215,11 @@ class CrewTV:
def __str__(self) -> str:
return self.name or self.original_name or ""

def backdrop_url(self, size: Optional[SizeType] = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size}{self.backdrop_path}" if self.backdrop_path else None
def backdrop_url(self, size: SizeType = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size.value}{self.backdrop_path}" if self.backdrop_path else None

def poster_url(self, size: Optional[SizeType] = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size}{self.poster_path}" if self.poster_path else None
def poster_url(self, size: SizeType = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size.value}{self.poster_path}" if self.poster_path else None


@dataclass
Expand Down
4 changes: 2 additions & 2 deletions themoviedb/schemas/episodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ class Episode(PartialEpisode):
def __str__(self) -> str:
return self.name or ""

def still_url(self, size: Optional[SizeType] = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size}{self.still_path}" if self.still_path else None
def still_url(self, size: SizeType = SizeType.original) -> Optional[str]:
return f"https://image.tmdb.org/t/p/{size.value}{self.still_path}" if self.still_path else None
Loading

0 comments on commit 7879120

Please sign in to comment.