From 33cbeba02b03fe46e76669bf2b76d28f3e4323c5 Mon Sep 17 00:00:00 2001 From: Rayan fernandes <37145078+Rayanfer32@users.noreply.github.com> Date: Sun, 13 Jun 2021 21:48:42 +0530 Subject: [PATCH 01/15] =?UTF-8?q?=F0=9F=99=88=20ignore=20test=20.env?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 4f3eb8b..e7eafaa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ *.session -.env +*.env __pycache__/ venv/ tests/ From 42400c0036430e1fadc84142fe2cef6ad6189fc7 Mon Sep 17 00:00:00 2001 From: Rayan fernandes <37145078+Rayanfer32@users.noreply.github.com> Date: Fri, 29 Apr 2022 21:26:30 +0530 Subject: [PATCH 02/15] .venv ignored --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e7eafaa..73a5e33 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ logo/ app.json Procfile .vscode/ -.gitignore \ No newline at end of file +.gitignore +.venv/ \ No newline at end of file From f4bbb44b2c7eecc4f27ff0d32e8e6c1c18d895e7 Mon Sep 17 00:00:00 2001 From: Rayan fernandes <37145078+Rayanfer32@users.noreply.github.com> Date: Fri, 29 Apr 2022 21:39:52 +0530 Subject: [PATCH 03/15] =?UTF-8?q?=F0=9F=90=9B=20fix=20for=20windows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/info_view.py | 4 +++- run.py | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 run.py diff --git a/app/views/info_view.py b/app/views/info_view.py index 26b8c0a..060b1e6 100644 --- a/app/views/info_view.py +++ b/app/views/info_view.py @@ -5,7 +5,9 @@ from aiohttp import web from telethon.tl import types from telethon.tl.custom import Message -from jinja2 import Markup +from jinja2.utils import markupsafe + +Markup = markupsafe.Markup() from app.util import get_file_name, get_human_size from app.config import block_downloads diff --git a/run.py b/run.py new file mode 100644 index 0000000..fd82900 --- /dev/null +++ b/run.py @@ -0,0 +1,5 @@ +from dotenv import load_dotenv +import runpy +load_dotenv() +runpy.run_module('app') + From b4ed654f24d63d2c66f2cf53c882cfd2805f7db0 Mon Sep 17 00:00:00 2001 From: Rayan fernandes <37145078+Rayanfer32@users.noreply.github.com> Date: Fri, 29 Apr 2022 22:38:32 +0530 Subject: [PATCH 04/15] add eye saving purple theme --- app/templates/header.html | 10 +++++----- app/templates/home.html | 4 ++-- app/templates/index.html | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/templates/header.html b/app/templates/header.html index 1489435..32f6c8c 100644 --- a/app/templates/header.html +++ b/app/templates/header.html @@ -4,7 +4,7 @@ - + @@ -28,13 +28,13 @@ - + -
+
- Telegram index + Telegram index
- {% if authenticated %} diff --git a/app/templates/home.html b/app/templates/home.html index 6ddeb11..4275284 100644 --- a/app/templates/home.html +++ b/app/templates/home.html @@ -8,10 +8,10 @@

{% for chat in chats %} + class="justify-items-center min-h-full w-5/12 sm:w-1/4 md:w-1/5 lg:w-1/6 rounded p-2 text-center break-words shadow hover:shadow-md hover:bg-blue-100 dark:bg-gray-500 dark:hover:bg-gray-400"> -
{{chat.name}}
+
{{chat.name}}
{% endfor %} diff --git a/app/templates/index.html b/app/templates/index.html index 1307244..db75182 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -6,7 +6,7 @@ {% endblock %} -
+
{{name}} @@ -16,8 +16,8 @@
-
- +
@@ -47,14 +47,14 @@
+ class="text-sm items-center justify-center w-full min-h-full sm:w-2/5 md:w-1/4 lg:w-1/6 rounded m-2 shadow hover:shadow-lg dark:bg-purple-500"> {% if item.media %}
{{item.insight}}
- + {% if not block_downloads %} {{item.insight}}
{% endif %} -
{{item.file_id}}
+
{{item.file_id}}
From 241c4a34ed8ebb640e7168bedab21b08498de716 Mon Sep 17 00:00:00 2001 From: Rayan fernandes <37145078+Rayanfer32@users.noreply.github.com> Date: Fri, 29 Apr 2022 23:09:31 +0530 Subject: [PATCH 05/15] fix playlist download --- app/templates/index.html | 4 +--- app/templates/js/filesaver.min.js | 2 -- app/templates/js/playlist.js | 27 +++++++++++++++++++-------- app/views/index_view.py | 1 + 4 files changed, 21 insertions(+), 13 deletions(-) delete mode 100644 app/templates/js/filesaver.min.js diff --git a/app/templates/index.html b/app/templates/index.html index db75182..ce24cf4 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -1,8 +1,6 @@ {% include 'header.html' %} {% block javascript %} {% endblock %} @@ -80,7 +78,7 @@ - {% if authenticated %} diff --git a/app/templates/home.html b/app/templates/home.html index 4275284..3329ece 100644 --- a/app/templates/home.html +++ b/app/templates/home.html @@ -1,6 +1,6 @@ {% include 'header.html' %} -

+

Available Sources

@@ -11,7 +11,7 @@

class="justify-items-center min-h-full w-5/12 sm:w-1/4 md:w-1/5 lg:w-1/6 rounded p-2 text-center break-words shadow hover:shadow-md hover:bg-blue-100 dark:bg-gray-500 dark:hover:bg-gray-400"> -
{{chat.name}}
+
{{chat.name}}
{% endfor %} diff --git a/app/templates/index.html b/app/templates/index.html index ce24cf4..9e52a41 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -45,14 +45,14 @@
+ class="text-sm items-center justify-center w-full min-h-full sm:w-2/5 md:w-1/4 lg:w-1/6 rounded m-2 shadow hover:shadow-lg dark:bg-gray-500"> {% if item.media %}
{{item.insight}}
- + {% if not block_downloads %} {{item.insight}}
{% endif %} -
{{item.file_id}}
+
{{item.file_id}}

From 3752166a19542544e744fde00f4b86c5e6ebc53c Mon Sep 17 00:00:00 2001 From: Rayan fernandes <37145078+Rayanfer32@users.noreply.github.com> Date: Fri, 29 Apr 2022 23:36:22 +0530 Subject: [PATCH 07/15] fix dark mode --- app/templates/header.html | 10 +++++----- app/templates/home.html | 4 ++-- app/templates/index.html | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/templates/header.html b/app/templates/header.html index 32f6c8c..e5a6f63 100644 --- a/app/templates/header.html +++ b/app/templates/header.html @@ -16,9 +16,9 @@ } @@ -28,13 +28,13 @@ - + -
+
Telegram index
- {% if authenticated %} diff --git a/app/templates/home.html b/app/templates/home.html index 4275284..3329ece 100644 --- a/app/templates/home.html +++ b/app/templates/home.html @@ -1,6 +1,6 @@ {% include 'header.html' %} -

+

Available Sources

@@ -11,7 +11,7 @@

class="justify-items-center min-h-full w-5/12 sm:w-1/4 md:w-1/5 lg:w-1/6 rounded p-2 text-center break-words shadow hover:shadow-md hover:bg-blue-100 dark:bg-gray-500 dark:hover:bg-gray-400"> -
{{chat.name}}
+
{{chat.name}}
{% endfor %} diff --git a/app/templates/index.html b/app/templates/index.html index ce24cf4..9e52a41 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -45,14 +45,14 @@
+ class="text-sm items-center justify-center w-full min-h-full sm:w-2/5 md:w-1/4 lg:w-1/6 rounded m-2 shadow hover:shadow-lg dark:bg-gray-500"> {% if item.media %}
{{item.insight}}
- + {% if not block_downloads %} {{item.insight}}
{% endif %} -
{{item.file_id}}
+
{{item.file_id}}

From a65ecbe2292b9d04b9014b808ff38f281a77f795 Mon Sep 17 00:00:00 2001 From: Rayan fernandes <37145078+Rayanfer32@users.noreply.github.com> Date: Sat, 30 Apr 2022 11:47:27 +0530 Subject: [PATCH 08/15] add file icon --- app/config.py | 1 + app/icons/document-icon.png | Bin 0 -> 4152 bytes app/views/thumbnail_view.py | 6 +++--- 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 app/icons/document-icon.png diff --git a/app/config.py b/app/config.py index bf8fc53..168c240 100644 --- a/app/config.py +++ b/app/config.py @@ -49,6 +49,7 @@ logo_folder.mkdir(parents=True, exist_ok=True) username = os.environ.get("TGINDEX_USERNAME", "") password = os.environ.get("PASSWORD", "") +file_icon_path = "app/icons/document-icon.png" SHORT_URL_LEN = int(os.environ.get("SHORT_URL_LEN", 3)) authenticated = bool(username and password) SESSION_COOKIE_LIFETIME = int(os.environ.get("SESSION_COOKIE_LIFETIME") or "60") diff --git a/app/icons/document-icon.png b/app/icons/document-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce7c0333497651acc596a600ff546b8b3c7dd5d5 GIT binary patch literal 4152 zcmd5;c|4Ts9)I4qF-EqLlr=+^gy>Kt%MdxX>QGXmA;vB#TWF>usW_>WvV?Q82^taNgg;+E9#Y3FoQ^phCLRlO3-$!29*5mMaaI9tUY_=zZXOXw znmr8x5bd=xH{BiHOMlgO^gswyH(lCi*P-h(sw}bVp<~<;S<5ujm1VG96%%#az&nD` zY#QZ}?zXTRUrlv3y?$}^!Y}7VmBQ6lA4bVV512lF7_5Fz*Dgt==hd6}fX&KXDnoE( zEpxs_cJo-E^K7~uiOSqcqpJu2yTS7Zm&SYidjjl=rItIIUJ?=(mTL~I4_@b7FS<8u zX;sz_=~Zl&mfVv-{*oNp-GhtmH~0JqoTypy==sRf;T4uKlqC==ca5X9$jIa@nSonw1Jvu9iLvsj9-;T;@hBW{r;fJ; zx_(d0V?*Wu#_`8+pDwu8%42c8n7Ku*4CY~3nDBIfR8K^kgCQj##35tI>3sO56(%tz zI2fk|VOwY00@sxKoHVqoqpgv`LPLS*fs_7Q2pzB@9(5rJG|h4v>bN0k63DOHQe=LA zdmx5C4`PKP-ymG=RBtPXusq(+}Xe*3vj-3nFYj71DQi zfNvSW#!M#Z41lmt1f>y}R(QZ@voaZjBSArRxhRBO3xIAsDr#YfYC#5o=MZ2a3;>8Z zK*p>ca8Tu_z$gF|$=#RT!&msE_Fe+c;*e1y^=QYjX=ph#JNu6aa&S)tjp$osJ0I`oejFph(2}Z)#3kRd&K<;$MmkRGLjjH_t z#1jm}$R9kMQGn~&sFw>3syth`L>-6+@J`G-eNQdxR7pYmQ6HTCTcHN8P?p2V{CZ&x zOZCsRxDpIzO8o8g6z2yXDnnl!_pWb9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6A=G7doYU_gV2h{%iFkg9!Hz+^2nbYmOOY@)AQlQAqieV=Ia3kjd9w-EWpK#>{}ai=QrZuedTgQdw#i zAG{5EJ3Ha@;@4GBJ4y_@p+kRUlVBZMt{_qEsoKM;&V_}A9Ugj?)h8gQxTKx|`H6&J zh1o(?7--MYw88IUSa{%6mk#j5o}bT5Sh8BhDA`ns87;EJ-|gBAev`Z@%2^f>UJ_ds z@Jd@|m&PjjTaE>l)i0o?bSvV{*{vygsxD3AFN)+>Rdgi)d=YCdkrpt}77bbiPcCbw zZ{_dLXgQHyj6 web.Response: location = types.InputPhotoFileLocation if not thumbnails: - color = tuple([random.randint(0, 255) for i in range(3)]) - im = Image.new("RGB", (100, 100), color) + im = Image.open(file_icon_path) temp = io.BytesIO() im.save(temp, "PNG") body = temp.getvalue() From e4ba0901fa2aaf51e9978dc423d4c7aec06978ed Mon Sep 17 00:00:00 2001 From: Rayan fernandes <37145078+Rayanfer32@users.noreply.github.com> Date: Mon, 6 Jun 2022 12:44:04 +0530 Subject: [PATCH 09/15] =?UTF-8?q?=F0=9F=9A=91=20run=20safe=20for=20repl.it?= =?UTF-8?q?=20to=20prevent=20session=20expiration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements.txt | 1 + run.py | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 91feb57..6e9c7e8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,4 @@ cryptg pillow aiohttp_session[secure] python-dotenv +requests \ No newline at end of file diff --git a/run.py b/run.py index fd82900..94cbe12 100644 --- a/run.py +++ b/run.py @@ -1,5 +1,24 @@ -from dotenv import load_dotenv +import os import runpy +import requests +from dotenv import load_dotenv load_dotenv() -runpy.run_module('app') +def is_alive(): + repl_slug = os.environ.get("REPL_SLUG") + repl_owner = os.environ.get("REPL_OWNER") + resp = requests.get(f"https://{repl_slug}.{repl_owner}.repl.co") + return resp.ok + +def run_safe(): + "prevent session string from expiring due to two instances running" + if not is_alive(): + runpy.run_module('app') + else: + print("Server is already running...") + +def kill_server(): + kill_server_cmd = "pkill -9 -f 'python3 run.py'" + os.system(kill_server_cmd) + +run_safe() \ No newline at end of file From 72e5f1559326e638eb72d4f97375fdf17a4779f9 Mon Sep 17 00:00:00 2001 From: Rayan fernandes <37145078+Rayanfer32@users.noreply.github.com> Date: Mon, 6 Jun 2022 12:51:08 +0530 Subject: [PATCH 10/15] =?UTF-8?q?=F0=9F=94=A7=20repl.it=20config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .replit | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .replit diff --git a/.replit b/.replit new file mode 100644 index 0000000..c94c4da --- /dev/null +++ b/.replit @@ -0,0 +1,3 @@ +language="bash" +run="pip3 install -r requirements;python3 run.py" +#run="pip3 install -r requirements;python3 app/generate_session_string.py" From 316e8458c37a9a958356928915eb9a2f2e41a42f Mon Sep 17 00:00:00 2001 From: Rayan fernandes <37145078+Rayanfer32@users.noreply.github.com> Date: Mon, 6 Jun 2022 13:21:19 +0530 Subject: [PATCH 11/15] =?UTF-8?q?=F0=9F=90=9B=20=E2=9C=8F=EF=B8=8F=20timeo?= =?UTF-8?q?ut=20is=5Falive(),=20fix=20self.loop=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .replit | 4 ++-- app/main.py | 2 +- run.py | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.replit b/.replit index c94c4da..8f28b59 100644 --- a/.replit +++ b/.replit @@ -1,3 +1,3 @@ language="bash" -run="pip3 install -r requirements;python3 run.py" -#run="pip3 install -r requirements;python3 app/generate_session_string.py" +run="pip3 install -r requirements.txt;python3 run.py" +#run="pip3 install -r requirements.txt;python3 app/generate_session_string.py" diff --git a/app/main.py b/app/main.py index bf08b97..30ad69d 100644 --- a/app/main.py +++ b/app/main.py @@ -74,4 +74,4 @@ async def cleanup(self, server: web.Application): log.debug("telegram client disconnected!") def run(self): - web.run_app(self.server, host=host, port=port, loop=self.loop) + web.run_app(self.server, host=host, port=port) diff --git a/run.py b/run.py index 94cbe12..09126ea 100644 --- a/run.py +++ b/run.py @@ -7,12 +7,17 @@ def is_alive(): repl_slug = os.environ.get("REPL_SLUG") repl_owner = os.environ.get("REPL_OWNER") - resp = requests.get(f"https://{repl_slug}.{repl_owner}.repl.co") + try: + resp = requests.get(f"https://{repl_slug}.{repl_owner}.repl.co", timeout=15) + except Exception as e: + print("Server response wait timed out!") + return False return resp.ok def run_safe(): "prevent session string from expiring due to two instances running" if not is_alive(): + print("Starting a new instance...") runpy.run_module('app') else: print("Server is already running...") From 533ce3a3a1994cb31b1f9b175359dd33393992eb Mon Sep 17 00:00:00 2001 From: Rayan fernandes <37145078+Rayanfer32@users.noreply.github.com> Date: Wed, 8 Jun 2022 12:48:05 +0530 Subject: [PATCH 12/15] =?UTF-8?q?=F0=9F=92=84=20improve=20UI,=20selectable?= =?UTF-8?q?=20=20text?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/templates/home.html | 5 ++--- app/templates/index.html | 44 +++++++++++++++++++++++----------------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/app/templates/home.html b/app/templates/home.html index 3329ece..dccf380 100644 --- a/app/templates/home.html +++ b/app/templates/home.html @@ -10,9 +10,8 @@

- -
{{chat.name}}
- + +
{{chat.name}}
{% endfor %}

diff --git a/app/templates/index.html b/app/templates/index.html index 9e52a41..fa936c4 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -5,22 +5,26 @@ {% endblock %}
-
- - {{name}} + + + -
+ +
- -
+
-