更新bd影视
This commit is contained in:
parent
96e85aefd8
commit
ee2bdb71f1
@ -103,11 +103,11 @@
|
||||
"key":"hipy_t4_哔滴影视",
|
||||
"name":"哔滴影视(hipy_t4)",
|
||||
"type":4,
|
||||
"api":"http://192.168.31.49:5707/api/v1/vod/哔滴影视",
|
||||
"api":"http://192.168.31.49:5707/api/v1/vod/哔滴影视?api_ext={{host}}/txt/hipy/bdys.jar",
|
||||
"searchable":1,
|
||||
"quickSearch":0,
|
||||
"filterable":1,
|
||||
"ext":""
|
||||
"ext":"{{host}}/txt/hipy/bdys.jar"
|
||||
},
|
||||
{
|
||||
"key": "hipy_t3_哔滴影视",
|
||||
@ -117,7 +117,7 @@
|
||||
"searchable": 1,
|
||||
"quickSearch": 0,
|
||||
"filterable": 1,
|
||||
"ext": ""
|
||||
"ext": "{{host}}/txt/hipy/bdys.jar"
|
||||
},
|
||||
{"key":"Test_jsapi","name":"Test_jsapi(drpy)","type":3,"api":"{{host}}/libs/drpy2.min.js","searchable":2,"quickSearch":0,"filterable":0,"ext":"{{host}}/js/jsapi.js","jar":"{{host}}/libs/jar/custom_jsapi.jar"},
|
||||
|
||||
|
||||
@ -1 +1 @@
|
||||
3.9.49beta22
|
||||
3.9.49beta23
|
||||
BIN
txt/hipy/bdys.jar
Normal file
BIN
txt/hipy/bdys.jar
Normal file
Binary file not shown.
@ -15,9 +15,9 @@ try:
|
||||
except ImportError:
|
||||
from t4.base.spider import BaseSpider
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
import base64
|
||||
from cachetools import cached, TTLCache # 可以缓存curd的函数,指定里面的key
|
||||
|
||||
"""
|
||||
配置示例:
|
||||
@ -46,6 +46,16 @@ api里会自动含有ext参数是base64编码后的选中的筛选条件
|
||||
"""
|
||||
|
||||
|
||||
def envkey(self, url: str):
|
||||
return url
|
||||
|
||||
|
||||
# 全局变量
|
||||
gParam = {
|
||||
"inited": False,
|
||||
}
|
||||
|
||||
|
||||
class Spider(BaseSpider): # 元类 默认的元类 type
|
||||
|
||||
api: str = 'https://www.bdys03.com/api/v1'
|
||||
@ -58,22 +68,27 @@ class Spider(BaseSpider): # 元类 默认的元类 type
|
||||
def getName(self):
|
||||
return "哔滴影视"
|
||||
|
||||
@cached(cache=TTLCache(maxsize=3, ttl=3600), key=envkey)
|
||||
def get_init_api(self, url):
|
||||
try:
|
||||
print('get_init_api请求URL:', url)
|
||||
r = self.fetch(url)
|
||||
ret = None
|
||||
if r.status_code == 200:
|
||||
self.log(f'url:{url},文件体积:{len(r.content)}')
|
||||
ret = r.content
|
||||
return ret
|
||||
except Exception as e:
|
||||
print(f'get_init_api请求URL发生错误:{e}')
|
||||
return {}
|
||||
|
||||
def init_api_ext_file(self):
|
||||
"""
|
||||
这个函数用于初始化py文件对应的json文件,用于存筛选规则。
|
||||
执行此函数会自动生成筛选文件
|
||||
@return:
|
||||
"""
|
||||
ext_file = __file__.replace('.py', '.json')
|
||||
print(f'ext_file:{ext_file}')
|
||||
ext_file_dict = {
|
||||
"分类1": [{"key": "letter", "name": "首字母", "value": [{"n": "A", "v": "A"}, {"n": "B", "v": "B"}]}],
|
||||
"分类2": [{"key": "letter", "name": "首字母", "value": [{"n": "A", "v": "A"}, {"n": "B", "v": "B"}]},
|
||||
{"key": "year", "name": "年份",
|
||||
"value": [{"n": "2024", "v": "2024"}, {"n": "2023", "v": "2023"}]}],
|
||||
}
|
||||
with open(ext_file, mode='w+', encoding='utf-8') as f:
|
||||
f.write(json.dumps(ext_file_dict, ensure_ascii=False))
|
||||
pass
|
||||
|
||||
def init(self, extend=""):
|
||||
"""
|
||||
@ -81,35 +96,32 @@ class Spider(BaseSpider): # 元类 默认的元类 type
|
||||
@param extend:
|
||||
@return:
|
||||
"""
|
||||
|
||||
def init_file(ext_file):
|
||||
"""
|
||||
根据与py对应的json文件去扩展规则的筛选条件
|
||||
"""
|
||||
ext_file = Path(ext_file).as_posix()
|
||||
if os.path.exists(ext_file):
|
||||
with open(ext_file, mode='r', encoding='utf-8') as f:
|
||||
try:
|
||||
ext_dict = json.loads(f.read())
|
||||
self.config['filter'].update(ext_dict)
|
||||
except Exception as e:
|
||||
print(f'更新扩展筛选条件发生错误:{e}')
|
||||
|
||||
global gParam
|
||||
ext = self.extend
|
||||
print(f"============{extend}============")
|
||||
|
||||
if isinstance(ext, str) and ext:
|
||||
if ext.startswith('./'):
|
||||
ext_file = os.path.join(os.path.dirname(__file__), ext)
|
||||
init_file(ext_file)
|
||||
elif ext.startswith('http'):
|
||||
try:
|
||||
r = self.fetch(ext)
|
||||
self.config['filter'].update(r.json())
|
||||
except Exception as e:
|
||||
print(f'更新扩展筛选条件发生错误:{e}')
|
||||
elif not ext.startswith('./') and not ext.startswith('http'):
|
||||
ext_file = os.path.join(os.path.dirname(__file__), './' + ext + '.json')
|
||||
init_file(ext_file)
|
||||
if ext.endswith('.jar'):
|
||||
jar_path = os.path.join(os.path.dirname(__file__), './jars')
|
||||
os.makedirs(jar_path, exist_ok=True)
|
||||
jar_file = os.path.join(os.path.dirname(__file__), './jars/bdys.jar')
|
||||
jar_file = Path(jar_file).as_posix()
|
||||
need_down = False
|
||||
msg = ''
|
||||
if not gParam['inited'] and not os.path.exists(jar_file):
|
||||
need_down = True
|
||||
msg = f'未inited,且文件不存在。开始下载文件'
|
||||
elif gParam['inited'] and not os.path.exists(jar_file):
|
||||
need_down = True
|
||||
msg = f'已inited,但文件不存在。开始下载文件'
|
||||
# elif not gParam['inited'] and os.path.exists(jar_file):
|
||||
# need_down = True
|
||||
# msg = f'未inited,但文件已存在。重新下载文件'
|
||||
|
||||
if need_down:
|
||||
self.log(msg)
|
||||
content = self.get_init_api(ext)
|
||||
with open(jar_file, mode='wb+') as f:
|
||||
f.write(content)
|
||||
|
||||
# 装载模块,这里只要一个就够了
|
||||
if isinstance(extend, list):
|
||||
@ -126,6 +138,8 @@ class Spider(BaseSpider): # 元类 默认的元类 type
|
||||
self.token = str(self.class1.getToken())
|
||||
self.headers.update({'token': self.token})
|
||||
|
||||
gParam['inited'] = True
|
||||
|
||||
def isVideoFormat(self, url):
|
||||
pass
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user