From 483372284ceab710a0969bfcbf9797c5e393a26e Mon Sep 17 00:00:00 2001
From: lomion
{cast}
#taken from www.themoviedb.org
""" - async def send_html_message(self, evt: MessageEvent, text_message, html_message) -> None: + async def send_html_message(self, evt: MessageEvent, text_message: str, html_message: str) -> None: content = TextMessageEventContent( msgtype=MessageType.TEXT, format=Format.HTML, body=f"{text_message}", @@ -90,6 +90,7 @@ class TmdbBot(Plugin): async def send_help(self, evt: MessageEvent) -> None: html = """Use !tmdb id movie {tmdb id} to get movie detail for tmdb-id.
Use !tmdb movie {title} [y:{release year}] to get movie detail based on the given title.
+Use !tmdb popular to get most popular movies.
Use !tmdb language {language} to set your prefered language.
Use !tmdb poster_size [{size}] to set your prefered poster size. With empty {size} all available sizes are listed.
Use !tmdb tvshow {title} to get detail about a tv show based on the given title.
""" @@ -147,21 +148,13 @@ class TmdbBot(Plugin): async def command_movie_id(self, evt: MessageEvent, message: str = "") -> None: await self.movie_id(evt, message) - async def movie_search(self, evt: MessageEvent, message: str = "") -> None: - movie = Movie() - self.poster_size(evt, movie) + async def movie_popular(self, evt: MessageEvent, message: str = "") -> None: + popular = MoviePopular() language = self.db.get_language(evt.sender) if language: - movie.set_language(language) - title, year = self.split_title_year(message) - movie.search_title(title, year) - if movie.valid: - await self.send_movie_info(evt, movie) - else: - content = TextMessageEventContent( - msgtype=MessageType.NOTICE, format=Format.HTML, - body="No movie found!") - await evt.respond(content) + popular.set_language(language) + length = 5 + await self.send_html_message(evt, popular.getListText(length), popular.getListHtml(length)) @command.new("movie-search", help="Movie lookup by Title") @command.argument("message", pass_raw=True, required=True) @@ -220,6 +213,22 @@ class TmdbBot(Plugin): async def command_tvshow_search(self, evt: MessageEvent, message: str = "") -> None: await self.tvshow_search(evt, message) + async def movie_search(self, evt: MessageEvent, message: str = "") -> None: + movie = Movie() + self.poster_size(evt, movie) + language = self.db.get_language(evt.sender) + if language: + movie.set_language(language) + title, year = self.split_title_year(message) + movie.search_title(title, year) + if movie.valid: + await self.send_movie_info(evt, movie) + else: + content = TextMessageEventContent( + msgtype=MessageType.NOTICE, format=Format.HTML, + body="No movie found!") + await evt.respond(content) + @command.new("tmdb", help="TMDB Bot") @command.argument("message", pass_raw=True, required=True) async def command_dispatcher(self, evt: MessageEvent, message: str = "") -> None: @@ -231,6 +240,8 @@ class TmdbBot(Plugin): await self.send_help(evt) elif command.lower() == 'movie': await self.movie_search(evt, parameters) + elif command.lower() == 'popular': + await self.movie_popular(evt, parameters) elif command.lower() == 'language': await self.movie_language(evt, parameters) elif command.lower() == 'poster_size': diff --git a/tmdb/tmdb_api.py b/tmdb/tmdb_api.py index 6197ac5..f57ccac 100644 --- a/tmdb/tmdb_api.py +++ b/tmdb/tmdb_api.py @@ -14,6 +14,7 @@ You should have received a copy of the GNU Affero General Public License along with tmdb-bot. If not, see