diff --git a/app.py b/app.py index 38f9cfcade98c68441064714a8b618f21c148cd4..b8851480507d8e29233d7f9f4fdb47e4f4929251 100644 --- a/app.py +++ b/app.py @@ -9,17 +9,12 @@ from js.rules import rule_list from utils import error,parser import sys import codecs +from models.cms import CMS sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach()) app = Flask(__name__) app.config["JSON_AS_ASCII"] = False # jsonify返回的中文正常显示 -MOBILE_UA = 'Mozilla/5.0 (Linux; Android 11; M2007J3SC Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045714 Mobile Safari/537.36' -PC_UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36' -UA = 'Mozilla/5.0' -headers = { - 'Referer': 'https://www.baidu.com', - 'user-agent': UA, -} +from utils.web import * def getParmas(key=None): """ @@ -54,13 +49,12 @@ def vod(): msg = f'仅支持以下规则:{",".join(rule_list)}' return jsonify(error.failed(msg)) - # with open(f'js/{rule}.js',mode='r',encoding='utf-8') as f: - # js_code = f.read() js_path = f'js/{rule}.js' ctx,js_code = parser.runJs(js_path) - a = ctx.eval('rule') - print(a) - print(type(a)) + rule = ctx.eval('rule') + cms = CMS(rule) + print(cms) + print(cms.title) return jsonify({'rule':rule,'js_code':js_code}) if __name__ == '__main__': diff --git "a/js/\351\270\255\345\245\210\351\243\236.js" "b/js/\351\270\255\345\245\210\351\243\236.js" index f03244ec47bd67eb10c2f06429fec35783d0dcb1..aa3869104805f09251d7fe781be848ec07a032d6 100644 --- "a/js/\351\270\255\345\245\210\351\243\236.js" +++ "b/js/\351\270\255\345\245\210\351\243\236.js" @@ -1,4 +1,5 @@ var rule = { + title:'鸭奈飞', url:'https://yanetflix.com/vodshow/dianying--------fypage---.html', searchUrl:'/vodsearch/**----------fypage---.html', ua:'MOBILE_UA', diff --git a/models/__init__.py b/models/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..2daf85f0e06b8e2da02a85d084f537fd938bf26b --- /dev/null +++ b/models/__init__.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# File : __init__.py.py +# Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------ +# Date : 2022/8/25 + +from . import cms \ No newline at end of file diff --git a/models/cms.py b/models/cms.py new file mode 100644 index 0000000000000000000000000000000000000000..e5798c973e27cc42f77cbc79abf0d8b025600f54 --- /dev/null +++ b/models/cms.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# File : cms.py +# Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------ +# Date : 2022/8/25 +from utils.web import * + +class CMS: + def __init__(self,rule): + self.url = rule.get('url','') + self.searchUrl = rule.get('searchUrl','') + ua = rule.get('ua','') + if ua == 'MOBILE_UA': + self.ua = MOBILE_UA + elif ua == 'PC_UA': + self.ua = PC_UA + else: + self.ua = UA + self.searchUrl = rule.get('searchUrl','') + self.class_name = rule.get('class_name','') + self.class_url = rule.get('class_url','') + self.一级 = rule.get('一级','') + self.二级 = rule.get('二级','') + self.搜索 = rule.get('搜索','') + self.title = rule.get('title','') + + def getName(self): + return self.title + +if __name__ == '__main__': + from utils import parser + js_path = f'js/鸭奈飞.js' + ctx, js_code = parser.runJs(js_path) + rule = ctx.eval('rule') + cms = CMS(rule) + print(cms.title) \ No newline at end of file diff --git a/utils/web.py b/utils/web.py new file mode 100644 index 0000000000000000000000000000000000000000..dbe542597f4ccab630ebbaa83c391315195ce0db --- /dev/null +++ b/utils/web.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# File : web.py +# Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------ +# Date : 2022/8/25 + +MOBILE_UA = 'Mozilla/5.0 (Linux; Android 11; M2007J3SC Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045714 Mobile Safari/537.36' +PC_UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36' +UA = 'Mozilla/5.0' +headers = { + 'Referer': 'https://www.baidu.com', + 'user-agent': UA, +}