提交 7a5f2fb3 编写于 作者: H hjdhnx

增加错误返回空列表

上级 2e40a389
......@@ -468,6 +468,7 @@ class CMS:
else:
url = detailUrl
# print(url)
try:
r = requests.get(url, headers=self.headers,timeout=self.timeout)
r.encoding = self.encoding
html = r.text
......@@ -554,6 +555,8 @@ class CMS:
# print(vod_play_url)
vod['vod_play_from'] = vod_play_from
vod['vod_play_url'] = vod_play_url
except Exception as e:
logger.info(f'{self.getName()}获取单个详情页出错{e}')
return vod
......@@ -567,6 +570,7 @@ class CMS:
array = array[(fypage-1)*self.limit:min(self.limit*fypage,len(array))]
thread_pool = ThreadPoolExecutor(min(self.limit,len(array))) # 定义线程池来启动多线程执行此任务
obj_list = []
try:
for vod_url in array:
obj = thread_pool.submit(self.detailOneVod, vod_url)
obj_list.append(obj)
......@@ -575,7 +579,12 @@ class CMS:
result = {
'list': vod_list
}
logger.info(f'{self.getName()}获取详情页耗时:{get_interval(t1)}毫秒,共计{round(len(str(result))/1000,2)} kb')
logger.info(f'{self.getName()}获取详情页耗时:{get_interval(t1)}毫秒,共计{round(len(str(result)) / 1000, 2)} kb')
except Exception as e:
result = {
'list': []
}
logger.info(f'{self.getName()}获取详情页耗时:{get_interval(t1)}毫秒,发生错误:{e}')
# print(result)
return result
......@@ -585,20 +594,21 @@ class CMS:
return self.blank()
url = self.searchUrl.replace('**', key).replace('fypage',pg)
logger.info(f'{self.getName()}搜索链接:{url}')
r = requests.get(url, headers=self.headers)
r.encoding = self.encoding
html = r.text
if not self.搜索:
return self.blank()
p = self.一级.split(';') if self.搜索 == '*' and self.一级 else self.搜索.split(';') # 解析
if len(p) < 5:
return self.blank()
jsp = jsoup(self.url)
pdfh = jsp.pdfh
pdfa = jsp.pdfa
pd = jsp.pd
pq = jsp.pq
videos = []
try:
r = requests.get(url, headers=self.headers)
r.encoding = self.encoding
html = r.text
items = pdfa(html, p[0])
videos = []
for item in items:
......@@ -616,6 +626,8 @@ class CMS:
"vod_remarks": desc,
"vod_content": content,
})
except Exception as e:
logger.info(f'搜索{self.getName()}发生错误:{e}')
result = {
'list': videos
}
......@@ -626,8 +638,9 @@ class CMS:
jxs = []
if self.lazy:
print(f'{play_url}->开始执行免嗅代码->{self.lazy}')
if not str(self.lazy).startswith('js:'):
t1 = time()
try:
if not str(self.lazy).startswith('js:'):
pycode = runPy(self.lazy)
if pycode:
# print(pycode)
......@@ -659,7 +672,8 @@ class CMS:
# print(loader.toString())
play_url = loader.eval('input')
logger.info(f'js免嗅耗时:{get_interval(t1)}毫秒,播放地址:{play_url}')
except Exception as e:
logger.info(f'免嗅耗时:{get_interval(t1)}毫秒,并发生错误:{e}')
return play_url
else:
logger.info(f'播放重定向到:{play_url}')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册