From 6d9f8ae704a6bb44618ab31dc9bfadc617136b90 Mon Sep 17 00:00:00 2001 From: garickbadalov Date: Tue, 17 Oct 2023 18:14:32 +0300 Subject: [PATCH] minor fixes --- main.py | 2 +- src/core/master_service.py | 2 -- src/parsers/Telegram/telegram_media_downloader/config.yaml | 4 ++-- .../Telegram/telegram_media_downloader/media_downloader.py | 2 ++ .../Telegram/telegram_media_downloader/telegram_parser.py | 5 ++++- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 7387ba3..2dc10b1 100644 --- a/main.py +++ b/main.py @@ -5,4 +5,4 @@ from src.core.master_service import MasterService if __name__ == '__main__': freeze_support() ms = MasterService() - ms.loop.run_until_complete(ms.run()) \ No newline at end of file + ms.loop.run_until_complete(ms.run()) diff --git a/src/core/master_service.py b/src/core/master_service.py index 5abbc79..e6657d0 100644 --- a/src/core/master_service.py +++ b/src/core/master_service.py @@ -87,8 +87,6 @@ class MasterService: result = downloader.video_download() return result - - @staticmethod def get_parser(params: dict): try: diff --git a/src/parsers/Telegram/telegram_media_downloader/config.yaml b/src/parsers/Telegram/telegram_media_downloader/config.yaml index f0b7f7a..e5d7300 100644 --- a/src/parsers/Telegram/telegram_media_downloader/config.yaml +++ b/src/parsers/Telegram/telegram_media_downloader/config.yaml @@ -2,8 +2,8 @@ api_hash: cb06da2bf01e15627434223242b6446d api_id: 21648766 chat: - chat_id: landigos - download_filter: id == 6989 - last_read_message_id: 6989 + download_filter: id == 6986 + last_read_message_id: 6986 file_formats: video: - all diff --git a/src/parsers/Telegram/telegram_media_downloader/media_downloader.py b/src/parsers/Telegram/telegram_media_downloader/media_downloader.py index 7104ddd..75b69e3 100644 --- a/src/parsers/Telegram/telegram_media_downloader/media_downloader.py +++ b/src/parsers/Telegram/telegram_media_downloader/media_downloader.py @@ -487,9 +487,11 @@ async def worker(client: pyrogram.client.Client): if node.client: await download_task(node.client, message, node) app.is_running = False + app.loop.stop() else: await download_task(client, message, node) app.is_running = False + app.loop.stop() except Exception as e: logger.exception(f"{e}") diff --git a/src/parsers/Telegram/telegram_media_downloader/telegram_parser.py b/src/parsers/Telegram/telegram_media_downloader/telegram_parser.py index 950f367..ef85878 100644 --- a/src/parsers/Telegram/telegram_media_downloader/telegram_parser.py +++ b/src/parsers/Telegram/telegram_media_downloader/telegram_parser.py @@ -1,3 +1,4 @@ +import asyncio import os from asyncio import gather from urllib.parse import urlparse @@ -30,7 +31,9 @@ class TelegramParser(BaseParser): mode="w+", encoding="utf-8") as f: YAML().dump(config, f) if _check_config(): - app.loop.run_until_complete(gather(*[download_all_chat(client), worker(client)])) + asyncio.run_coroutine_threadsafe(download_all_chat(client), app.loop) + asyncio.run_coroutine_threadsafe(worker(client), app.loop) + app.loop.run_forever() client.stop() app.is_running = False logger.info("Stopped!")