Skip to content

Commit

Permalink
[630-152289-152456] (#99)
Browse files Browse the repository at this point in the history
Co-authored-by: uNickz <[email protected]>
Co-authored-by: KurimuzonAkuma <[email protected]>
  • Loading branch information
3 people authored Oct 14, 2024
1 parent f0da2e6 commit 060ab37
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 20 deletions.
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/send_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ async def progress(current, total):
try:
if isinstance(animation, str):
if os.path.isfile(animation):
thumb = await self.save_file(thumb)
file = await self.save_file(animation, progress=progress, progress_args=progress_args)
thumb = await self.save_file(thumb)
media = raw.types.InputMediaUploadedDocument(
mime_type=self.guess_mime_type(animation) or "video/mp4",
file=file,
Expand Down Expand Up @@ -250,8 +250,8 @@ async def progress(current, total):
ttl_seconds=ttl_seconds
)
else:
thumb = await self.save_file(thumb)
file = await self.save_file(animation, progress=progress, progress_args=progress_args)
thumb = await self.save_file(thumb)
media = raw.types.InputMediaUploadedDocument(
mime_type=self.guess_mime_type(file_name or animation.name) or "video/mp4",
file=file,
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/send_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ async def progress(current, total):
if isinstance(audio, str):
if os.path.isfile(audio):
mime_type = utils.fix_up_voice_audio_uri(self, audio, 1)
thumb = await self.save_file(thumb)
file = await self.save_file(audio, progress=progress, progress_args=progress_args)
thumb = await self.save_file(thumb)
media = raw.types.InputMediaUploadedDocument(
mime_type=mime_type,
file=file,
Expand All @@ -224,8 +224,8 @@ async def progress(current, total):
media = utils.get_input_media_from_file_id(audio, FileType.AUDIO)
else:
mime_type = utils.fix_up_voice_audio_uri(self, file_name or audio.name, 1)
thumb = await self.save_file(thumb)
file = await self.save_file(audio, progress=progress, progress_args=progress_args)
thumb = await self.save_file(thumb)
media = raw.types.InputMediaUploadedDocument(
mime_type=mime_type,
file=file,
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/send_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ async def progress(current, total):
try:
if isinstance(document, str):
if os.path.isfile(document):
thumb = await self.save_file(thumb)
file = await self.save_file(document, progress=progress, progress_args=progress_args)
thumb = await self.save_file(thumb)
media = raw.types.InputMediaUploadedDocument(
mime_type=self.guess_mime_type(document) or "application/zip",
file=file,
Expand All @@ -220,8 +220,8 @@ async def progress(current, total):
else:
media = utils.get_input_media_from_file_id(document, FileType.DOCUMENT)
else:
thumb = await self.save_file(thumb)
file = await self.save_file(document, progress=progress, progress_args=progress_args)
thumb = await self.save_file(thumb)
media = raw.types.InputMediaUploadedDocument(
mime_type=self.guess_mime_type(file_name or document.name) or "application/zip",
file=file,
Expand Down
12 changes: 6 additions & 6 deletions pyrogram/methods/messages/send_media_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ async def send_media_group(
w=i.width,
h=i.height
),
raw.types.DocumentAttributeFilename(file_name=os.path.basename(i.media))
raw.types.DocumentAttributeFilename(file_name=i.file_name or os.path.basename(i.media))
]
)
)
Expand Down Expand Up @@ -263,7 +263,7 @@ async def send_media_group(
w=i.width,
h=i.height
),
raw.types.DocumentAttributeFilename(file_name=getattr(i.media, "name", "video.mp4"))
raw.types.DocumentAttributeFilename(file_name=i.file_name or getattr(i.media, "name", "video.mp4"))
]
)
)
Expand Down Expand Up @@ -295,7 +295,7 @@ async def send_media_group(
performer=i.performer,
title=i.title
),
raw.types.DocumentAttributeFilename(file_name=os.path.basename(i.media))
raw.types.DocumentAttributeFilename(file_name=i.file_name or os.path.basename(i.media))
]
)
)
Expand Down Expand Up @@ -343,7 +343,7 @@ async def send_media_group(
performer=i.performer,
title=i.title
),
raw.types.DocumentAttributeFilename(file_name=getattr(i.media, "name", "audio.mp3"))
raw.types.DocumentAttributeFilename(file_name=i.file_name or getattr(i.media, "name", "audio.mp3"))
]
)
)
Expand All @@ -368,7 +368,7 @@ async def send_media_group(
file=await self.save_file(i.media),
thumb=await self.save_file(i.thumb),
attributes=[
raw.types.DocumentAttributeFilename(file_name=os.path.basename(i.media))
raw.types.DocumentAttributeFilename(file_name=i.file_name or os.path.basename(i.media))
]
# TODO
)
Expand Down Expand Up @@ -414,7 +414,7 @@ async def send_media_group(
file=await self.save_file(i.media),
thumb=await self.save_file(i.thumb),
attributes=[
raw.types.DocumentAttributeFilename(file_name=getattr(i.media, "name", "file.zip"))
raw.types.DocumentAttributeFilename(file_name=i.file_name or getattr(i.media, "name", "file.zip"))
]
)
)
Expand Down
12 changes: 8 additions & 4 deletions pyrogram/methods/messages/send_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ async def send_video(
ttl_seconds: int = None,
view_once: bool = None,
file_name: str = None,
mime_type: str = None,
schedule_date: datetime = None,
reply_to_message_id: int = None,
progress: Callable = None,
Expand Down Expand Up @@ -151,6 +152,9 @@ async def send_video(
file_name (``str``, *optional*):
File name of the video sent.
Defaults to file's path basename.
mime_type (``str``, *optional*):
no docs!
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.
Expand Down Expand Up @@ -222,10 +226,10 @@ async def progress(current, total):
try:
if isinstance(video, str):
if os.path.isfile(video):
thumb = await self.save_file(thumb)
file = await self.save_file(video, progress=progress, progress_args=progress_args)
thumb = await self.save_file(thumb)
media = raw.types.InputMediaUploadedDocument(
mime_type=self.guess_mime_type(video) or "video/mp4",
mime_type=self.guess_mime_type(video) or "video/mp4" if mime_type is None else mime_type,
file=file,
ttl_seconds=ttl_seconds,
nosound_video=True,
Expand Down Expand Up @@ -255,10 +259,10 @@ async def progress(current, total):
has_spoiler=has_spoiler
)
else:
thumb = await self.save_file(thumb)
file = await self.save_file(video, progress=progress, progress_args=progress_args)
thumb = await self.save_file(thumb)
media = raw.types.InputMediaUploadedDocument(
mime_type=self.guess_mime_type(file_name or video.name) or "video/mp4",
mime_type=self.guess_mime_type(file_name or video.name) or "video/mp4" if mime_type is None else mime_type,
file=file,
ttl_seconds=ttl_seconds,
spoiler=has_spoiler,
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/send_video_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ async def send_video_note(
try:
if isinstance(video_note, str):
if os.path.isfile(video_note):
thumb = await self.save_file(thumb)
file = await self.save_file(video_note, progress=progress, progress_args=progress_args)
thumb = await self.save_file(thumb)
media = raw.types.InputMediaUploadedDocument(
mime_type=self.guess_mime_type(video_note) or "video/mp4",
file=file,
Expand All @@ -217,8 +217,8 @@ async def send_video_note(
ttl_seconds=ttl_seconds
)
else:
thumb = await self.save_file(thumb)
file = await self.save_file(video_note, progress=progress, progress_args=progress_args)
thumb = await self.save_file(thumb)
media = raw.types.InputMediaUploadedDocument(
mime_type=self.guess_mime_type(video_note.name) or "video/mp4",
file=file,
Expand Down
8 changes: 7 additions & 1 deletion pyrogram/types/input_media/input_media_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ class InputMediaAudio(InputMedia):
title (``str``, *optional*):
Title of the audio
file_name (``str``, *optional*):
File name of the audio sent.
Defaults to file's path basename.
"""

def __init__(
Expand All @@ -72,11 +76,13 @@ def __init__(
caption_entities: List[MessageEntity] = None,
duration: int = 0,
performer: str = "",
title: str = ""
title: str = "",
file_name: str = None
):
super().__init__(media, caption, parse_mode, caption_entities)

self.thumb = thumb
self.duration = duration
self.performer = performer
self.title = title
self.file_name = file_name
8 changes: 7 additions & 1 deletion pyrogram/types/input_media/input_media_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ class InputMediaDocument(InputMedia):
caption_entities (List of :obj:`~pyrogram.types.MessageEntity`):
List of special entities that appear in the caption, which can be specified instead of *parse_mode*.
file_name (``str``, *optional*):
File name of the document sent.
Defaults to file's path basename.
"""

def __init__(
Expand All @@ -58,8 +62,10 @@ def __init__(
thumb: str = None,
caption: str = "",
parse_mode: Optional["enums.ParseMode"] = None,
caption_entities: List[MessageEntity] = None
caption_entities: List[MessageEntity] = None,
file_name: str = None
):
super().__init__(media, caption, parse_mode, caption_entities)

self.thumb = thumb
self.file_name = file_name
6 changes: 6 additions & 0 deletions pyrogram/types/input_media/input_media_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ class InputMediaVideo(InputMedia):
duration (``int``, *optional*):
Video duration.
file_name (``str``, *optional*):
File name of the video sent.
Defaults to file's path basename.
supports_streaming (``bool``, *optional*):
Pass True, if the uploaded video is suitable for streaming.
Expand All @@ -86,6 +90,7 @@ def __init__(
width: int = 0,
height: int = 0,
duration: int = 0,
file_name: str = None,
supports_streaming: bool = True,
has_spoiler: bool = None,
disable_content_type_detection: bool = None,
Expand All @@ -97,6 +102,7 @@ def __init__(
self.width = width
self.height = height
self.duration = duration
self.file_name = file_name
self.supports_streaming = supports_streaming
self.has_spoiler = has_spoiler
self.disable_content_type_detection = disable_content_type_detection
5 changes: 5 additions & 0 deletions pyrogram/types/messages_and_media/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -3335,6 +3335,7 @@ async def reply_video(
ttl_seconds: int = None,
view_once: bool = None,
file_name: str = None,
mime_type: str = None,
schedule_date: datetime = None,
reply_to_message_id: int = None,
progress: Callable = None,
Expand Down Expand Up @@ -3431,6 +3432,9 @@ async def reply_video(
File name of the video sent.
Defaults to file's path basename.
mime_type (``str``, *optional*):
no docs!
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.
Expand Down Expand Up @@ -3495,6 +3499,7 @@ async def reply_video(
ttl_seconds=ttl_seconds,
view_once=view_once,
file_name=file_name,
mime_type=mime_type,
schedule_date=schedule_date,
reply_to_message_id=reply_to_message_id,
progress=progress,
Expand Down

0 comments on commit 060ab37

Please sign in to comment.