Returns the file location for the media file.
(file_id: FileId)
| 117 | |
| 118 | @staticmethod |
| 119 | async def get_location(file_id: FileId) -> Union[raw.types.InputPhotoFileLocation, |
| 120 | raw.types.InputDocumentFileLocation, |
| 121 | raw.types.InputPeerPhotoFileLocation,]: |
| 122 | """ |
| 123 | Returns the file location for the media file. |
| 124 | """ |
| 125 | file_type = file_id.file_type |
| 126 | |
| 127 | if file_type == FileType.CHAT_PHOTO: |
| 128 | if file_id.chat_id > 0: |
| 129 | peer = raw.types.InputPeerUser( |
| 130 | user_id=file_id.chat_id, access_hash=file_id.chat_access_hash |
| 131 | ) |
| 132 | else: |
| 133 | if file_id.chat_access_hash == 0: |
| 134 | peer = raw.types.InputPeerChat(chat_id=-file_id.chat_id) |
| 135 | else: |
| 136 | peer = raw.types.InputPeerChannel( |
| 137 | channel_id=utils.get_channel_id(file_id.chat_id), |
| 138 | access_hash=file_id.chat_access_hash, |
| 139 | ) |
| 140 | |
| 141 | location = raw.types.InputPeerPhotoFileLocation( |
| 142 | peer=peer, |
| 143 | volume_id=file_id.volume_id, |
| 144 | local_id=file_id.local_id, |
| 145 | big=file_id.thumbnail_source == ThumbnailSource.CHAT_PHOTO_BIG, |
| 146 | ) |
| 147 | elif file_type == FileType.PHOTO: |
| 148 | location = raw.types.InputPhotoFileLocation( |
| 149 | id=file_id.media_id, |
| 150 | access_hash=file_id.access_hash, |
| 151 | file_reference=file_id.file_reference, |
| 152 | thumb_size=file_id.thumbnail_size, |
| 153 | ) |
| 154 | else: |
| 155 | location = raw.types.InputDocumentFileLocation( |
| 156 | id=file_id.media_id, |
| 157 | access_hash=file_id.access_hash, |
| 158 | file_reference=file_id.file_reference, |
| 159 | thumb_size=file_id.thumbnail_size, |
| 160 | ) |
| 161 | return location |
| 162 | |
| 163 | async def yield_file( |
| 164 | self, |