From a617c6991afbcf544b2b336fd3b38c09d33501da Mon Sep 17 00:00:00 2001 From: hillerliao Date: Sun, 25 Feb 2024 21:57:59 +0900 Subject: [PATCH] =?UTF-8?q?=E5=8F=82=E6=95=B0=E8=BF=87=E6=BB=A4=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=A4=9A=E5=85=B3=E9=94=AE=E8=AF=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rsshub/blueprints/main.py | 26 +++++++++++++++++++++----- rsshub/spiders/word/word.py | 4 ++-- rsshub/templates/main/feeds.html | 4 ++-- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/rsshub/blueprints/main.py b/rsshub/blueprints/main.py index 173d84e..4e143b1 100644 --- a/rsshub/blueprints/main.py +++ b/rsshub/blueprints/main.py @@ -27,17 +27,33 @@ def filter_content(ctx): exclude_description = request.args.get('exclude_description') limit = request.args.get('limit', type=int) items = ctx['items'].copy() - items = [item for item in items if include_title in item['title']] if include_title else items - items = [item for item in items if include_description in item['description']] if include_description else items - items = [item for item in items if exclude_title not in item['title']] if exclude_title else items - items = [item for item in items if exclude_description not in item['description']] if exclude_description else items - items = items[:limit] if limit else items + + if include_title: + include_keywords = include_title.split('|') if '|' in include_title else [include_title] + items = [item for item in items if any(keyword in item['title'] for keyword in include_keywords)] + + if include_description: + include_keywords = include_description.split('|') if '|' in include_description else [include_description] + items = [item for item in items if any(keyword in item['description'] for keyword in include_keywords)] + + if exclude_title: + exclude_keywords = exclude_title.split('|') if '|' in exclude_title else [exclude_title] + items = [item for item in items if all(keyword not in item['title'] for keyword in exclude_keywords)] + + if exclude_description: + exclude_keywords = exclude_description.split('|') if '|' in exclude_description else [exclude_description] + items = [item for item in items if all(keyword not in item['description'] for keyword in exclude_keywords)] + + if limit: + items = items[:limit] + ctx = ctx.copy() ctx['items'] = items return ctx + #---------- feed路由从这里开始 -----------# @bp.route('/cninfo/announcement//') @bp.route('/cninfo/announcement') diff --git a/rsshub/spiders/word/word.py b/rsshub/spiders/word/word.py index 57e7c67..edcf0df 100644 --- a/rsshub/spiders/word/word.py +++ b/rsshub/spiders/word/word.py @@ -27,11 +27,11 @@ def remove_html_tags(text): def ctx(category=''): word = '' if category == 'ja': - url = 'https://raw.githubusercontent.com/hillerliao/img/main/words.csv' + url = 'https://raw.githubusercontent.com/henrylovemiller/img/main/words.csv' res = get_csv_line(url) word = f"{res[1]} 〔{res[2]} {res[4]}〕 {res[3]} " elif category == 'jlpt3': - url = 'https://raw.githubusercontent.com/hillerliao/img/main/hongbaoshu_N3.csv' + url = 'https://raw.githubusercontent.com/henrylovemiller/img/main/hongbaoshu_N3.csv' res = get_csv_line(url) word = f"{res[0]}〔{res[1]} {res[2]}〕 ➡{res[3]} ➡{res[4]} ➡ {res[5]} ➡ {res[6]} " word = remove_html_tags(word) diff --git a/rsshub/templates/main/feeds.html b/rsshub/templates/main/feeds.html index a4e372a..820a65d 100644 --- a/rsshub/templates/main/feeds.html +++ b/rsshub/templates/main/feeds.html @@ -5,8 +5,8 @@

RSS Filter参数

RSS 过滤参数by hillerliao
-

举例:https://pyrsshub.vercel.app/filter?feed=https://sspai.com/feed&include_title=派早报

-

参数:include_title 匹配标题

+

举例:https://pyrsshub.vercel.app/filter?feed=https://sspai.com/feed&include_title=征文|派早报

+

参数:include_title 匹配标题,支持多关键词,用 | 分隔。

参数:include_description 匹配摘要

参数:exclude_title 排除标题

参数:exclude_description 排除摘要