2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-28 21:07:59 +00:00

Fix messed up variable names

This commit is contained in:
Dan 2020-11-28 17:37:39 +01:00
parent 90cee1ea89
commit 4f197855f4

View File

@ -32,7 +32,7 @@ DEFAULT_DOWNLOAD_DIR = "downloads/"
class DownloadMedia(Scaffold): class DownloadMedia(Scaffold):
async def download_media( async def download_media(
self, self,
media: Union["types.Message", str], message: Union["types.Message", str],
file_name: str = DEFAULT_DOWNLOAD_DIR, file_name: str = DEFAULT_DOWNLOAD_DIR,
block: bool = True, block: bool = True,
progress: callable = None, progress: callable = None,
@ -41,7 +41,7 @@ class DownloadMedia(Scaffold):
"""Download the media from a message. """Download the media from a message.
Parameters: Parameters:
media (:obj:`~pyrogram.types.Message` | ``str``): message (:obj:`~pyrogram.types.Message` | ``str``):
Pass a Message containing the media, the media itself (message.audio, message.video, ...) or a file id Pass a Message containing the media, the media itself (message.audio, message.video, ...) or a file id
as string. as string.
@ -103,14 +103,16 @@ class DownloadMedia(Scaffold):
available_media = ("audio", "document", "photo", "sticker", "animation", "video", "voice", "video_note", available_media = ("audio", "document", "photo", "sticker", "animation", "video", "voice", "video_note",
"new_chat_photo") "new_chat_photo")
if isinstance(media, types.Message): if isinstance(message, types.Message):
for kind in available_media: for kind in available_media:
media = getattr(media, kind, None) media = getattr(message, kind, None)
if media is not None: if media is not None:
break break
else: else:
raise ValueError("This message doesn't contain any downloadable media") raise ValueError("This message doesn't contain any downloadable media")
else:
media = message
if isinstance(media, str): if isinstance(media, str):
file_id_str = media file_id_str = media