wip telegram test

This commit is contained in:
nikili0n 2023-10-18 00:15:44 +03:00 committed by Dantenerosas
parent 913dc7f9aa
commit c12b966496
2 changed files with 6 additions and 4 deletions

View File

@ -81,7 +81,9 @@ class MasterService:
app.pre_run()
app.is_running = True
tg_client.start()
result = downloader.video_download(client=tg_client)
loop = asyncio.get_running_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(downloader.video_download(client=tg_client))
return result
case _:
result = downloader.video_download()

View File

@ -51,7 +51,7 @@ def asyncio_gather(*futures, return_exceptions=False) -> list:
class TelegramParser(BaseParser):
def video_download(self, client: Client = None):
async def video_download(self, client: Client = None):
url_parse_result = urlparse(self.params["link"])
channel, message_id = url_parse_result.path[1:].split('/') if "/c/" not in url_parse_result.path else \
url_parse_result.path[3:].split('/')
@ -68,8 +68,8 @@ class TelegramParser(BaseParser):
mode="w+", encoding="utf-8") as f:
YAML().dump(config, f)
if _check_config():
a = asyncio_run(download_all_chat(client))
b = asyncio_run(worker(client))
await download_all_chat(client)
await worker(client)
client.stop()
app.is_running = False
logger.info("Stopped!")