minor fixes

This commit is contained in:
garickbadalov 2023-10-17 18:14:32 +03:00
parent d404aa92a6
commit 6d9f8ae704
5 changed files with 9 additions and 6 deletions

View File

@ -5,4 +5,4 @@ from src.core.master_service import MasterService
if __name__ == '__main__': if __name__ == '__main__':
freeze_support() freeze_support()
ms = MasterService() ms = MasterService()
ms.loop.run_until_complete(ms.run()) ms.loop.run_until_complete(ms.run())

View File

@ -87,8 +87,6 @@ class MasterService:
result = downloader.video_download() result = downloader.video_download()
return result return result
@staticmethod @staticmethod
def get_parser(params: dict): def get_parser(params: dict):
try: try:

View File

@ -2,8 +2,8 @@ api_hash: cb06da2bf01e15627434223242b6446d
api_id: 21648766 api_id: 21648766
chat: chat:
- chat_id: landigos - chat_id: landigos
download_filter: id == 6989 download_filter: id == 6986
last_read_message_id: 6989 last_read_message_id: 6986
file_formats: file_formats:
video: video:
- all - all

View File

@ -487,9 +487,11 @@ async def worker(client: pyrogram.client.Client):
if node.client: if node.client:
await download_task(node.client, message, node) await download_task(node.client, message, node)
app.is_running = False app.is_running = False
app.loop.stop()
else: else:
await download_task(client, message, node) await download_task(client, message, node)
app.is_running = False app.is_running = False
app.loop.stop()
except Exception as e: except Exception as e:
logger.exception(f"{e}") logger.exception(f"{e}")

View File

@ -1,3 +1,4 @@
import asyncio
import os import os
from asyncio import gather from asyncio import gather
from urllib.parse import urlparse from urllib.parse import urlparse
@ -30,7 +31,9 @@ class TelegramParser(BaseParser):
mode="w+", encoding="utf-8") as f: mode="w+", encoding="utf-8") as f:
YAML().dump(config, f) YAML().dump(config, f)
if _check_config(): 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() client.stop()
app.is_running = False app.is_running = False
logger.info("Stopped!") logger.info("Stopped!")