提交 344b611d 编写于 作者: H hjdhnx

解决菜狗的自定义筛选

上级 098a17b3
......@@ -19,7 +19,7 @@ from utils.parser import runPy,runJScode,JsObjectWrapper
from utils.htmlParser import jsoup
from urllib.parse import urljoin
from concurrent.futures import ThreadPoolExecutor # 引入线程池
from flask import url_for,redirect
from flask import url_for,redirect,render_template_string
from easydict import EasyDict as edict
from controllers.service import storage_service
......@@ -51,6 +51,7 @@ class CMS:
self.lsg = storage_service()
self.title = rule.get('title', '')
self.id = rule.get('id', self.title)
self.filter_url = rule.get('filter_url', '')
cate_exclude = rule.get('cate_exclude','')
tab_exclude = rule.get('tab_exclude','')
self.lazy = rule.get('lazy', False)
......@@ -595,14 +596,17 @@ class CMS:
# print(result)
return result
def categoryContent(self, fyclass, fypage):
def categoryContent(self, fyclass, fypage, fl=None):
"""
一级带分类的数据返回
:param fyclass: 分类标识
:param fypage: 页码
:param fl: 筛选
:return: cms一级数据
"""
if fl is None:
fl = {}
result = {}
# urlParams = ["", "", "", "", "", "", "", "", "", "", "", ""]
# urlParams = [""] * 12
......@@ -629,11 +633,17 @@ class CMS:
exec(f'cnt_pg={cnt_page}', cnt_ctx)
cnt_pg = str(cnt_ctx['cnt_pg']) # 计算表达式的结果
url = url.replace(url_rep,str(cnt_pg)).replace('(','').replace(')','')
print(url)
# print(url)
else:
url = url.replace('fypage',pg)
if fypage == 1 and self.test('[\[\]]',url):
url = url.split('[')[1].split(']')[0]
if self.filter_url:
fl_url = render_template_string(self.filter_url,fl=fl)
if not url.endswith('&') and not fl_url.startswith('&'):
url += '&'
url += fl_url
# print(url)
p = self.一级
jsp = jsoup(self.url)
videos = []
......
......@@ -3,6 +3,7 @@
# File : vod.py
# Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------
# Date : 2022/9/6
import json
from flask import Blueprint,request,render_template,jsonify,make_response,redirect
from time import time
......@@ -23,6 +24,7 @@ def vod_home():
t0 = time()
rule = getParmas('rule')
ext = getParmas('ext')
filters = getParmas('f')
if not ext.startswith('http') and not rule:
return R.failed('规则字段必填')
rule_list = getRuleLists()
......@@ -90,8 +92,13 @@ def vod_home():
else:
return play_url
if ac and t: # 一级
data = cms.categoryContent(t,pg)
if ac and t: # 一级
fl = {}
if filters and filters.find('{') > -1 and filters.find('}') > -1:
fl = json.loads(filters)
# print(filters,type(filters))
# print(fl,type(fl))
data = cms.categoryContent(t,pg,fl)
# print(data)
return jsonify(data)
if ac and ids: # 二级
......@@ -105,7 +112,6 @@ def vod_home():
data = cms.searchContent(wd)
# print(data)
return jsonify(data)
# return jsonify({'rule':rule,'js_code':js_code})
home_data = cms.homeContent(pg)
return jsonify(home_data)
\ No newline at end of file
......@@ -7,6 +7,7 @@ var rule = {
quickSearch:0,
// 分类链接fypage参数支持1个()表达式
url:'/napi/video/classlist?abtest=0&iploc=CN1304&spver=&listTab=fyclass&filter=&start=((fypage-1)*15)&len=15&fr=filter',
filter_url:'style={{fl.style}}&zone={{fl.zone}}&year={{fl.year}}&fee={{fl.fee}}&order={{fl.order}}',
headers:{
'User-Agent':'MOBILE_UA'
},
......
......@@ -49,6 +49,7 @@
###### 2022/09/11
- [X] 1.升级至3.5.2.后台管理增加设置中心 (可能会存在bug)
- [X] 2.升级至3.5.3.增加菜狗源(筛选及解析播放暂未解决)
- [X] 3.升级至3.5.4 (此版本+pluto1.4.1以上版本支持filter,源示例:菜狗.js)
###### 2022/09/10
- [X] 1.升级至3.4.4.增加小强迷源,增加二级重定向属性(提供重定向后的源码,让代码重新取重定向过后的线路和播放列表)
- [X] 2.升级至3.4.5.增加兔小贝儿歌源,优化json:细节处理以及详情页拼接细节
......@@ -203,6 +204,8 @@ var rule = {
quickSearch:0,//是否启用快速搜索,
filterable:0,//是否启用筛选,
filter:{},// 筛选条件字典
// 筛选网站传参,会自动传到分类链接下(本示例中的url参数)
filter_url:'style={{fl.style}}&zone={{fl.zone}}&year={{fl.year}}&fee={{fl.fee}}&order={{fl.order}}',
// 注意,由于猫有配置缓存,搜索配置没法热加载,修改了js不需要重启服务器
// 但是需要tv_box进设置里换源使配置重新装载
headers:{//网站的请求头,完整支持所有的,常带ua和cookies
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册