mirror of
https://github.com/lyz05/danmaku.git
synced 2026-04-15 02:50:08 +08:00
fix: 修复一处腾讯视频、爱奇艺解析错误
fix: 错误日志返回Object
This commit is contained in:
@@ -42,6 +42,7 @@ async function updateDatabase() {
|
||||
}
|
||||
|
||||
/* GET users listing. */
|
||||
// TODO TG代理 日志生成
|
||||
router.get('/', async function (req, res, next) {
|
||||
const database = await updateDatabase();
|
||||
if (req.query.user) {
|
||||
|
||||
@@ -62,10 +62,8 @@ function Iqiyi() {
|
||||
const json = await xml2js.parseStringPromise(xml)
|
||||
// console.log(json)
|
||||
global.gc()
|
||||
for (const entry of json.danmu.data[0].entry) {
|
||||
if (!entry.list[0].bulletInfo)
|
||||
continue
|
||||
for (const bulletInfo of entry.list[0].bulletInfo){
|
||||
for (const entry of json.danmu.data[0].entry??[]) {
|
||||
for (const bulletInfo of entry.list[0].bulletInfo??[]){
|
||||
// console.log(bulletInfo)
|
||||
const content = JSON.parse(JSON.stringify(content_template));
|
||||
content.timepoint = bulletInfo['showTime'][0]//showTime
|
||||
@@ -76,8 +74,6 @@ function Iqiyi() {
|
||||
}
|
||||
}
|
||||
memory()
|
||||
// $('bulletInfo').each(function () {
|
||||
// })
|
||||
}
|
||||
contents = make_response(contents)
|
||||
return contents
|
||||
|
||||
@@ -28,7 +28,14 @@ function Tencentvideo() {
|
||||
let res = await axios.get(url);
|
||||
const $ = whacko.load(res.data, null, false);
|
||||
this.title = $("title")[0].children[0].data;
|
||||
res = await axios.get(api_danmaku_base + vid);
|
||||
try {
|
||||
res = await axios.get(api_danmaku_base + vid);
|
||||
} catch (e) {
|
||||
if (e.response.status === 404) {
|
||||
this.error_msg = '好像没有弹幕哦'
|
||||
return
|
||||
} else throw e
|
||||
}
|
||||
|
||||
let promises = []
|
||||
let list = Object.values(res.data.segment_index)
|
||||
@@ -61,12 +68,14 @@ function Tencentvideo() {
|
||||
|
||||
this.work = async (url) => {
|
||||
const promises = await this.resolve(url);
|
||||
console.log(this.name, 'api lens:', promises.length)
|
||||
this.content = await this.parse(promises);
|
||||
if (!this.error_msg) {
|
||||
console.log(this.name, 'api lens:', promises.length)
|
||||
this.content = await this.parse(promises)
|
||||
}
|
||||
return {
|
||||
title: this.title,
|
||||
content: this.content,
|
||||
msg: 'ok'
|
||||
msg: this.error_msg ? this.error_msg : 'ok'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ async function build_response(url,req) {
|
||||
ret = await fc.work(url)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
leancloud.danmakuErrorAdd({ip: getClientIp(req), url: url, error: e})
|
||||
leancloud.danmakuErrorAdd({ip: getClientIp(req), url: url, err: e})
|
||||
return {msg: '弹幕解析过程中程序报错退出,请等待管理员修复!或者换条链接试试!'}
|
||||
}
|
||||
return ret
|
||||
|
||||
@@ -101,7 +101,7 @@ describe('App', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('airportsub modules',function (){
|
||||
describe('机场订阅模块',function (){
|
||||
this.timeout(1000*5);
|
||||
it('接口不带参数测试', (done) =>{
|
||||
chai.request(app)
|
||||
|
||||
@@ -51,13 +51,15 @@ async function danmakuQuery(date) {
|
||||
}
|
||||
|
||||
function danmakuErrorAdd(obj) {
|
||||
const {ip, url, error} = obj;
|
||||
let {ip, url, err} = obj;
|
||||
const DanmakuErrorObject = AV.Object.extend('DanmakuError');
|
||||
const record = new DanmakuErrorObject();
|
||||
record.set('remoteIP', ip);
|
||||
record.set('url', url);
|
||||
//TODO: 转换成object
|
||||
record.set('error', JSON.stringify(error));
|
||||
err = JSON.stringify(err, Object.getOwnPropertyNames(err))
|
||||
err = JSON.parse(err)
|
||||
record.set('err', err);
|
||||
record.save().then()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user