From 3641e24cebcb6c8040a9d420a14366e6d40c4a83 Mon Sep 17 00:00:00 2001 From: Dantenerosas Date: Wed, 18 Oct 2023 01:44:24 +0300 Subject: [PATCH] minor fixes --- src/core/master_service.py | 17 ----------------- src/parsers/Dzen/dzen_parser.py | 2 +- .../telegram_parser.py | 3 --- src/parsers/base_parser.py | 1 - 4 files changed, 1 insertion(+), 22 deletions(-) diff --git a/src/core/master_service.py b/src/core/master_service.py index 8f51a3d..ba0fd69 100644 --- a/src/core/master_service.py +++ b/src/core/master_service.py @@ -1,7 +1,6 @@ import asyncio import concurrent.futures as pool import subprocess -import pyrogram import traceback from functools import partial @@ -14,7 +13,6 @@ from src.core.redis_client import RedisClient from src.core.result import Result, ResultTypeEnum from src.exceptions.download_exceptions import FileAlreadyExistException, SiteNotImplementedException from src.parsers.MyMail.my_mail_parser import MyMailParser -from src.parsers.Telegram.telegram_media_downloader.media_downloader import app, _check_config from src.parsers.Yappy.yappy_parser import YappyParser from src.parsers.base_parser import BaseParser from src.parsers.parser_mapping import get_parser @@ -73,8 +71,6 @@ class MasterService: loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) result = loop.run_until_complete(downloader.video_download()) - # r = f.result(600) - # loop.close() return result case _: result = downloader.video_download() @@ -86,19 +82,6 @@ class MasterService: url_parse_result = urlparse(params["link"]) uri = f"{url_parse_result.netloc}{url_parse_result.path}" logger.info(uri) - # # TODO: похоже нужно переделать на регулярки, т.к. добавлять каждую вариацию домена моветон, вероятно я сделаюне- - # parser_mapping = { - # "my.mail.ru": MyMailParser(params), - # "www.youtube.com": BaseParser(params), - # "youtube.com": BaseParser(params), - # "youtu.be": BaseParser(params), - # "vk.com": BaseParser(params), - # "ok.ru": BaseParser(params) if "topic" not in params["link"] else OkParser(params), - # "likee.video": BaseParser(params), - # "dzen.ru": BaseParser(params), - # "yappy.media": YappyParser(params), - # "yandex.ru": BaseParser(params), - # } return get_parser(uri)(params) except KeyError: raise SiteNotImplementedException diff --git a/src/parsers/Dzen/dzen_parser.py b/src/parsers/Dzen/dzen_parser.py index 971960f..ef57e60 100644 --- a/src/parsers/Dzen/dzen_parser.py +++ b/src/parsers/Dzen/dzen_parser.py @@ -36,4 +36,4 @@ class DzenParser(BaseParser): self.params["outtmpl"] = f"downloads/ZenYandex/{title}_%(resolution)s.%(ext)s" file_path = super().video_download() self.params["link"] = base_link - return file_path + return file_path.replace("master", title) if "master" in file_path else file_path diff --git a/src/parsers/Telegram/telegram_media_downloader/telegram_parser.py b/src/parsers/Telegram/telegram_media_downloader/telegram_parser.py index 83327ac..b52ddf3 100644 --- a/src/parsers/Telegram/telegram_media_downloader/telegram_parser.py +++ b/src/parsers/Telegram/telegram_media_downloader/telegram_parser.py @@ -2,7 +2,6 @@ import os from urllib.parse import urlparse from loguru import logger -from pyrogram import Client import pyrogram from ruamel.yaml import YAML @@ -11,8 +10,6 @@ from src.parsers.Telegram.telegram_media_downloader.media_downloader import _che worker from src.parsers.base_parser import BaseParser -import asyncio -import threading class TelegramParser(BaseParser): async def video_download(self): diff --git a/src/parsers/base_parser.py b/src/parsers/base_parser.py index 1ae9811..1adca12 100644 --- a/src/parsers/base_parser.py +++ b/src/parsers/base_parser.py @@ -40,7 +40,6 @@ class BaseParser: if os.path.exists(os.path.join(os.getcwd() + "/downloads/" + path_to_video)): raise FileAlreadyExistException(message=path_to_video) downloader.ydl_opts["quiet"] = False - downloader.ydl_opts["quiet"] = False downloader.download() return path_to_video