Stop manually constructing InputFileLocation

This commit is contained in:
Lonami Exo 2018-05-06 11:46:04 +02:00
parent ee1e4e18f6
commit 2045e00563

View File

@ -72,7 +72,6 @@ from .tl.functions.channels import (
) )
from .tl.types import ( from .tl.types import (
DocumentAttributeAudio, DocumentAttributeFilename, DocumentAttributeAudio, DocumentAttributeFilename,
InputDocumentFileLocation, InputFileLocation,
InputMediaUploadedDocument, InputMediaUploadedPhoto, InputPeerEmpty, InputMediaUploadedDocument, InputMediaUploadedPhoto, InputPeerEmpty,
Message, MessageMediaContact, MessageMediaDocument, MessageMediaPhoto, Message, MessageMediaContact, MessageMediaDocument, MessageMediaPhoto,
InputUserSelf, UserProfilePhoto, ChatPhoto, UpdateMessageID, InputUserSelf, UserProfilePhoto, ChatPhoto, UpdateMessageID,
@ -1914,14 +1913,7 @@ class TelegramClient(TelegramBareClient):
) )
try: try:
self.download_file( self.download_file(loc, file)
InputFileLocation(
volume_id=loc.volume_id,
local_id=loc.local_id,
secret=loc.secret
),
file
)
return file return file
except LocationInvalidError: except LocationInvalidError:
# See issue #500, Android app fails as of v4.6.0 (1155). # See issue #500, Android app fails as of v4.6.0 (1155).
@ -2016,16 +2008,8 @@ class TelegramClient(TelegramBareClient):
f.close() f.close()
return file return file
self.download_file( self.download_file(photo.location, file, file_size=photo.size,
InputFileLocation( progress_callback=progress_callback)
volume_id=photo.location.volume_id,
local_id=photo.location.local_id,
secret=photo.location.secret
),
file,
file_size=photo.size,
progress_callback=progress_callback
)
return file return file
def _download_document(self, document, file, date, progress_callback): def _download_document(self, document, file, date, progress_callback):
@ -2061,16 +2045,8 @@ class TelegramClient(TelegramBareClient):
date=date, possible_names=possible_names date=date, possible_names=possible_names
) )
self.download_file( self.download_file(document, file, file_size=file_size,
InputDocumentFileLocation( progress_callback=progress_callback)
id=document.id,
access_hash=document.access_hash,
version=document.version
),
file,
file_size=file_size,
progress_callback=progress_callback
)
return file return file
@staticmethod @staticmethod
@ -2178,8 +2154,10 @@ class TelegramClient(TelegramBareClient):
Downloads the given input location to a file. Downloads the given input location to a file.
Args: Args:
input_location (:tl:`InputFileLocation`): input_location (:tl:`FileLocation` | :tl:`InputFileLocation`):
The file location from which the file will be downloaded. The file location from which the file will be downloaded.
See `telethon.utils.get_input_location` source for a complete
list of supported types.
file (`str` | `file`, optional): file (`str` | `file`, optional):
The output file path, directory, or stream-like object. The output file path, directory, or stream-like object.