|
| 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