From 53482111a00b705bb64feaf5a892dcad4845c9db Mon Sep 17 00:00:00 2001 From: EstrellaXD Date: Thu, 11 May 2023 17:30:42 +0800 Subject: [PATCH] Fix status bug. Fix log level of uvicorn access. --- src/module/core/check.py | 1 - src/module/core/download_fliter.py | 25 ------------------------ src/module/parser/analyser/bgm_parser.py | 23 +++++++++++----------- 3 files changed, 12 insertions(+), 37 deletions(-) delete mode 100644 src/module/core/download_fliter.py diff --git a/src/module/core/check.py b/src/module/core/check.py index dd40c653..883c50b6 100644 --- a/src/module/core/check.py +++ b/src/module/core/check.py @@ -18,7 +18,6 @@ def check_status() -> bool: return False - def check_downloader(): with DownloadClient() as client: if client.authed: diff --git a/src/module/core/download_fliter.py b/src/module/core/download_fliter.py deleted file mode 100644 index 343aca4c..00000000 --- a/src/module/core/download_fliter.py +++ /dev/null @@ -1,25 +0,0 @@ -import re -import logging -import xml.etree.ElementTree -from typing import Tuple - -from module.conf import settings -from module.utils import json_config - -logger = logging.getLogger(__name__) - - -class RSSFilter: - def __init__(self): - self.filter_rule = json_config.load(settings.filter_rule) - - def filter(self, item: xml.etree.ElementTree.Element) -> Tuple[bool, str]: - title = item.find("title").text - torrent = item.find("enclosure").attrib["url"] - download = False - for rule in self.filter_rule: - if re.search(rule["include"], title): - if not re.search(rule["exclude"], title): - download = True - logger.debug(f"{title} added") - return download, torrent diff --git a/src/module/parser/analyser/bgm_parser.py b/src/module/parser/analyser/bgm_parser.py index 924dac57..67fbf220 100644 --- a/src/module/parser/analyser/bgm_parser.py +++ b/src/module/parser/analyser/bgm_parser.py @@ -1,15 +1,16 @@ from module.network import RequestContent -class BgmAPI: - def __init__(self): - self.search_url = lambda e: f"https://api.bgm.tv/search/subject/{e}?type=2" - self.info_url = lambda e: f"https://api.bgm.tv/subject/{e}" +search_url = lambda e: \ + f"https://api.bgm.tv/search/subject/{e}?responseGroup=large" + + +def bgm_parser(title): + url = search_url(title) + with RequestContent() as req: + contents = req.get_json(url) + if contents: + return contents[0] + else: + return None - def search(self, title): - url = self.search_url(title) - with RequestContent() as req: - contents = req.get_json(url)["list"] - if contents.__len__() == 0: - return None - return contents[0]["name"], contents[0]["name_cn"]