Add year searches to TV shows
This commit is contained in:
parent
2681786f9c
commit
4d9f76b9e0
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -84,6 +84,7 @@ ipython_config.py
|
||||||
|
|
||||||
# pyenv
|
# pyenv
|
||||||
.python-version
|
.python-version
|
||||||
|
.pyenv
|
||||||
|
|
||||||
# pipenv
|
# pipenv
|
||||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||||
|
|
28
test_tmdb.py
28
test_tmdb.py
|
@ -134,6 +134,34 @@ class TestTmdbMethods(unittest.IsolatedAsyncioTestCase):
|
||||||
self.assertEqual('The Flash', movie.title)
|
self.assertEqual('The Flash', movie.title)
|
||||||
await movie.close_session()
|
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):
|
async def test_cast_2(self):
|
||||||
movie = TvShow()
|
movie = TvShow()
|
||||||
await movie.load_parameters()
|
await movie.load_parameters()
|
||||||
|
|
|
@ -206,7 +206,8 @@ class TmdbBot(Plugin):
|
||||||
language = self.db.get_language(evt.sender)
|
language = self.db.get_language(evt.sender)
|
||||||
if language:
|
if language:
|
||||||
movie.set_language(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:
|
if movie.valid:
|
||||||
await self.send_movie_info(evt, movie)
|
await self.send_movie_info(evt, movie)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -161,9 +161,11 @@ class TvShow(TmdbApiSingle):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
async def search_title(self, title):
|
async def search_title(self, title, year: int = 0):
|
||||||
payload = {}
|
payload = {}
|
||||||
payload['query'] = title
|
payload['query'] = title
|
||||||
|
if year:
|
||||||
|
payload['first_air_date_year'] = str(year)
|
||||||
json = await self.request('/search/tv', params=payload)
|
json = await self.request('/search/tv', params=payload)
|
||||||
if json['total_results'] > 0:
|
if json['total_results'] > 0:
|
||||||
movie_id = json['results'][0]['id']
|
movie_id = json['results'][0]['id']
|
||||||
|
|
Loading…
Reference in a new issue