Skip to content

Commit

Permalink
Merge pull request #233 from dbatten5/async-search-movie-optional-region
Browse files Browse the repository at this point in the history
optional region for search async
  • Loading branch information
dbatten5 committed Feb 19, 2023
2 parents ebe5c9d + 65ebea5 commit 86f32ed
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 93 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "phylm"
version = "6.1.2"
version = "6.1.3"
description = "Phylm"
authors = ["Dom Batten <[email protected]>"]
license = "MIT"
Expand Down
6 changes: 4 additions & 2 deletions src/phylm/clients/tmdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def search_movies(
return results

async def search_movies_async(
self, query: str, region: str = "us", year: Optional[int] = None
self, query: str, region: Optional[str] = None, year: Optional[int] = None
) -> List[Dict[str, Any]]:
"""Search for movies async.
Expand All @@ -91,10 +91,12 @@ async def search_movies_async(
"language": "en-US",
"query": query,
"include_adult": "false",
"region": region.upper(),
"page": 1,
}

if region:
params["region"] = region

if year:
params["year"] = year

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ interactions:
body: null
headers: {}
method: GET
uri: https://api.themoviedb.org/3/search/movie?include_adult=false&language=en-US&page=1&query=askdjhashdaskdasljd&region=US
uri: https://api.themoviedb.org/3/search/movie?include_adult=false&language=en-US&page=1&query=askdjhashdaskdasljd
response:
body:
string: '{"page":1,"results":[],"total_pages":0,"total_results":0}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ interactions:
body: null
headers: {}
method: GET
uri: https://api.themoviedb.org/3/search/movie?include_adult=false&language=en-US&page=1&query=The+Matrix&region=US&year=1999
uri: https://api.themoviedb.org/3/search/movie?include_adult=false&language=en-US&page=1&query=The+Matrix&year=1999
response:
body:
string:
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/vcr_cassettes/tmdb/no_results.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ interactions:
body: null
headers: {}
method: GET
uri: https://api.themoviedb.org/3/search/movie?api_key=9017d5457c4e8ec5f0999d1b10012ae1&language=en-US&query=asldkjnkasnxlajsnxkasjxnas&include_adult=false&region=US&page=1
uri: https://api.themoviedb.org/3/search/movie?api_key=9017d5457c4e8ec5f0999d1b10012ae1&language=en-US&query=asldkjnkasnxlajsnxkasjxnas&include_adult=false&page=1
response:
body:
string: '{"page":1,"results":[],"total_pages":0,"total_results":0}'
Expand Down
170 changes: 87 additions & 83 deletions tests/fixtures/vcr_cassettes/tmdb/the_matrix.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/fixtures/vcr_cassettes/tmdb/the_matrix_3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ interactions:
body: null
headers: {}
method: GET
uri: https://api.themoviedb.org/3/search/movie?api_key=9017d5457c4e8ec5f0999d1b10012ae1&language=en-US&query=The+Matrix&include_adult=false&region=US&page=1&year=2021
uri: https://api.themoviedb.org/3/search/movie?api_key=9017d5457c4e8ec5f0999d1b10012ae1&language=en-US&query=The+Matrix&include_adult=false&page=1&year=2021
response:
body:
string:
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/clients/test_tmdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async def test_success(self) -> None:
f"{VCR_FIXTURES_DIR}/the_matrix_async.yaml",
filter_query_parameters=["api_key"],
) as cass:
results = await client.search_movies_async(query="The Matrix")
results = await client.search_movies_async(query="The Matrix", region="US")

assert results[0]["title"] == "The Matrix Resurrections"

Expand Down Expand Up @@ -128,7 +128,6 @@ async def test_success_year(self) -> None:
("language", "en-US"),
("page", "1"),
("query", "The Matrix"),
("region", "US"),
("year", "1999"),
]

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/sources/test_tmdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ async def test_year(self) -> None:
tmdb = Tmdb("The Matrix")
await tmdb.load_source()

assert tmdb.rating == 8.196
assert tmdb.rating == 8.2


class TestPlot:
Expand Down

0 comments on commit 86f32ed

Please sign in to comment.