From 329525d2a9eab70cb5f1c641236ecef81ce9e838 Mon Sep 17 00:00:00 2001 From: hjdhnx Date: Thu, 1 Sep 2022 11:58:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/cms.py | 5 ++++ config.py | 1 + "js/vip\345\275\261\351\231\242.js" | 6 +++++ "js/\346\250\241\346\235\277.js" | 21 +++++++++++++++ ...51\345\201\266\345\247\220\345\247\220.js" | 1 + models/rules.db | Bin 32768 -> 32768 bytes readme.md | 4 +++ templates/admin.html | 25 ++++++++++++++++-- templates/index.html | 2 +- utils/htmlParser.py | 20 ++++++++++++-- 10 files changed, 80 insertions(+), 5 deletions(-) create mode 100644 "js/vip\345\275\261\351\231\242.js" diff --git a/classes/cms.py b/classes/cms.py index 48bcfdf..e1bfd37 100644 --- a/classes/cms.py +++ b/classes/cms.py @@ -39,6 +39,7 @@ class CMS: self.retry_count = new_conf.get('RETRY_CNT',3) self.lazy_mode = new_conf.get('LAZYPARSE_MODE') self.ocr_api = new_conf.get('OCR_API') + self.cate_exclude = new_conf.get('CATE_EXCLUDE','') try: self.vod = redirect(url_for('vod')).headers['Location'] except: @@ -352,6 +353,7 @@ class CMS: r.encoding = self.encoding html = r.text # print(html) + # print(self.headers) if self.class_parse and not has_cache: p = self.class_parse.split(';') # print(p) @@ -364,6 +366,9 @@ class CMS: # print(items) for item in items: title = pdfh(item, p[1]) + # 过滤排除掉标题名称 + if self.cate_exclude and jsp.test(self.cate_exclude, title): + continue url = pd(item, p[2]) # print(url) tag = url diff --git a/config.py b/config.py index 57fd59e..98b4cf0 100644 --- a/config.py +++ b/config.py @@ -31,4 +31,5 @@ UNAME = 'admin' # 管理员账号 PWD = 'drpy' # 管理员密码 MAX_CONTENT_LENGTH = 1 * 1024 * 1024/100 # 100 kB LIVE_MODE = 1 # 0 本地 1外网 +CATE_EXCLUDE = '首页|留言' # 动态分类过滤 # {% if config.WALL_PAPER %}"wallpaper":"{{ config.WALL_PAPER }}",{% endif %} \ No newline at end of file diff --git "a/js/vip\345\275\261\351\231\242.js" "b/js/vip\345\275\261\351\231\242.js" new file mode 100644 index 0000000..c894777 --- /dev/null +++ "b/js/vip\345\275\261\351\231\242.js" @@ -0,0 +1,6 @@ +var rule = Object.assign(muban.vfed,{ +title:'VIP影院', +host:'http://360yy.cn', +url:'/index.php/vod/show/id/fyclass/page/fypage.html', +searchUrl:'/index.php/vod/search/page/fypage/wd/**.html', +}); \ No newline at end of file diff --git "a/js/\346\250\241\346\235\277.js" "b/js/\346\250\241\346\235\277.js" index 0f52d33..97b70f4 100644 --- "a/js/\346\250\241\346\235\277.js" +++ "b/js/\346\250\241\346\235\277.js" @@ -74,6 +74,27 @@ var muban = { 一级:'.stui-vodlist li;a&&title;a&&data-original;.pic-text&&Text;a&&href', 二级:{"title":".stui-content__detail .title&&Text;.stui-content__detail p:eq(-2)&&Text","img":".stui-content__thumb .lazyload&&data-original","desc":".stui-content__detail p:eq(0)&&Text;.stui-content__detail p:eq(1)&&Text;.stui-content__detail p:eq(2)&&Text","content":".detail&&Text","tabs":".stui-vodlist__head h3","lists":".stui-content__playlist:eq(#id) li"}, 搜索:'#searchList li;a&&title;.lazyload&&data-original;.text-muted&&Text;a&&href;.text-muted:eq(-1)&&Text', +}, +vfed:{ + title:'', + host:'', + url:'/index.php/vod/show/id/fyclass/page/fypage.html', + searchUrl:'/index.php/vod/search/page/fypage/wd/**.html', + searchable:0, + quickSearch:0, + headers:{ + 'User-Agent':'UC_UA', + }, + // class_parse:'.fed-pops-navbar&&ul.fed-part-rows&&a.fed-part-eone:gt(0):lt(5);a&&Text;a&&href;.*/(.*?).html', + class_parse:'.fed-pops-navbar&&ul.fed-part-rows&&a;a&&Text;a&&href;.*/(.*?).html', + play_parse:true, + lazy:'', + limit:6, + 推荐:'ul.fed-list-info.fed-part-rows;li;a.fed-list-title&&Text;a&&data-original;.fed-list-remarks&&Text;a&&href', + double:true, // 推荐内容是否双层定位 + 一级:'.stui-vodlist li;a&&title;a&&data-original;.pic-text&&Text;a&&href', + 二级:{"title":".stui-content__detail .title&&Text;.stui-content__detail p:eq(-2)&&Text","img":".stui-content__thumb .lazyload&&data-original","desc":".stui-content__detail p:eq(0)&&Text;.stui-content__detail p:eq(1)&&Text;.stui-content__detail p:eq(2)&&Text","content":".detail&&Text","tabs":".stui-vodlist__head h3","lists":".stui-content__playlist:eq(#id) li"}, + 搜索:'#searchList li;a&&title;.lazyload&&data-original;.text-muted&&Text;a&&href;.text-muted:eq(-1)&&Text', } diff --git "a/js/\347\216\251\345\201\266\345\247\220\345\247\220.js" "b/js/\347\216\251\345\201\266\345\247\220\345\247\220.js" index 3b52486..5882968 100644 --- "a/js/\347\216\251\345\201\266\345\247\220\345\247\220.js" +++ "b/js/\347\216\251\345\201\266\345\247\220\345\247\220.js" @@ -8,6 +8,7 @@ var rule = { }, timeout:5000, class_parse:'#side-menu:lt(1) li;a&&Text;a&&href;com/(.*?)/', + limit:5, play_parse:true, lazy:'', 一级:'.col-sm-6;h3&&Text;img&&data-src;.date&&Text;a&&href', diff --git a/models/rules.db b/models/rules.db index 6e1e55a9c1e606271fdc656df14e0a4c6ee3424e..5bab170b985ece673fed633c415766dc1636773b 100644 GIT binary patch delta 771 zcmZo@U}|V!njp;>H&Mo!F>YhR5`HaVHeqIdYhE8tMqV~HVV+#heC~@}I{Z!CZk(66 zZgNfHp24w!$AtYO&#{e-Pg%K|quJRRu{20DvNSLO8W>-anO7ViZ)9j}Y;0y=ZmVkUq-tbToS6b7 zRgE20jSPV18yOfFSQwd@nwYB^IRk}&a%D&g;DV_Y1(`*u#b{cM%ph9p&0SC|w6p{o zj^9EvpjBjA2-FI(&(ts{F*6+)=*kvA4;N?Tmphf@*_ITQrZ(D$0HY_iNtEGf=kn(> z_X5#mMQORo^Ca2ppLe$FXO$);W&)93aoEob0Mq*L`Tzg` delta 117 zcmV-*0E+*BfC7Mk0+1U4Qjr`(0aCGGqz@($2(SYWI}J<;0SyKWxD0IxZwt{1EDwSU zMhVgi*$R>im|1JShba)~q diff --git a/readme.md b/readme.md index 830520d..159f9b2 100644 --- a/readme.md +++ b/readme.md @@ -3,6 +3,10 @@ [搭建教程](./安卓本地搭建说明.md) | [install_help](./安卓本地搭建说明.md) [dr项目QQ官群](https://qm.qq.com/cgi-bin/qm/qr?k=H2KwcXrMdiR5M2blHR5gjZzPfN_S3N_C&jump_from=webapi) ###### 更新日志 +###### 2022/09/01 +- [X] 1.增加动态分类排除配置 +- [X] 2.优化pdfh,pdfa,pd等函数,支持多个&&写法,自动取第一个 +- [X] 3.增加vfed规则模板 ###### 2022/08/31 - [X] 1.增加管理员登录功能 - [X] 2.增加管理员上传和删除内置规则功能 diff --git a/templates/admin.html b/templates/admin.html index 7903ec4..fa3e465 100644 --- a/templates/admin.html +++ b/templates/admin.html @@ -17,7 +17,7 @@ padding-left:10px; /*padding-top:10px;*/ margin-left:10px; - width: 240px; + width: 360px; height: 30px; } .green { @@ -26,7 +26,7 @@ padding-left:10px; /*padding-top:10px;*/ margin-left:10px; - width: 240px; + width: 360px; height: 30px; } .btn{ @@ -47,6 +47,19 @@ color:#FFFFFF; background-color: #1379cb; } + .view_home{ + letter-spacing:5px; + margin-left:20px; + width: 150px; + height: 30px; + text-align: center; + border-style: solid; + /*border-color: #8CD4F5;*/ + border-color: #17af30; + text-decoration:none; + color:#FFFFFF; + background-color: #17af30; + } /*li a {*/ /* display: block !important;*/ /*}*/ @@ -60,6 +73,12 @@ location.href = '/admin/view/'+rule+'.js'; }); + $(".view_home").click(function(){ + // location.reload(); + let rule = this.getAttribute('value').trim(); + location.href = '/vod?rule='+rule; + }); + $(".clear").click(function(){ // location.reload(); // let rule = this.innerText.trim(); @@ -137,11 +156,13 @@ {% if rule.name|length > 2 %}
  • {{ rule.name }} + 主页数据预览 删除
  • {% else %}
  • {{ rule.name }} + 主页数据预览 删除
  • {% endif %} diff --git a/templates/index.html b/templates/index.html index bef3197..37b6675 100644 --- a/templates/index.html +++ b/templates/index.html @@ -36,7 +36,7 @@ -
    +
    diff --git a/utils/htmlParser.py b/utils/htmlParser.py index 7b2a8e7..63d9a41 100644 --- a/utils/htmlParser.py +++ b/utils/htmlParser.py @@ -6,21 +6,32 @@ from pyquery import PyQuery as pq from urllib.parse import urljoin +import re class jsoup: def __init__(self,MY_URL=''): self.MY_URL = MY_URL + def test(self, text, string): + searchObj = re.search(rf'{text}', string, re.M | re.I) + test_ret = True if searchObj else False + return test_ret + def pdfh(self,html,parse,pd=False): if not parse: return '' doc = pq(html) option = None if parse.find('&&') > -1: - option = parse.split('&&')[1] - parse = parse.split('&&')[0] + option = parse.split('&&')[-1] + parse = parse.split('&&')[:-1] # 如果只有一个&& 取的就直接是0 + if len(parse) > 1: # 如果不大于1可能就是option操作,不需要拼eq + parse = ' '.join([i if self.test(':eq|:lt|:gt',i) else f'{i}:eq(0)' for i in parse]) + else: + parse = parse[0] if self.test(':eq|:lt|:gt',parse[0]) else f'{parse[0]}:eq(0)' if option: + # print(f'parse:{parse}=>(option:{option})') ret = doc(parse) # FIXME 解析出来有多个的情况应该自动取第一个 if option == 'Text': @@ -44,6 +55,11 @@ class jsoup: def pdfa(self,html,parse): if not parse: return [] + if parse.find('&&') > -1: + parse = parse.split('&&') # 带&&的重新拼接 + # print(f"{parse[0]},{self.test(':eq|:lt|:gt', parse[0])}") + parse = ' '.join([parse[i] if self.test(':eq|:lt|:gt', parse[i]) or i>=len(parse)-1 else f'{parse[i]}:eq(0)' for i in range(len(parse))]) + # print(f'pdfa:{parse}') doc = pq(html) # return [item.html() for item in doc(parse).items()] return [str(item) for item in doc(parse).items()] -- GitLab