From 3a2fba04225f49b0c1284072833cd45caf5a45ba Mon Sep 17 00:00:00 2001 From: thsrite Date: Mon, 11 Sep 2023 12:43:27 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E8=87=AA=E5=8A=A8=E8=8E=B7=E5=8F=96rss?= =?UTF-8?q?=20data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/chain/cookiecloud.py | 51 +++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/app/chain/cookiecloud.py b/app/chain/cookiecloud.py index 65eeb6c7..10cb7b23 100644 --- a/app/chain/cookiecloud.py +++ b/app/chain/cookiecloud.py @@ -160,12 +160,16 @@ class CookieCloudChain(ChainBase): return self.__get_rss_monika(url=url, cookie=cookie, ua=ua) if "zhuque.in" in url: return self.__get_rss_zhuque(url=url, cookie=cookie, ua=ua) + + xpath = "//a[@class='faqlink']/@href" if "et8.org" in url or "club.hares.top" in url: - return self.__get_rss_tccf(url=url, cookie=cookie, ua=ua) + xpath = "//a/@href" + if "pttime.org" in url: + xpath = "//*[@id='outer']/table/tbody/tr/td/table/tbody/tr/td/text()[5]" - return self.__get_rss_base(url=url, cookie=cookie, ua=ua) + return self.__get_rss_base(url=url, cookie=cookie, ua=ua, xpath=xpath) - def __get_rss_base(self, url: str, cookie: str, ua: str) -> str: + def __get_rss_base(self, url: str, cookie: str, ua: str, xpath: str) -> str: """ 默认获取站点rss地址 """ @@ -180,30 +184,7 @@ class CookieCloudChain(ChainBase): return "" html = etree.HTML(html_text) if html: - rss_link = html.xpath("//a[@class='faqlink']/@href") - if rss_link: - return str(rss_link[-1]) - return "" - except Exception as e: - print(str(e)) - return "" - - def __get_rss_tccf(self, url: str, cookie: str, ua: str) -> str: - """ - 默认tccf rss地址 - """ - try: - get_rss_url = urljoin(url, "getrss.php") - rss_data = self.__get_rss_data(url) - res = RequestUtils(cookies=cookie, timeout=60, ua=ua).post_res(url=get_rss_url, data=rss_data) - if res: - html_text = res.text - else: - logger.error(f"获取rss失败:{url}") - return "" - html = etree.HTML(html_text) - if html: - rss_link = html.xpath("//a/@href") + rss_link = html.xpath(xpath) if rss_link: return str(rss_link[-1]) return "" @@ -321,6 +302,7 @@ class CookieCloudChain(ChainBase): if 'shadowflow.org' in url: # 下载需扣除魔力 0不需要 1需要 2全部 _rss_data['paid'] = 0 + _rss_data['search_mode'] = 0 if 'hddolby.com' in url: # RSS链接有效期: 180天 @@ -330,9 +312,17 @@ class CookieCloudChain(ChainBase): # RSS链接有效期: 180天 _rss_data['exp'] = 180 + if 'pthome.net' in url: + # RSS链接有效期: 180天 + _rss_data['exp'] = 180 + if 'leaves.red' in url: # 下载需扣除魔力 0不需要 1需要 2全部 _rss_data['paid'] = 2 + _rss_data['search_mode'] = 0 + + if 'hdtime.org' in url: + _rss_data['search_mode'] = 0 if 'u2.dmhy.org' in url: # 显示自动通过的种子 0不显示自动通过的种子 1全部 @@ -340,6 +330,13 @@ class CookieCloudChain(ChainBase): # Tracker SSL 0不使用SSL 1使用SSL _rss_data['trackerssl'] = 1 + if 'www.pttime.org' in url: + _rss_data = { + "showrows": 10, + "inclbookmarked": 0, + "itemsmalldescr": 1 + } + return _rss_data @staticmethod