diff --git a/app.py b/app.py index 4fbc1d1f88575402480774449ebab1c326ac0aec..76e415b64d645efaee74ff62102cbf6a8844d2e8 100644 --- a/app.py +++ b/app.py @@ -186,7 +186,8 @@ def getRules(path='cache'): new_rule_list.append({ 'name':rule_list[i], 'searchable':rule_codes[i].searchable or 0, - 'quickSearch':rule_codes[i].quickSearch or 0 + 'quickSearch':rule_codes[i].quickSearch or 0, + 'filterable':rule_codes[i].filterable or 0, }) # print(new_rule_list) rules = {'list': new_rule_list, 'count': len(rule_list)} diff --git a/classes/cms.py b/classes/cms.py index 84bb5830dc500747f581decfccd6583751e0c183..d618c174e5e91c221d88feeb080e033465dbc852 100644 --- a/classes/cms.py +++ b/classes/cms.py @@ -35,11 +35,13 @@ class CMS: self.id = rule.get('id', self.title) self.lazy = rule.get('lazy', False) self.play_disable = new_conf.get('PLAY_DISABLE',False) + self.lazy_mode = new_conf.get('LAZYPARSE_MODE') self.vod = redirect(url_for('vod')).headers['Location'] # if not self.play_disable and self.lazy: if not self.play_disable: self.play_parse = rule.get('play_parse', False) - play_url = new_conf.get('PLAY_URL',getHost(2)) + play_url = getHost(self.lazy_mode) + # play_url = new_conf.get('PLAY_URL',getHost(2)) if not play_url.startswith('http'): play_url = 'http://'+play_url if self.play_parse: @@ -356,11 +358,32 @@ class CMS: for item in items: items2 = pdfa(item,p[1]) for item2 in items2: - title = pdfh(item2, p[2]) - img = pd(item2, p[3]) - desc = pdfh(item2, p[4]) - link = pd(item2, p[5]) - content = '' if len(p) < 7 else pdfh(item2, p[6]) + try: + title = pdfh(item2, p[2]) + img = pd(item2, p[3]) + desc = pdfh(item2, p[4]) + link = pd(item2, p[5]) + content = '' if len(p) < 7 else pdfh(item2, p[6]) + videos.append({ + "vod_id": link, + "vod_name": title, + "vod_pic": img, + "vod_remarks": desc, + "vod_content": content, + "type_id": 1, + "type_name": "首页推荐", + }) + except: + pass + else: + items = pdfa(html, p[0]) + for item in items: + try: + title = pdfh(item, p[1]) + img = pd(item, p[2]) + desc = pdfh(item, p[3]) + link = pd(item, p[4]) + content = '' if len(p) < 6 else pdfh(item, p[5]) videos.append({ "vod_id": link, "vod_name": title, @@ -370,23 +393,8 @@ class CMS: "type_id": 1, "type_name": "首页推荐", }) - else: - items = pdfa(html, p[0]) - for item in items: - title = pdfh(item, p[1]) - img = pd(item, p[2]) - desc = pdfh(item, p[3]) - link = pd(item, p[4]) - content = '' if len(p) < 6 else pdfh(item, p[5]) - videos.append({ - "vod_id": link, - "vod_name": title, - "vod_pic": img, - "vod_remarks": desc, - "vod_content": content, - "type_id": 1, - "type_name": "首页推荐", - }) + except: + pass result['list'] = videos result['code'] = 1 result['msg'] = '数据列表' @@ -421,9 +429,6 @@ class CMS: url = self.url.replace('fyclass',fyclass).replace('fypage',pg) if fypage == 1 and self.test('[\[\]]',url): url = url.split('[')[1].split(']')[0] - r = requests.get(url, headers=self.headers,timeout=self.timeout) - r.encoding = self.encoding - print(r.url) p = self.一级.split(';') # 解析 if len(p) < 5: return self.blank() @@ -435,23 +440,35 @@ class CMS: # print(pdfh(r.text,'body a.module-poster-item.module-item:eq(1)&&Text')) # print(pdfh(r.text,'body a.module-poster-item.module-item:eq(0)')) # print(pdfh(r.text,'body a.module-poster-item.module-item:first')) - items = pdfa(r.text, p[0]) + videos = [] + items = [] + try: + r = requests.get(url, headers=self.headers, timeout=self.timeout) + r.encoding = self.encoding + print(r.url) + html = r.text + items = pdfa(html, p[0]) + except: + pass for item in items: # print(item) - title = pdfh(item, p[1]) - img = pd(item, p[2]) - desc = pdfh(item, p[3]) - link = pd(item, p[4]) - content = '' if len(p) < 6 else pdfh(item, p[5]) - # sid = self.regStr(sid, "/video/(\\S+).html") - videos.append({ - "vod_id": link, - "vod_name": title, - "vod_pic": img, - "vod_remarks": desc, - "vod_content": content, - }) + try: + title = pdfh(item, p[1]) + img = pd(item, p[2]) + desc = pdfh(item, p[3]) + link = pd(item, p[4]) + content = '' if len(p) < 6 else pdfh(item, p[5]) + # sid = self.regStr(sid, "/video/(\\S+).html") + videos.append({ + "vod_id": link, + "vod_name": title, + "vod_pic": img, + "vod_remarks": desc, + "vod_content": content, + }) + except: + pass result['list'] = videos result['page'] = fypage result['pagecount'] = 9999 @@ -469,10 +486,6 @@ class CMS: url = detailUrl # print(url) try: - r = requests.get(url, headers=self.headers,timeout=self.timeout) - r.encoding = self.encoding - html = r.text - # print(html) p = self.二级 # 解析 if p == '*': vod = self.blank_vod() @@ -493,6 +506,10 @@ class CMS: pq = jsp.pq obj = {} vod_name = '' + r = requests.get(url, headers=self.headers, timeout=self.timeout) + r.encoding = self.encoding + html = r.text + # print(html) if p.get('title'): p1 = p['title'].split(';') vod_name = pdfh(html,p1[0]).replace('\n',' ') @@ -557,7 +574,7 @@ class CMS: vod['vod_play_url'] = vod_play_url except Exception as e: logger.info(f'{self.getName()}获取单个详情页出错{e}') - + print(vod) return vod def detailContent(self, fypage, array): @@ -610,22 +627,27 @@ class CMS: r.encoding = self.encoding html = r.text items = pdfa(html, p[0]) + # print(items) videos = [] for item in items: # print(item) - title = pdfh(item, p[1]) - img = pd(item, p[2]) - desc = pdfh(item, p[3]) - link = pd(item, p[4]) - content = '' if len(p) < 6 else pdfh(item, p[5]) - # sid = self.regStr(sid, "/video/(\\S+).html") - videos.append({ - "vod_id": link, - "vod_name": title, - "vod_pic": img, - "vod_remarks": desc, - "vod_content": content, - }) + try: + title = pdfh(item, p[1]) + img = pd(item, p[2]) + desc = pdfh(item, p[3]) + link = pd(item, p[4]) + content = '' if len(p) < 6 else pdfh(item, p[5]) + # sid = self.regStr(sid, "/video/(\\S+).html") + videos.append({ + "vod_id": link, + "vod_name": title, + "vod_pic": img, + "vod_remarks": desc, + "vod_content": content, + }) + except: + pass + # print(videos) except Exception as e: logger.info(f'搜索{self.getName()}发生错误:{e}') result = { diff --git "a/js/\345\271\262\351\245\255\345\275\261\350\247\206.js" "b/js/\345\271\262\351\245\255\345\275\261\350\247\206.js" index 7a7d1e1747595fb54780a9f61a596c16a5d731a5..00a855716fd603d851d8f262cbc6d7b044e796ce 100644 --- "a/js/\345\271\262\351\245\255\345\275\261\350\247\206.js" +++ "b/js/\345\271\262\351\245\255\345\275\261\350\247\206.js" @@ -4,11 +4,12 @@ var rule = { // homeUrl:'/', url:'/vodtype/fyclass-fypage.html', headers:{ - 'User-Agent':'MOBILE_UA' + 'User-Agent':'MOBILE_UA', + "Cookie": "searchneed=ok" }, - searchUrl:'/search/**-fypage.html', - searchable:1, - quickSearch:1, + searchUrl:'/vodsearch/**----------fypage---.html', + searchable:0, + quickSearch:0, // class_name:'电影&网剧&剧集&动漫&综艺&记录', // class_url:'20&1&2&3&4&23', class_parse:'.stui-header__menu li:gt(0):lt(5);a&&Text;a&&href;/(\\d+).html', diff --git "a/js/\347\223\234\347\232\256TV.js" "b/js/\347\223\234\347\232\256TV.js" index 0e4e407cf553d4741098ce4772bf63b4d557bab2..93618c2874828f40b88f7b2df39214173e17e217 100644 --- "a/js/\347\223\234\347\232\256TV.js" +++ "b/js/\347\223\234\347\232\256TV.js" @@ -4,8 +4,8 @@ var rule = { // homeUrl:'/', url:'/vodshow/fyclass--------fypage---.html', searchUrl:'/vodsearch/**----------fypage---.html', - searchable:0, - quickSearch:0, + searchable:1, + quickSearch:1, headers:{//网站的请求头,完整支持所有的,常带ua和cookies 'User-Agent':'MOBILE_UA', "Cookie": "searchneed=ok" diff --git a/readme.md b/readme.md index 6317c2faf26a04f5301a72ab568f5aa1035fa659..a2ad7b3836e8bbdb81b1057767ca2f1aed8c909f 100644 --- a/readme.md +++ b/readme.md @@ -84,6 +84,7 @@ var rule = { searchUrl:'',//搜索链接 可以是完整路径或者相对路径,用于分类获取和推荐获取 **代表搜索词 fypage代表页数 searchable:0,//是否启用全局搜索, quickSearch:0,//是否启用快速搜索, + filterable:0,//是否启用筛选, // 注意,由于猫有配置缓存,搜索配置没法热加载,修改了js不需要重启服务器 // 但是需要tv_box进设置里换源使配置重新装载 headers:{//网站的请求头,完整支持所有的,常带ua和cookies diff --git a/templates/config.txt b/templates/config.txt index ea5cd4e8120cc8c171356271a3643d02554306e3..f711799043fa37c943f0d5ea0dde7214391efffe 100644 --- a/templates/config.txt +++ b/templates/config.txt @@ -10,7 +10,7 @@ "api":"{{ host }}/vod?rule={{ rule.name }}", "searchable": {{ rule.searchable }}, "quickSearch": {{ rule.quickSearch }}, - "filterable": 1 + "filterable": {{ rule.filterable }} }{% else %} { "key":"dr_{{ rule.name }}",