Merge branch 'develop' of codeberg.org:lomion/tmdb-bot into develop
This commit is contained in:
commit
41180653ac
|
@ -107,6 +107,11 @@ class TestTmdbMethods(unittest.TestCase):
|
|||
movie.search_title('The Flash')
|
||||
#self.assertEqual('Tom Cavanagh', movie.cast[0])
|
||||
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__':
|
||||
unittest.main()
|
||||
|
|
17
tmdb/tmdb.py
17
tmdb/tmdb.py
|
@ -16,7 +16,7 @@ along with tmdb-bot. If not, see <https://www.gnu.org/licenses/>.
|
|||
from html import escape
|
||||
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.handlers import command
|
||||
|
@ -100,12 +100,15 @@ class TmdbBot(Plugin):
|
|||
await evt.respond(content)
|
||||
|
||||
async def send_image(self, evt: MessageEvent, title, image) -> None:
|
||||
mxc_uri = await self.client.upload_media(image)
|
||||
content = MediaMessageEventContent(
|
||||
msgtype=MessageType.IMAGE,
|
||||
body=f"Image {title}",
|
||||
url=f"{mxc_uri}")
|
||||
await evt.respond(content)
|
||||
if image:
|
||||
mxc_uri = await self.client.upload_media(image, mime_type='image/jpg')
|
||||
content = MediaMessageEventContent(
|
||||
msgtype=MessageType.IMAGE,
|
||||
body=f"Image {title}",
|
||||
url=f"{mxc_uri}",
|
||||
info=ImageInfo(mimetype='image/jpg'))
|
||||
await evt.respond(content)
|
||||
#await self.client.send_image(evt.room_id, url=mxc_uri, info=ImageInfo(mimetype='image/jpg'))
|
||||
|
||||
def split_title_year(self, message : str) -> (str, int):
|
||||
m = re.search(r'^(.*) (y:\d\d\d\d)', message)
|
||||
|
|
Loading…
Reference in a new issue