Skip to content

Commit 2034a78

Browse files
committed
Add set_profile_video method
1 parent 9a80570 commit 2034a78

3 files changed

Lines changed: 61 additions & 1 deletion

File tree

compiler/docs/compiler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ def get_title_list(s: str) -> list:
225225
get_profile_photos_count
226226
iter_profile_photos
227227
set_profile_photo
228+
set_profile_video
228229
delete_profile_photos
229230
update_username
230231
update_profile

pyrogram/client/methods/users/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from .get_users import GetUsers
2626
from .iter_profile_photos import IterProfilePhotos
2727
from .set_profile_photo import SetProfilePhoto
28+
from .set_profile_video import SetProfileVideo
2829
from .unblock_user import UnblockUser
2930
from .update_profile import UpdateProfile
3031
from .update_username import UpdateUsername
@@ -42,6 +43,7 @@ class Users(
4243
GetProfilePhotosCount,
4344
IterProfilePhotos,
4445
UnblockUser,
45-
UpdateProfile
46+
UpdateProfile,
47+
SetProfileVideo
4648
):
4749
pass
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Pyrogram - Telegram MTProto API Client Library for Python
2+
# Copyright (C) 2017-2020 Dan <https://github.com/delivrance>
3+
#
4+
# This file is part of Pyrogram.
5+
#
6+
# Pyrogram is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU Lesser General Public License as published
8+
# by the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# Pyrogram is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU Lesser General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Lesser General Public License
17+
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
18+
19+
from typing import Union, BinaryIO
20+
21+
from pyrogram.api import functions
22+
from ...ext import BaseClient
23+
24+
25+
class SetProfileVideo(BaseClient):
26+
def set_profile_video(
27+
self,
28+
video: Union[str, BinaryIO]
29+
) -> bool:
30+
"""Set a new profile video (H.264/MPEG-4 AVC video, max 5 seconds).
31+
32+
If you want to set a profile photo instead, use :meth:`~Client.set_profile_photo`
33+
34+
This method only works for Users.
35+
36+
Parameters:
37+
video (``str``):
38+
Profile video to set.
39+
Pass a file path as string to upload a new video that exists on your local machine or
40+
pass a binary file-like object with its attribute ".name" set for in-memory uploads.
41+
42+
Returns:
43+
``bool``: True on success.
44+
45+
Example:
46+
.. code-block:: python
47+
48+
app.set_profile_video("new_video.mp4")
49+
"""
50+
51+
return bool(
52+
self.send(
53+
functions.photos.UploadProfilePhoto(
54+
video=self.save_file(video)
55+
)
56+
)
57+
)

0 commit comments

Comments
 (0)