2
0
mirror of https://github.com/Nick80835/microbot synced 2025-08-31 06:26:04 +00:00

fix fast_telethon

This commit is contained in:
Nick80835
2020-07-29 08:21:04 -04:00
parent e8502dade2
commit 4ce2ba4faf
2 changed files with 6 additions and 9 deletions

View File

@@ -177,17 +177,14 @@ class ParallelTransferrer:
for i in range(1, connections)])
]
async def _create_upload_sender(self, file_id: int, part_count: int, big: bool, index: int,
stride: int) -> UploadSender:
return UploadSender(await self._create_sender(), file_id, part_count, big, index, stride,
loop=self.loop)
async def _create_upload_sender(self, file_id: int, part_count: int, big: bool, index: int, stride: int) -> UploadSender:
return UploadSender(await self._create_sender(), file_id, part_count, big, index, stride, loop=self.loop)
async def _create_sender(self) -> MTProtoSender:
dc = await self.client._get_dc(self.dc_id)
sender = MTProtoSender(self.auth_key, self.loop, loggers=self.client._log)
await sender.connect(self.client._connection(dc.ip_address, dc.port, dc.id,
loop=self.loop, loggers=self.client._log,
proxy=self.client._proxy))
sender = MTProtoSender(self.auth_key, loggers=self.client._log)
await sender.connect(self.client._connection(dc.ip_address, dc.port, dc.id, loggers=self.client._log, proxy=self.client._proxy))
if not self.auth_key:
log.debug(f"Exporting auth to DC {self.dc_id}")
auth = await self.client(ExportAuthorizationRequest(self.dc_id))

View File

@@ -211,7 +211,7 @@ async def youtube_cmd(event):
file_path = await download(video_stream.url, f"{event.chat_id}_{event.id}", ldr.aioclient)
end_time = time_ns()
time_taken_seconds = int((end_time - start_time) / 1000000000)
time_taken_seconds = int((end_time - start_time) / 1000000000) or 1
speed = int(int(file_size / 1000000) / time_taken_seconds)
await wait_msg.edit(f"Download complete, took {time_taken_seconds} seconds at ~{speed}MB/s")