diff --git a/.gitignore b/.gitignore index c85af22..398e025 100644 --- a/.gitignore +++ b/.gitignore @@ -84,6 +84,7 @@ ipython_config.py # pyenv .python-version +.pyenv # pipenv # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. diff --git a/test_tmdb.py b/test_tmdb.py index 2f58489..212ad47 100644 --- a/test_tmdb.py +++ b/test_tmdb.py @@ -134,6 +134,34 @@ class TestTmdbMethods(unittest.IsolatedAsyncioTestCase): self.assertEqual('The Flash', movie.title) await movie.close_session() + async def test_search_tvshow_v(self): + movie = TvShow() + await movie.load_parameters() + mid = await movie.search_title('V') + self.assertEqual(mid, 21494) + await movie.close_session() + + async def test_tv_title_v(self): + movie = TvShow() + await movie.load_parameters() + await movie.search_title('V') + self.assertEqual('V', movie.title) + await movie.close_session() + + async def test_search_tvshow_v_2009(self): + movie = TvShow() + await movie.load_parameters() + mid = await movie.search_title('V', 1983) + self.assertEqual(mid, 14141) + await movie.close_session() + + async def test_tv_title_v_1983(self): + movie = TvShow() + await movie.load_parameters() + await movie.search_title('V', 1983) + self.assertEqual('V', movie.title) + await movie.close_session() + async def test_cast_2(self): movie = TvShow() await movie.load_parameters() diff --git a/tmdb/tmdb.py b/tmdb/tmdb.py index 527550e..903c9e4 100644 --- a/tmdb/tmdb.py +++ b/tmdb/tmdb.py @@ -206,7 +206,8 @@ class TmdbBot(Plugin): language = self.db.get_language(evt.sender) if language: movie.set_language(language) - await movie.search_title(message) + title, year = self.split_title_year(message) + await movie.search_title(title, year) if movie.valid: await self.send_movie_info(evt, movie) else: diff --git a/tmdb/tmdb_api.py b/tmdb/tmdb_api.py index 06e8677..2a5febf 100644 --- a/tmdb/tmdb_api.py +++ b/tmdb/tmdb_api.py @@ -161,9 +161,11 @@ class TvShow(TmdbApiSingle): def __init__(self): super().__init__() - async def search_title(self, title): + async def search_title(self, title, year: int = 0): payload = {} payload['query'] = title + if year: + payload['first_air_date_year'] = str(year) json = await self.request('/search/tv', params=payload) if json['total_results'] > 0: movie_id = json['results'][0]['id']