KurimuzonAkuma / pyrogram

Elegant, modern and asynchronous Telegram MTProto API framework in Python for users and bots
https://pyrogram.org
GNU Lesser General Public License v3.0
267 stars 72 forks source link

send_media_group() send video without sound run error #53

Open fivepe opened 2 months ago

fivepe commented 2 months ago

Checklist

Description

when use send_media_group() send send video without sound, it run error.

Steps to reproduce

Traceback (most recent call last): File "C:\demo\test\test.py", line 20, in app.send_media_group( File "C:\Users\HC\AppData\Local\Programs\Python\Python310\lib\site-packages\pyrogram\sync.py", line 66, in async_to_sync_wrap return loop.run_until_complete(coroutine) File "C:\Users\HC\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete return future.result() File "C:\Users\HC\AppData\Local\Programs\Python\Python310\lib\site-packages\pyrogram\methods\messages\send_media_group.py", line 450, in send_media_group r = await self.invoke( File "C:\Users\HC\AppData\Local\Programs\Python\Python310\lib\site-packages\pyrogram\methods\advanced\invoke.py", line 94, in invoke r = await session.invoke( File "C:\Users\HC\AppData\Local\Programs\Python\Python310\lib\site-packages\pyrogram\session\session.py", line 399, in invoke return await self.send(query, timeout=timeout) File "C:\Users\HC\AppData\Local\Programs\Python\Python310\lib\site-packages\pyrogram\session\session.py", line 367, in send RPCError.raise_it(result, type(data)) File "C:\Users\HC\AppData\Local\Programs\Python\Python310\lib\site-packages\pyrogram\errors\rpc_error.py", line 91, in raise_it raise getattr( pyrogram.errors.exceptions.bad_request_400.MediaEmpty: Telegram says: [400 MEDIA_EMPTY] - The media you tried to send is invalid (caused by "messages.SendMultiMedia")

Code example

app.send_media_group(
    xxxxxx,
    [
        InputMediaVideo("no sound.mp4", caption="video without sound"),
        InputMediaVideo("sound.mp4")
    ]
)

Logs

No response

SpEcHiDe commented 2 months ago

You have to use it like this

app.send_media_group(
    xxxxxx,
    [
        InputMediaVideo("no sound.mp4", caption="video without sound", no_sound=True),
        InputMediaVideo("sound.mp4")
    ]
)
fivepe commented 2 months ago

You have to use it like this

app.send_media_group(
    xxxxxx,
    [
        InputMediaVideo("no sound.mp4", caption="video without sound", no_sound=True),
        InputMediaVideo("sound.mp4")
    ]
)

Thanks, that's right. One suggestion is whether send_media_group() and send_video() can directly detect whether the incoming video has sound by themselves, and add no_sound=True by themselves. This will be more perfect and reduce many problems.