diff --git a/app/routes.py b/app/routes.py index 63a29c2..5290eb6 100644 --- a/app/routes.py +++ b/app/routes.py @@ -65,7 +65,6 @@ async def setup_routes(app, handler): web.get(p + r"/{id:\d+}/download", h.download_get), web.head(p + r"/{id:\d+}/download", h.download_head), web.get(p + r"/{id:\d+}/thumbnail", h.thumbnail_get), - web.head(p + r"/{id:\d+}/thumbnail", h.thumbnail_head), ] routes += r log.debug(f"Index added for {chat.id} :: {chat.title} at /{alias_id}") @@ -81,7 +80,6 @@ async def setup_routes(app, handler): web.get(p + r"/{id:\d+}/download", h.download_get), web.head(p + r"/{id:\d+}/download", h.download_head), web.get(p + r"/{id:\d+}/thumbnail", h.thumbnail_get), - web.head(p + r"/{id:\d+}/thumbnail", h.thumbnail_head), ] routes += r log.debug(f"Index added for {chat.id} :: {chat.title} at /{alias_id}") diff --git a/app/telegram.py b/app/telegram.py index 6ebae15..db01cf5 100644 --- a/app/telegram.py +++ b/app/telegram.py @@ -2,7 +2,7 @@ import math import logging import asyncio -from telethon import TelegramClient +from telethon import TelegramClient, utils from telethon.sessions import StringSession class Client(TelegramClient): @@ -13,7 +13,8 @@ class Client(TelegramClient): async def download(self, file, file_size, offset, limit): - part_size = 1024 * 1024 + part_size_kb = utils.get_appropriated_part_size(file_size) + part_size = int(part_size_kb * 1024) first_part_cut = offset % part_size first_part = math.floor(offset / part_size) last_part_cut = part_size - (limit % part_size) @@ -21,7 +22,7 @@ class Client(TelegramClient): part_count = math.ceil(file_size / part_size) part = first_part try: - async for chunk in self.iter_download(file, offset=first_part * part_size, file_size=file_size, request_size=part_size): + async for chunk in self.iter_download(file, offset=first_part * part_size, request_size=part_size): if part == first_part: yield chunk[first_part_cut:] elif part == last_part: diff --git a/app/templates/info.html b/app/templates/info.html index afb8141..7bafd18 100644 --- a/app/templates/info.html +++ b/app/templates/info.html @@ -3,7 +3,7 @@
Video {{name}} could not be played!