This commit is contained in:
odysseusmax 2020-12-12 22:01:21 +05:30
parent 2c0160b21e
commit 873c5ff361
4 changed files with 16 additions and 20 deletions

View File

@ -17,7 +17,4 @@
<header class="flex justify-between bg-red-600 text-white mb-2 p-4 w-full sticky top-0 shadow">
<a href="/" class="text-left text-xl lg:text-2xl xl:text-3xl"> Telegram Index </a>
{% if otg %}
<a title="On-The-Go Indexing" href="/otg" class="text-xl lg:text-2xl xl:text-3xl"> OTG Indexing </a>
{% endif %}
</header>

View File

@ -7,20 +7,17 @@
Download {{name}}
</h1>
<div class="mx-auto w-full p-2 md:flex ">
<div>
</div>
<div class="mx-auto w-full p-2 md:w-3/4 lg:w-2/5 p-2">
{% if media.image %}
<img class="mx-auto rounded" src="../{{file_id}}/thumbnail" alt="{{name}}">
<img class="mx-auto rounded" src="{{thumbnail}}" alt="{{name}}">
{% elif media.video %}
<div id="video-warning" class="mx-auto p-4 bg-gray-600 text-gray-300 rounded border text-center hidden break-words">
<p> Video {{name}} could not be played!</p>
</div>
<div id="my-video-wrapper">
<video id="my-video-player" class="mx-auto rounded" controls poster="../{{file_id}}/thumbnail">
<source src="../{{file_id}}/download" type="video/mp4" />
<video id="my-video-player" class="mx-auto rounded" controls poster="{{thumbnail}}">
<source src="{{download_url}}" type="video/mp4" />
</video>
</div>
@ -55,9 +52,9 @@
</div>
<div id="my-audio-wrapper">
<img class="mx-auto rounded w-full" src="../{{file_id}}/thumbnail" alt="{{name}}">
<img class="mx-auto rounded w-full" src="{{thumbnail}}" alt="{{name}}">
<audio class="mx-auto" controls muted>
<source src="../{{file_id}}/download" type="audio/mpeg" />
<source src="{{download_url}}" type="audio/mpeg" />
</audio>
</div>
<script>
@ -97,7 +94,7 @@
<div class="text-center text-white">
<a class="rounded p-3 bg-indigo-500 hover:bg-indigo-700 shadow-lg" href="../{{file_id}}/download">Download Now! ({{ human_size }})</a>
<a class="rounded p-3 bg-indigo-500 hover:bg-indigo-700 shadow-lg{% if block_downloads %} cursor-not-allowed disabled{% endif %}" download="{{name}}" href="{{download_url}}">Download Now! ({{ human_size }})</a>
</div>
{% else %}

View File

@ -21,7 +21,7 @@ class Download:
async def handle_request(self, req, head=False):
if block_downloads:
return web.Response(status=403, text="403: Forbiden")
return web.Response(status=403, text="403: Forbiden" if not head else None)
file_id = int(req.match_info["id"])
alias_id = req.match_info['chat']
@ -36,7 +36,7 @@ class Download:
if not message or not message.file:
log.debug(f"no result for {file_id} in {chat_id}")
return web.Response(status=410, text="410: Gone. Access to the target resource is no longer available!")
return web.Response(status=410, text="410: Gone. Access to the target resource is no longer available!" if not head else None)
media = message.media
size = message.file.size
@ -51,7 +51,7 @@ class Download:
except ValueError:
return web.Response(
status=416,
text="416: Range Not Satisfiable",
text="416: Range Not Satisfiable" if not head else None,
headers = {
"Content-Range": f"bytes */{size}"
}

View File

@ -6,6 +6,7 @@ from telethon.tl.custom import Message
from jinja2 import Markup
from app.util import get_file_name, get_human_size
from app.config import block_downloads
log = logging.getLogger(__name__)
@ -47,7 +48,7 @@ class InfoView:
'type':message.file.mime_type
}
if 'video/' in message.file.mime_type:
media['video'] : True
media['video'] = True
elif 'audio/' in message.file.mime_type:
media['audio'] = True
elif 'image/' in message.file.mime_type:
@ -68,8 +69,9 @@ class InfoView:
'title': f"Download | {file_name} | {human_file_size}",
'reply_btns': reply_btns,
'thumbnail': f"/{alias_id}/{file_id}/thumbnail",
'download_url': f"/{alias_id}/{file_id}/download",
'page_id': alias_id
'download_url': '#' if block_downloads else f"/{alias_id}/{file_id}/download",
'page_id': alias_id,
'block_downloads': block_downloads
}
elif message.message:
text = message.raw_text