Added vote average

This commit is contained in:
markus 2021-11-10 15:38:28 +01:00 committed by Scott Wallace
parent 4d9f76b9e0
commit 8d32883c71
Signed by: scott
GPG key ID: AA742FDC5AFE2A72
3 changed files with 12 additions and 3 deletions

View file

@ -29,6 +29,14 @@ class TestTmdbMethods(unittest.IsolatedAsyncioTestCase):
self.assertEqual(movie.valid, True) self.assertEqual(movie.valid, True)
await movie.close_session() await movie.close_session()
async def test_vote(self):
movie = Movie()
await movie.load_parameters()
await movie.search_title('Dune')
vote = movie.vote_average
self.assertEqual(vote, 8.0)
await movie.close_session()
async def test_cast(self): async def test_cast(self):
movie = Movie() movie = Movie()
await movie.load_parameters() await movie.load_parameters()
@ -204,5 +212,6 @@ class TestTmdbMethods(unittest.IsolatedAsyncioTestCase):
await list.close_session() await list.close_session()
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

View file

@ -44,7 +44,7 @@ class MessageConstructor():
return cast[:-2] return cast[:-2]
def construct_html_message(self) -> str: def construct_html_message(self) -> str:
html_message = f"""<p><a href="{self.movie.web_url}"><b>{escape(self.movie.title)}</b></a></p> html_message = f"""<p><a href="{self.movie.web_url}"><b>{escape(self.movie.title)}</b></a> - {str(int(self.movie.vote_average*10))}%</p>
<p>{escape(self.movie.overview)[:self.overview_length]}{self.three_dotts()}</p> <p>{escape(self.movie.overview)[:self.overview_length]}{self.three_dotts()}</p>
<p>{self.cast()}</p> <p>{self.cast()}</p>
<p>Taken from www.themoviedb.org</p>""" <p>Taken from www.themoviedb.org</p>"""

View file

@ -145,7 +145,7 @@ class Movie(TmdbApiSingle):
self.poster_url = self.base_url_poster + data['poster_path'] self.poster_url = self.base_url_poster + data['poster_path']
self.overview = data['overview'] self.overview = data['overview']
self.web_url = 'https://www.themoviedb.org/movie/' + str(self.id) self.web_url = 'https://www.themoviedb.org/movie/' + str(self.id)
self.vote_average = str(data['vote_average']) self.vote_average = data['vote_average']
async def query_cast(self, id): async def query_cast(self, id):
data = await self.request('movie/' + str(id) + '/credits') data = await self.request('movie/' + str(id) + '/credits')
@ -187,7 +187,7 @@ class TvShow(TmdbApiSingle):
self.poster_url = self.base_url_poster + data['poster_path'] self.poster_url = self.base_url_poster + data['poster_path']
self.overview = data['overview'] self.overview = data['overview']
self.web_url = 'https://www.themoviedb.org/tv/' + str(self.id) self.web_url = 'https://www.themoviedb.org/tv/' + str(self.id)
self.vote_average = str(data['vote_average']) self.vote_average = data['vote_average']
async def query_cast(self): async def query_cast(self):
data = await self.request('tv/' + str(self.id) + '/credits') data = await self.request('tv/' + str(self.id) + '/credits')