Added mime type to poster message. This might address #10 but needs to be verified (not reproduceable).
This commit is contained in:
parent
94baaf9296
commit
92f89dc9a8
|
@ -67,9 +67,9 @@ class TestTmdbMethods(unittest.TestCase):
|
||||||
|
|
||||||
def test_search_year(self):
|
def test_search_year(self):
|
||||||
movie = Movie()
|
movie = Movie()
|
||||||
id = movie.search_title('Dune')
|
id = movie.search_title('Dune', 1984)
|
||||||
self.assertEqual(id, 841)
|
self.assertEqual(id, 841)
|
||||||
id = movie.search_title('Dune', 2020)
|
id = movie.search_title('Dune')
|
||||||
self.assertEqual(id, 438631)
|
self.assertEqual(id, 438631)
|
||||||
|
|
||||||
def test_split_year(self):
|
def test_split_year(self):
|
||||||
|
@ -106,5 +106,10 @@ class TestTmdbMethods(unittest.TestCase):
|
||||||
#self.assertEqual('Tom Cavanagh', movie.cast[0])
|
#self.assertEqual('Tom Cavanagh', movie.cast[0])
|
||||||
self.assertEqual('Carlos Valdes', movie.cast[2])
|
self.assertEqual('Carlos Valdes', movie.cast[2])
|
||||||
|
|
||||||
|
def test_poster_path(self):
|
||||||
|
movie = Movie()
|
||||||
|
id = movie.search_title('Dune')
|
||||||
|
self.assertEqual(movie.poster_url, "http://image.tmdb.org/t/p/w92/9HNZTw2D3cM1yA08FF5SeWEO9eX.jpg")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
16
tmdb/tmdb.py
16
tmdb/tmdb.py
|
@ -16,7 +16,7 @@ along with tmdb-bot. If not, see <https://www.gnu.org/licenses/>.
|
||||||
from html import escape
|
from html import escape
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from mautrix.types import TextMessageEventContent, MediaMessageEventContent, MessageType, Format
|
from mautrix.types import TextMessageEventContent, MediaMessageEventContent, MessageType, Format, ImageInfo
|
||||||
|
|
||||||
from maubot import Plugin, MessageEvent
|
from maubot import Plugin, MessageEvent
|
||||||
from maubot.handlers import command
|
from maubot.handlers import command
|
||||||
|
@ -74,12 +74,14 @@ class TmdbBot(Plugin):
|
||||||
await evt.respond(content)
|
await evt.respond(content)
|
||||||
|
|
||||||
async def send_image(self, evt: MessageEvent, title, image) -> None:
|
async def send_image(self, evt: MessageEvent, title, image) -> None:
|
||||||
mxc_uri = await self.client.upload_media(image)
|
if image:
|
||||||
content = MediaMessageEventContent(
|
mxc_uri = await self.client.upload_media(image)
|
||||||
msgtype=MessageType.IMAGE,
|
content = MediaMessageEventContent(
|
||||||
body=f"Image {title}",
|
msgtype=MessageType.IMAGE,
|
||||||
url=f"{mxc_uri}")
|
body=f"Image {title}",
|
||||||
await evt.respond(content)
|
url=f"{mxc_uri}",
|
||||||
|
info=ImageInfo(mimetype='image/jpg'))
|
||||||
|
await evt.respond(content)
|
||||||
|
|
||||||
def construct_html_message(self, movie, overview_length = 200, cast_length = 3) -> str:
|
def construct_html_message(self, movie, overview_length = 200, cast_length = 3) -> str:
|
||||||
if len(movie.overview) > overview_length:
|
if len(movie.overview) > overview_length:
|
||||||
|
|
Loading…
Reference in a new issue