Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sending no-sound videos in media group & sending media as videos by default in send_video #72

Merged
merged 2 commits into from
Jun 16, 2024

Conversation

Danipulok
Copy link

Requirements: we have video without sound named 'test.mp4'.

Without this PR, the following code fails:

async with client:
    media = [
        types.InputMediaVideo(media="test.mp4"),
        types.InputMediaVideo(media="test.mp4"),
    ]
    await client.send_media_group(chat_id="me", media=media)

with error:

Traceback (most recent call last):
  File "D:\Code\Personal\pyrogram\check.py", line 49, in <module>
    loop.run_until_complete(main())
  File "C:\Program Files\Python310\lib\asyncio\base_events.py", line 649, in run_until_complete
    return future.result()
  File "D:\Code\Personal\pyrogram\check.py", line 36, in main
    await client.send_media_group(
  File "D:\Code\Personal\pyrogram\src\pyrogram\methods\messages\send_media_group.py", line 455, in send_media_group
    r = await self.invoke(
  File "D:\Code\Personal\pyrogram\src\pyrogram\methods\advanced\invoke.py", line 94, in invoke
    r = await session.invoke(
  File "D:\Code\Personal\pyrogram\src\pyrogram\session\session.py", line 401, in invoke
    return await self.send(query, timeout=timeout)
  File "D:\Code\Personal\pyrogram\src\pyrogram\session\session.py", line 369, in send
    RPCError.raise_it(result, type(data))
  File "D:\Code\Personal\pyrogram\src\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")

Because GIF media (actually called 'animated') can not be sent in media group.
This PR changes it, so all valid files in media groups actually can be sent.

I also changed default no_sound for send_video, because currently it sends no-sound videos as GIFs, which is not expected.

@KurimuzonAkuma KurimuzonAkuma merged commit 4f5fc6b into KurimuzonAkuma:dev Jun 16, 2024
10 checks passed
@Danipulok Danipulok deleted the fix/multi-media-gif branch June 16, 2024 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants