forked from yydfys/CatPawOpen
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathpush.js
More file actions
84 lines (79 loc) · 2.24 KB
/
push.js
File metadata and controls
84 lines (79 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
async function init(_inReq, _outResp) {
return {};
}
async function support(_inReq, _outResp) {
// const clip = inReq.body.clip;
return 'true';
}
async function detail(inReq, _outResp) {
const ids = !Array.isArray(inReq.body.id) ? [inReq.body.id] : inReq.body.id;
const videos = [];
for (const id of ids) {
let vod = {
vod_id: id,
vod_content: '',
vod_name: id,
vod_pic: 'https://pic.rmb.bdstatic.com/bjh/1d0b02d0f57f0a42201f92caba5107ed.jpeg',
};
vod.vod_play_from = '推送';
vod.vod_play_url = '测试$' + id;
videos.push(vod);
}
return {
list: videos,
};
}
async function play(inReq, _outResp) {
// const flag = inReq.body.flag;
const id = inReq.body.id;
return {
parse: 0,
url: id,
};
}
async function test(inReq, outResp) {
try {
const printErr = function (json) {
if (json.statusCode && json.statusCode == 500) {
console.error(json);
}
};
const prefix = inReq.server.prefix;
const dataResult = {};
let resp = await inReq.server.inject().post(`${prefix}/support`).payload({
clip: 'https://xx.xx/1.m3u8',
});
dataResult.support = resp.json();
printErr(resp.json());
resp = await inReq.server.inject().post(`${prefix}/detail`).payload({
id: 'https://xx.xx/1.m3u8',
});
dataResult.detail = resp.json();
printErr(resp.json());
resp = await inReq.server.inject().post(`${prefix}/play`).payload({
flag: 'xx',
id: 'https://xx.xx/1.m3u8',
});
dataResult.play = resp.json();
printErr(resp.json());
return dataResult;
} catch (err) {
console.error(err);
outResp.code(500);
return { err: err.message, tip: 'check debug console output' };
}
}
export default {
meta: {
key: 'push',
name: '推送',
type: 4,
},
api: async (fastify) => {
fastify.post('/init', init);
fastify.post('/support', support);
fastify.post('/detail', detail);
fastify.post('/play', play);
fastify.get('/test', test);
},
};