remove heroku support

This commit is contained in:
odysseusmax 2020-09-19 16:58:02 +05:30
parent fcf5b580c6
commit d11a9f0f46
3 changed files with 20 additions and 17 deletions

View File

@ -68,8 +68,8 @@ This is the general format, change the values of corresponding fields as your re
> * `index_private` - Whether to index private chats. Only considered if `index_all` is set to `true`. Value should either be `true` or `false`.
> * `index_group` - Whether to index group chats. Only considered if `index_all` is set to `true`. Value should either be `true` or `false`.
> * `index_channel` - Whether to index channels. Only considered if `index_all` is set to `true`. Value should either be `true` or `false`.
> * `exclude_chats` - An array/list of chat id's that should be ignored for indexing. Only considered if `index_all` is set to `true`.
> * `include_chats` - An array/list of chat id's to index. Only considered if `index_all` is set to `false`.
> * `exclude_chats` - An array/list of chat id's that should be ignored for indexing. Only considered if `index_all` is set to `true`.
> * `include_chats` - An array/list of chat id's to index. Only considered if `index_all` is set to `false`.
* **Run app.**
@ -78,10 +78,6 @@ This is the general format, change the values of corresponding fields as your re
$ python3 -m app
```
* **Other quick methods.**
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/odysseusmax/tg-index/tree/master) [![Run on Repl.it](https://repl.it/badge/github/odysseusmax/tg-index)](https://repl.it/github/odysseusmax/tg-index)
## API

View File

@ -5,6 +5,7 @@ import logging
import aiohttp_jinja2
import jinja2
from aiohttp import web
from aiohttp_basicauth import BasicAuthMiddleware
from .telegram import Client
from .routes import setup_routes

View File

@ -60,8 +60,7 @@ class Views:
async def _index(self, req, api=False):
alias_pos = 2 if api else 1
alias_id = req.match_info['chat'] #req.rel_url.path.split('/')[alias_pos]
alias_id = req.match_info['chat']
chat = [i for i in chat_ids if i['alias_id'] == alias_id][0]
chat_id = chat['chat_id']
chat_name = chat['title']
@ -101,7 +100,7 @@ class Views:
media=True,
thumbnail=f"/{alias_id}/{m.id}/thumbnail",
mime_type=m.file.mime_type,
insight = get_file_name(m)[:100],
insight = get_file_name(m),
date = str(m.date),
size=m.file.size,
human_size=get_human_size(m.file.size),
@ -158,17 +157,16 @@ class Views:
async def api_info(self, req):
data = await self._info(req, True)
data = await self._info(req)
if not data['found']:
return web.Response(status=404, text="404: Not Found")
return web.json_response(data)
async def _info(self, req, api=False):
async def _info(self, req):
file_id = int(req.match_info["id"])
alias_pos = 2 if api else 1
alias_id = req.match_info['chat'] #req.rel_url.path.split('/')[alias_pos]
alias_id = req.match_info['chat']
chat = [i for i in chat_ids if i['alias_id'] == alias_id][0]
chat_id = chat['chat_id']
try:
@ -249,7 +247,7 @@ class Views:
async def logo(self, req):
alias_id = req.match_info['chat'] # req.rel_url.path.split('/')[1]
alias_id = req.match_info['chat']
chat = [i for i in chat_ids if i['alias_id'] == alias_id][0]
chat_id = chat['chat_id']
chat_name = "Image not available"
@ -287,6 +285,10 @@ class Views:
r = web.Response(
status=200,
body=body,
headers={
"Content-Type": "image/jpeg",
"Content-Disposition": 'inline; filename="logo.jpg"'
}
)
#r.enable_chunked_encoding()
return r
@ -302,7 +304,7 @@ class Views:
async def thumbnail_get(self, req):
file_id = int(req.match_info["id"])
alias_id = req.match_info['chat'] #req.rel_url.path.split('/')[1]
alias_id = req.match_info['chat']
chat = [i for i in chat_ids if i['alias_id'] == alias_id][0]
chat_id = chat['chat_id']
try:
@ -352,14 +354,18 @@ class Views:
r = web.Response(
status=200,
body=body,
headers={
"Content-Type": "image/jpeg",
"Content-Disposition": 'inline; filename="thumbnail.jpg"'
}
)
r.enable_chunked_encoding()
#r.enable_chunked_encoding()
return r
async def handle_request(self, req, head=False):
file_id = int(req.match_info["id"])
alias_id = req.match_info['chat'] # req.rel_url.path.split('/')[1]
alias_id = req.match_info['chat']
chat = [i for i in chat_ids if i['alias_id'] == alias_id][0]
chat_id = chat['chat_id']