|
|
|
@ -6,6 +6,7 @@ import yaml
|
|
|
|
|
from aiohttp import web |
|
|
|
|
from telethon import TelegramClient |
|
|
|
|
from telethon.utils import _get_file_info |
|
|
|
|
from telethon.client.downloads import _GenericDownloadIter |
|
|
|
|
|
|
|
|
|
with open('config.yaml') as file: |
|
|
|
|
config = yaml.safe_load(file) |
|
|
|
@ -61,7 +62,13 @@ async def handler(request):
|
|
|
|
|
if tmp_offset > size: |
|
|
|
|
tmp_offset -= size |
|
|
|
|
continue |
|
|
|
|
async for chunk in client._iter_download(i, offset=tmp_offset, msg_data=(chat_id, i.id)): |
|
|
|
|
stream = client._iter_download(i, offset=tmp_offset, request_size=131072, msg_data=(chat_id, i.id)) |
|
|
|
|
if isinstance(stream, _GenericDownloadIter): |
|
|
|
|
__load_next_chunk = stream._load_next_chunk |
|
|
|
|
def _load_next_chunk(mask=131071): |
|
|
|
|
return __load_next_chunk(mask=mask) |
|
|
|
|
stream._load_next_chunk = _load_next_chunk |
|
|
|
|
async for chunk in stream: |
|
|
|
|
yield chunk[:tmp_length] |
|
|
|
|
tmp_length -= len(chunk) |
|
|
|
|
if tmp_length < 1: |
|
|
|
|