From f0ef3ac12fc3c531cd8a9d74815210a69da6e10f Mon Sep 17 00:00:00 2001 From: hjdhnx Date: Tue, 13 Sep 2022 17:13:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E8=8F=9C=E7=8B=97?= =?UTF-8?q?=E7=83=AD=E6=90=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/rules.db | Bin 40960 -> 40960 bytes controllers/home.py | 7 ++++++- js/version.txt | 2 +- readme.md | 1 + templates/config.txt | 24 ++++++++++++++++++++++++ utils/files.py | 2 +- utils/update.py | 17 +++++++++++++++++ 7 files changed, 50 insertions(+), 3 deletions(-) diff --git a/base/rules.db b/base/rules.db index 733389c6e0df33bc8e2c18cfd6f8b1fada199dbb..8551cc2f0943473cf0cf0b4cc6fc9bbe057225af 100644 GIT binary patch delta 90 zcmZoTz|?SnX@WH4m5DOWj8`@$Sj0TbNr|nk1Q;B&DX98d(}8C#9GsZsrsD)C~ans~b=N delta 90 zcmZoTz|?SnX@WH4<%u%RjF&eiAZBCYx9!niwP*CtH{sr5GD0Cz>XiCYu-;8d#*7TcjG9ZsrsD)C~aJ&l+w3 diff --git a/controllers/home.py b/controllers/home.py index 18635ef..e8318bb 100644 --- a/controllers/home.py +++ b/controllers/home.py @@ -18,7 +18,7 @@ from utils.cfg import cfg from utils import parser from utils.log import logger from utils.files import getAlist,get_live_url -from utils.update import getLocalVer +from utils.update import getLocalVer,getHotSuggest from utils.encode import parseText from js.rules import getJxs import random @@ -179,6 +179,11 @@ def getCustonDict(host): logger.info(f'用户自定义配置加载失败:{e}') return customConfig +@home.route('/hotsugg') +def get_hot_search(): + data = getHotSuggest() + return R.success('获取成功',data) + @home.route('/config/') def config_render(mode): # print(dict(app.config)) diff --git a/js/version.txt b/js/version.txt index 627de44..084e244 100644 --- a/js/version.txt +++ b/js/version.txt @@ -1 +1 @@ -3.5.9 \ No newline at end of file +3.6.0 \ No newline at end of file diff --git a/readme.md b/readme.md index 2fb590e..dc867b4 100644 --- a/readme.md +++ b/readme.md @@ -50,6 +50,7 @@ - [X] 1.升级至3.5.8 - [X] 2.迁移alist.conf文件,修改默认模板,增加模板url参数支持fyfilter变量从此支持更多筛选场景 - [X] 3.升级至3.5.9,修复重大bug:模板继承导致的自动生成配置的搜索开关异常问题 +- [X] 4.增加菜狗热搜 ###### 2022/09/12 ###### 特别说明:仅pluto 1.4.2以上版本支持此项目的筛选及自定义播放免嗅 - [X] 1.升级至3.5.7 diff --git a/templates/config.txt b/templates/config.txt index 01a1ac8..eae688c 100644 --- a/templates/config.txt +++ b/templates/config.txt @@ -66,6 +66,30 @@ }{% if loop.last==False %},{% endif %}{% endfor %} ], "flags": ["imgo","youku", "qq", "iqiyi", "qiyi", "letv", "sohu", "tudou","xigua","cntv","1905", "pptv", "mgtv", "wasu", "bilibili", "renrenmi"], +"hotSearch": [{ + "name": "mobilesearch", + "request": { + "method": "GET", + "header": [ + { + "key": "Referer", + "value": "{{ host }}" + } + ], + "url": { + "raw": "{{ host }}/hotsugg?t={time}" + } + }, + "response": { + "result": "$.data", + "data": [ + { + "key": "keyword", + "value": "title" + } + ] + } +}], "lives":[{"group":"redirect","channels":[{"name":"直播","urls":["proxy://do=live&type=txt&ext={{live_url}}"]}]}], "ijk": [{ "group": "软解码", diff --git a/utils/files.py b/utils/files.py index 2d4d125..c353514 100644 --- a/utils/files.py +++ b/utils/files.py @@ -75,7 +75,7 @@ def custom_merge(original:dict,custom:dict): new_keys = custom.keys() updateObj = {} extend_obj = {} - for key in ['wallpaper','spider','homepage','lives']: + for key in ['wallpaper','spider','homepage','lives','hotSearch']: if key in new_keys: updateObj[key] = custom[key] diff --git a/utils/update.py b/utils/update.py index 287adde..c5ea7c7 100644 --- a/utils/update.py +++ b/utils/update.py @@ -12,12 +12,29 @@ import zipfile import shutil # https://blog.csdn.net/weixin_33130113/article/details/112336581 from utils.log import logger from utils.web import get_interval +from utils.htmlParser import jsoup headers = { 'Referer': 'https://gitcode.net/', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36', } +def getHotSuggest(url='http://4g.v.sogou.com/hotsugg'): + jsp = jsoup(url) + pdfh = jsp.pdfh + pdfa = jsp.pdfa + pd = jsp.pd + try: + r = requests.get(url,headers=headers,timeout=2) + html = r.text + data = pdfa(html,'ul.hot-list&&li') + suggs = [{'title':pdfh(dt,'a&&Text'),'url':pd(dt,'a&&href')} for dt in data] + # print(html) + # print(suggs) + return suggs + except: + return [] + def getLocalVer(): base_path = os.path.dirname(os.path.abspath(os.path.dirname(__file__))) # 上级目录 version_path = os.path.join(base_path, f'js/version.txt') -- GitLab