Fixed MoviesPopular

This commit is contained in:
lomion 2021-11-08 22:28:34 +01:00
parent 28c2a9e474
commit 16336d61f3
2 changed files with 7 additions and 5 deletions

View file

@ -161,11 +161,15 @@ class TmdbBot(Plugin):
async def movie_popular(self, evt: MessageEvent, message: str = "") -> None: async def movie_popular(self, evt: MessageEvent, message: str = "") -> None:
popular = MoviePopular() popular = MoviePopular()
await popular.load_parameters()
language = self.db.get_language(evt.sender) language = self.db.get_language(evt.sender)
if language: if language:
popular.set_language(language) popular.set_language(language)
length = 5 length = 5
await self.send_html_message(evt, popular.getListText(length), popular.getListHtml(length)) await popular.query()
text = popular.getListText(length)
html = popular.getListHtml(length)
await self.send_html_message(evt, text, html)
@command.new("movie-search", help="Movie lookup by Title") @command.new("movie-search", help="Movie lookup by Title")
@command.argument("message", pass_raw=True, required=True) @command.argument("message", pass_raw=True, required=True)

View file

@ -88,14 +88,13 @@ class MoviePopular(TmdbApi):
self.list = [] self.list = []
self.length = 0 self.length = 0
def query(self) -> int: async def query(self) -> int:
result = self.request('/movie/popular') result = await self.request('/movie/popular')
self.length = result['total_results'] self.length = result['total_results']
self.list = result['results'] self.list = result['results']
return self.length return self.length
def getListHtml(self, length: int = None) -> str: def getListHtml(self, length: int = None) -> str:
self.query()
html = "" html = ""
if length: if length:
loop = length loop = length
@ -106,7 +105,6 @@ class MoviePopular(TmdbApi):
return html return html
def getListText(self, length: int = None) -> str: def getListText(self, length: int = None) -> str:
self.query()
text = "" text = ""
if length: if length:
loop = length loop = length