mirror of
https://gitlab.com/octospacc/TelegramIndex-Fork.git
synced 2025-06-05 22:09:12 +02:00
add otg indexing support
This commit is contained in:
@ -29,9 +29,18 @@ def generate_alias_id(chat):
|
||||
async def setup_routes(app, handler):
|
||||
h = handler
|
||||
client = h.client
|
||||
p = r"/{chat:[^/]+}"
|
||||
routes = [
|
||||
web.get('/', h.home),
|
||||
web.get('/api', h.api_home),
|
||||
web.post('/otg', h.dynamic_view),
|
||||
web.get('/otg', h.otg_view),
|
||||
web.get(p, h.index),
|
||||
web.get(p + r"/logo", h.logo),
|
||||
web.get(p + r"/{id:\d+}/view", h.info),
|
||||
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.view(r'/{wildcard:.*}', h.wildcard)
|
||||
]
|
||||
index_all = index_settings['index_all']
|
||||
index_private = index_settings['index_private']
|
||||
@ -44,51 +53,25 @@ async def setup_routes(app, handler):
|
||||
alias_id = None
|
||||
if chat.id in exclude_chats:
|
||||
continue
|
||||
|
||||
|
||||
if chat.is_user:
|
||||
if index_private:
|
||||
alias_id = generate_alias_id(chat)
|
||||
elif chat.is_group:
|
||||
if index_group:
|
||||
alias_id = generate_alias_id(chat)
|
||||
else:
|
||||
elif chat.is_channel:
|
||||
if index_channel:
|
||||
alias_id = generate_alias_id(chat)
|
||||
|
||||
else:
|
||||
if index_group:
|
||||
alias_id = generate_alias_id(chat)
|
||||
|
||||
if not alias_id:
|
||||
continue
|
||||
|
||||
p = r"/{chat:" + alias_id + "}"
|
||||
p_api = '/api' + p
|
||||
r = [
|
||||
web.get(p, h.index),
|
||||
web.get(p_api, h.api_index),
|
||||
web.get(p + r"/logo", h.logo),
|
||||
web.get(p + r"/{id:\d+}/view", h.info),
|
||||
web.get(p_api + r"/{id:\d+}/view", h.api_info),
|
||||
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),
|
||||
]
|
||||
routes += r
|
||||
log.debug(f"Index added for {chat.id} :: {chat.title} at /{alias_id}")
|
||||
|
||||
else:
|
||||
for chat_id in include_chats:
|
||||
chat = await client.get_entity(chat_id)
|
||||
alias_id = generate_alias_id(chat)
|
||||
p = r"/{chat:" + alias_id + "}"
|
||||
p_api = '/api' + p
|
||||
r = [
|
||||
web.get(p, h.index),
|
||||
web.get(p_api, h.api_index),
|
||||
web.get(p + r"/logo", h.logo),
|
||||
web.get(p + r"/{id:\d+}/view", h.info),
|
||||
web.get(p_api + r"/{id:\d+}/view", h.api_info),
|
||||
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),
|
||||
]
|
||||
routes += r
|
||||
log.debug(f"Index added for {chat.id} :: {chat.title} at /{alias_id}")
|
||||
routes.append(web.view(r'/{wildcard:.*}', h.wildcard))
|
||||
|
||||
app.add_routes(routes)
|
||||
|
Reference in New Issue
Block a user