Skip to content

Commit 8da9fc9

Browse files
committed
Add disable_content_type_detection to InputMediaDocument
1 parent 72b9b7c commit 8da9fc9

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

pyrogram/methods/messages/edit_inline_media.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ async def edit_inline_media(
114114
media = utils.get_input_media_from_file_id(media.media, FileType.PHOTO, has_spoiler=media.has_spoiler)
115115
elif isinstance(media, types.InputMediaVideo):
116116
show_caption_above_media.append(media.show_caption_above_media)
117+
# TODO: remove this duplicate code
117118
if is_uploaded_file:
118119
media = raw.types.InputMediaUploadedDocument(
119120
mime_type=(None if is_bytes_io else self.guess_mime_type(media.media)) or "video/mp4",
@@ -190,7 +191,7 @@ async def edit_inline_media(
190191
thumb=await self.save_file(media.thumb),
191192
file=await self.save_file(media.media),
192193
attributes=filename_attribute,
193-
force_file=True
194+
force_file=media.disable_content_type_detection
194195
)
195196
elif is_external_url:
196197
media = raw.types.InputMediaDocumentExternal(

pyrogram/methods/messages/edit_message_media.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ async def edit_message_media(
329329
thumb=await self.save_file(media.thumb),
330330
file=await self.save_file(media.media),
331331
attributes=filename_attribute,
332-
force_file=True
332+
force_file=media.disable_content_type_detection
333333
)
334334
)
335335
)

pyrogram/methods/messages/send_media_group.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,8 @@ async def send_media_group(
385385
thumb=await self.save_file(i.thumb),
386386
attributes=[
387387
raw.types.DocumentAttributeFilename(file_name=i.file_name or os.path.basename(i.media))
388-
]
389-
# TODO
388+
],
389+
force_file=True # if i.disable_content_type_detection else True
390390
)
391391
)
392392
)

pyrogram/types/input_media/input_media_document.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ class InputMediaDocument(InputMedia):
5252
caption_entities (List of :obj:`~pyrogram.types.MessageEntity`):
5353
List of special entities that appear in the caption, which can be specified instead of *parse_mode*.
5454
55+
disable_content_type_detection (``bool``, *optional*):
56+
Pass True, if the uploaded video is a video message with no sound.
57+
Disables automatic server-side content type detection for files uploaded using multipart/form-data. Always True, if the document is sent as part of an album.
58+
5559
file_name (``str``, *optional*):
5660
File name of the document sent.
5761
Defaults to file's path basename.
@@ -64,9 +68,11 @@ def __init__(
6468
caption: str = "",
6569
parse_mode: Optional["enums.ParseMode"] = None,
6670
caption_entities: list[MessageEntity] = None,
71+
disable_content_type_detection: bool = None,
6772
file_name: str = None
6873
):
6974
super().__init__(media, caption, parse_mode, caption_entities)
7075

7176
self.thumb = thumb
77+
self.disable_content_type_detection = disable_content_type_detection
7278
self.file_name = file_name

0 commit comments

Comments
 (0)