mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-11-14 13:00:38 +00:00
Add supports_streaming to send_file and update docs/errors
This commit is contained in:
@@ -33,7 +33,7 @@ class UploadMethods(ButtonMethods, MessageParseMethods, UserMethods):
|
||||
progress_callback=None, reply_to=None, attributes=None,
|
||||
thumb=None, allow_cache=True, parse_mode=(),
|
||||
voice_note=False, video_note=False, buttons=None, silent=None,
|
||||
**kwargs):
|
||||
supports_streaming=False, **kwargs):
|
||||
"""
|
||||
Sends a file to the specified entity.
|
||||
|
||||
@@ -119,6 +119,13 @@ class UploadMethods(ButtonMethods, MessageParseMethods, UserMethods):
|
||||
channel or not. Defaults to ``False``, which means it will
|
||||
notify them. Set it to ``True`` to alter this behaviour.
|
||||
|
||||
supports_streaming (`bool`, optional):
|
||||
Whether the sent video supports streaming or not. Note that
|
||||
Telegram only recognizes as streamable some formats like MP4,
|
||||
and others like AVI or MKV will not work. You should convert
|
||||
these to MP4 before sending if you want them to be streamable.
|
||||
Unsupported formats will result in ``VideoContentTypeError``.
|
||||
|
||||
Notes:
|
||||
If the ``hachoir3`` package (``hachoir`` module) is installed,
|
||||
it will be used to determine metadata from audio and video files.
|
||||
@@ -161,6 +168,7 @@ class UploadMethods(ButtonMethods, MessageParseMethods, UserMethods):
|
||||
progress_callback=progress_callback, reply_to=reply_to,
|
||||
attributes=attributes, thumb=thumb, voice_note=voice_note,
|
||||
video_note=video_note, buttons=buttons, silent=silent,
|
||||
supports_streaming=supports_streaming,
|
||||
**kwargs
|
||||
))
|
||||
|
||||
@@ -181,7 +189,8 @@ class UploadMethods(ButtonMethods, MessageParseMethods, UserMethods):
|
||||
file, force_document=force_document,
|
||||
progress_callback=progress_callback,
|
||||
attributes=attributes, allow_cache=allow_cache, thumb=thumb,
|
||||
voice_note=voice_note, video_note=video_note
|
||||
voice_note=voice_note, video_note=video_note,
|
||||
supports_streaming=supports_streaming
|
||||
)
|
||||
|
||||
markup = self.build_reply_markup(buttons)
|
||||
@@ -389,7 +398,8 @@ class UploadMethods(ButtonMethods, MessageParseMethods, UserMethods):
|
||||
async def _file_to_media(
|
||||
self, file, force_document=False,
|
||||
progress_callback=None, attributes=None, thumb=None,
|
||||
allow_cache=True, voice_note=False, video_note=False):
|
||||
allow_cache=True, voice_note=False, video_note=False,
|
||||
supports_streaming=False):
|
||||
if not file:
|
||||
return None, None
|
||||
|
||||
@@ -447,7 +457,8 @@ class UploadMethods(ButtonMethods, MessageParseMethods, UserMethods):
|
||||
attributes=attributes,
|
||||
force_document=force_document,
|
||||
voice_note=voice_note,
|
||||
video_note=video_note
|
||||
video_note=video_note,
|
||||
supports_streaming=supports_streaming
|
||||
)
|
||||
|
||||
input_kw = {}
|
||||
|
||||
@@ -463,7 +463,8 @@ def get_message_id(message):
|
||||
|
||||
|
||||
def get_attributes(file, *, attributes=None, mime_type=None,
|
||||
force_document=False, voice_note=False, video_note=False):
|
||||
force_document=False, voice_note=False, video_note=False,
|
||||
supports_streaming=False):
|
||||
"""
|
||||
Get a list of attributes for the given file and
|
||||
the mime type as a tuple ([attribute], mime_type).
|
||||
@@ -496,11 +497,13 @@ def get_attributes(file, *, attributes=None, mime_type=None,
|
||||
w=m.get('width') if m.has('width') else 0,
|
||||
h=m.get('height') if m.has('height') else 0,
|
||||
duration=int(m.get('duration').seconds
|
||||
if m.has('duration') else 0)
|
||||
if m.has('duration') else 0),
|
||||
supports_streaming=supports_streaming
|
||||
)
|
||||
else:
|
||||
doc = types.DocumentAttributeVideo(
|
||||
0, 1, 1, round_message=video_note)
|
||||
0, 1, 1, round_message=video_note,
|
||||
supports_streaming=supports_streaming)
|
||||
|
||||
attr_dict[types.DocumentAttributeVideo] = doc
|
||||
|
||||
|
||||
Reference in New Issue
Block a user