From 16336d61f3e16e9330dac23a7b7c7cd0bf220fda Mon Sep 17 00:00:00 2001 From: lomion Date: Mon, 8 Nov 2021 22:28:34 +0100 Subject: [PATCH] Fixed MoviesPopular --- tmdb/tmdb.py | 6 +++++- tmdb/tmdb_api.py | 6 ++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tmdb/tmdb.py b/tmdb/tmdb.py index 5819753..a85f6c6 100644 --- a/tmdb/tmdb.py +++ b/tmdb/tmdb.py @@ -161,11 +161,15 @@ class TmdbBot(Plugin): async def movie_popular(self, evt: MessageEvent, message: str = "") -> None: popular = MoviePopular() + await popular.load_parameters() language = self.db.get_language(evt.sender) if language: popular.set_language(language) 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.argument("message", pass_raw=True, required=True) diff --git a/tmdb/tmdb_api.py b/tmdb/tmdb_api.py index 491fb8a..fe79364 100644 --- a/tmdb/tmdb_api.py +++ b/tmdb/tmdb_api.py @@ -88,14 +88,13 @@ class MoviePopular(TmdbApi): self.list = [] self.length = 0 - def query(self) -> int: - result = self.request('/movie/popular') + async def query(self) -> int: + result = await self.request('/movie/popular') self.length = result['total_results'] self.list = result['results'] return self.length def getListHtml(self, length: int = None) -> str: - self.query() html = "" if length: loop = length @@ -106,7 +105,6 @@ class MoviePopular(TmdbApi): return html def getListText(self, length: int = None) -> str: - self.query() text = "" if length: loop = length