bilibili module
This commit is contained in:
parent
5794ac872c
commit
ca9ac4e1ea
8
index.js
8
index.js
|
|
@ -8,4 +8,12 @@ app.engine('art', require('express-art-template'));
|
|||
|
||||
app.all('*', require('./routes/all'));
|
||||
|
||||
// bilibili
|
||||
app.get('/bilibili/user/video/:uid', require('./routes/bilibili/video'));
|
||||
app.get('/bilibili/user/fav/:uid', require('./routes/bilibili/fav'));
|
||||
app.get('/bilibili/user/coin/:uid', require('./routes/bilibili/coin'));
|
||||
app.get('/bilibili/user/dynamic/:uid', require('./routes/bilibili/dynamic'));
|
||||
app.get('/bilibili/partion/:tid', require('./routes/bilibili/partion'));
|
||||
app.get('/bilibili/bangumi/:seasonid', require('./routes/bilibili/bangumi'));
|
||||
|
||||
app.listen(1200);
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
const request = require('request');
|
||||
const art = require('art-template');
|
||||
const path = require('path');
|
||||
const base = require('../base');
|
||||
const mix = require('../../utils/mix');
|
||||
|
||||
module.exports = (req, res) => {
|
||||
const seasonid = req.params.seasonid;
|
||||
|
||||
base({
|
||||
req: req,
|
||||
res: res,
|
||||
getHTML: (callback) => {
|
||||
request.get({
|
||||
url: `https://bangumi.bilibili.com/jsonp/seasoninfo/${seasonid}.ver?callback=seasonListCallback&jsonp=jsonp&_=${+new Date()}`,
|
||||
headers: {
|
||||
'User-Agent': mix.ua,
|
||||
'Referer': `https://bangumi.bilibili.com/anime/${seasonid}/`
|
||||
}
|
||||
}, (err, httpResponse, body) => {
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(body.match(/^seasonListCallback\((.*)\);$/)[1]);
|
||||
}
|
||||
catch (e) {
|
||||
data = {};
|
||||
}
|
||||
const result = data.result || {};
|
||||
|
||||
const html = art(path.resolve(__dirname, '../../views/rss.art'), {
|
||||
title: result.title,
|
||||
link: `https://bangumi.bilibili.com/anime/${seasonid}/`,
|
||||
description: result.evaluate,
|
||||
lastBuildDate: new Date().toUTCString(),
|
||||
item: result.episodes && result.episodes.map((item) => ({
|
||||
title: `第${item.index}话 ${item.index_title}`,
|
||||
description: `更新时间:${item.update_time}<img referrerpolicy="no-referrer" src="${item.cover}">`,
|
||||
pubDate: new Date(item.update_time).toUTCString(),
|
||||
link: item.webplay_url
|
||||
})),
|
||||
});
|
||||
callback(html);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
const request = require('request');
|
||||
const art = require('art-template');
|
||||
const path = require('path');
|
||||
const base = require('../base');
|
||||
const mix = require('../../utils/mix');
|
||||
|
||||
module.exports = (req, res) => {
|
||||
const uid = req.params.uid;
|
||||
|
||||
base({
|
||||
req: req,
|
||||
res: res,
|
||||
getHTML: (callback) => {
|
||||
request.post({
|
||||
url: 'https://space.bilibili.com/ajax/member/GetInfo',
|
||||
headers: {
|
||||
'User-Agent': mix.ua,
|
||||
'Referer': `https://space.bilibili.com/${uid}/`,
|
||||
'Origin': 'https://space.bilibili.com'
|
||||
},
|
||||
form: {
|
||||
mid: uid
|
||||
}
|
||||
}, function (err, httpResponse, body) {
|
||||
const name = JSON.parse(body).data.name;
|
||||
request.get({
|
||||
url: `https://space.bilibili.com/ajax/member/getCoinVideos?mid=${uid}`,
|
||||
headers: {
|
||||
'User-Agent': mix.ua,
|
||||
'Referer': `https://space.bilibili.com/${uid}/`
|
||||
}
|
||||
}, function (err, httpResponse, body) {
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(body);
|
||||
}
|
||||
catch (e) {
|
||||
data = {};
|
||||
}
|
||||
|
||||
const html = art(path.resolve(__dirname, '../../views/rss.art'), {
|
||||
title: `${name} 的 bilibili 投币视频`,
|
||||
link: `https://space.bilibili.com/${uid}`,
|
||||
description: `${name} 的 bilibili 投币视频`,
|
||||
lastBuildDate: new Date().toUTCString(),
|
||||
item: data.data && data.data.list && data.data.list.map((item) => ({
|
||||
title: item.title,
|
||||
description: `${item.title}<br><img referrerpolicy="no-referrer" src="${item.pic}">`,
|
||||
link: `https://www.bilibili.com/video/av${item.stat.aid}`
|
||||
})),
|
||||
});
|
||||
callback(html);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
const request = require('request');
|
||||
const art = require('art-template');
|
||||
const path = require('path');
|
||||
const base = require('../base');
|
||||
const mix = require('../../utils/mix');
|
||||
|
||||
module.exports = (req, res) => {
|
||||
const uid = req.params.uid;
|
||||
|
||||
base({
|
||||
req: req,
|
||||
res: res,
|
||||
getHTML: (callback) => {
|
||||
request.get({
|
||||
url: `https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history?host_uid=${uid}`,
|
||||
headers: {
|
||||
'User-Agent': mix.ua,
|
||||
'Referer': `https://space.bilibili.com/${uid}/`
|
||||
}
|
||||
}, (err, httpResponse, body) => {
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(body);
|
||||
}
|
||||
catch (e) {
|
||||
data = {};
|
||||
}
|
||||
const result = data.data && data.data.cards || {};
|
||||
|
||||
const html = art(path.resolve(__dirname, '../../views/rss.art'), {
|
||||
title: `${result[0].desc.user_profile.info.uname} 的 bilibili 动态`,
|
||||
link: `https://space.bilibili.com/${uid}/#/dynamic`,
|
||||
description: `${result[0].desc.user_profile.info.uname} 的 bilibili 动态`,
|
||||
lastBuildDate: new Date().toUTCString(),
|
||||
item: result.map((item) => {
|
||||
const parsed = JSON.parse(item.card);
|
||||
const data = parsed.item || parsed;
|
||||
|
||||
// img
|
||||
let imgHTML = '';
|
||||
if (data.pictures) {
|
||||
for (let i = 0; i < data.pictures.length; i++) {
|
||||
imgHTML += `<img referrerpolicy="no-referrer" src="${data.pictures[i].img_src}">`;
|
||||
}
|
||||
}
|
||||
if (data.pic) {
|
||||
imgHTML += `<img referrerpolicy="no-referrer" src="${data.pic}">`;
|
||||
}
|
||||
|
||||
// link
|
||||
let link = '';
|
||||
if (data.dynamic_id) {
|
||||
link = `https://t.bilibili.com/${data.dynamic_id}`;
|
||||
}
|
||||
else if (data.aid) {
|
||||
link = `https://www.bilibili.com/video/av${data.aid}`;
|
||||
}
|
||||
else if (data.id) {
|
||||
link = `https://h.bilibili.com/${data.id}`;
|
||||
}
|
||||
|
||||
return {
|
||||
title: data.title || data.description || data.content,
|
||||
description: `${data.desc || data.description || data.content}${imgHTML}`,
|
||||
pubDate: new Date((data.pubdate || data.upload_time || data.timestamp) * 1000).toUTCString(),
|
||||
link: link
|
||||
};
|
||||
}),
|
||||
});
|
||||
callback(html);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
const request = require('request');
|
||||
const art = require('art-template');
|
||||
const path = require('path');
|
||||
const base = require('../base');
|
||||
const mix = require('../../utils/mix');
|
||||
|
||||
module.exports = (req, res) => {
|
||||
const uid = req.params.uid;
|
||||
|
||||
base({
|
||||
req: req,
|
||||
res: res,
|
||||
getHTML: (callback) => {
|
||||
request.post({
|
||||
url: 'https://space.bilibili.com/ajax/member/GetInfo',
|
||||
headers: {
|
||||
'User-Agent': mix.ua,
|
||||
'Referer': `https://space.bilibili.com/${uid}/`,
|
||||
'Origin': 'https://space.bilibili.com'
|
||||
},
|
||||
form: {
|
||||
mid: uid
|
||||
}
|
||||
}, function (err, httpResponse, body) {
|
||||
const name = JSON.parse(body).data.name;
|
||||
request.get({
|
||||
url: `https://api.bilibili.com/x/v2/fav/video?vmid=${uid}&ps=30&tid=0&keyword=&pn=1&order=fav_time`,
|
||||
headers: {
|
||||
'User-Agent': mix.ua,
|
||||
'Referer': `https://space.bilibili.com/${uid}/#/favlist`
|
||||
}
|
||||
}, function (err, httpResponse, body) {
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(body);
|
||||
}
|
||||
catch (e) {
|
||||
data = {};
|
||||
}
|
||||
|
||||
const html = art(path.resolve(__dirname, '../../views/rss.art'), {
|
||||
title: `${name} 的 bilibili 收藏夹`,
|
||||
link: `https://space.bilibili.com/${uid}/#/favlist`,
|
||||
description: `${name} 的 bilibili 收藏夹`,
|
||||
lastBuildDate: new Date().toUTCString(),
|
||||
item: data.data && data.data.archives && data.data.archives.map((item) => ({
|
||||
title: item.title,
|
||||
description: `${item.desc}<br><img referrerpolicy="no-referrer" src="${item.pic}">`,
|
||||
pubDate: new Date(item.fav_at * 1000).toUTCString(),
|
||||
link: `https://www.bilibili.com/video/av${item.aid}`
|
||||
})),
|
||||
});
|
||||
callback(html);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
const request = require('request');
|
||||
const art = require('art-template');
|
||||
const path = require('path');
|
||||
const base = require('../base');
|
||||
const mix = require('../../utils/mix');
|
||||
|
||||
module.exports = (req, res) => {
|
||||
const tid = req.params.tid;
|
||||
|
||||
base({
|
||||
req: req,
|
||||
res: res,
|
||||
getHTML: (callback) => {
|
||||
request.get({
|
||||
url: `https://api.bilibili.com/x/web-interface/newlist?ps=15&rid=${tid}&_=${+new Date()}`,
|
||||
headers: {
|
||||
'User-Agent': mix.ua,
|
||||
'Referer': 'https://www.bilibili.com/'
|
||||
}
|
||||
}, (err, httpResponse, body) => {
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(body);
|
||||
}
|
||||
catch (e) {
|
||||
data = {};
|
||||
}
|
||||
|
||||
const list = data.data && data.data.archives;
|
||||
let name = '未知';
|
||||
if (list && list[0] && list[0].tname) {
|
||||
name = list[0].tname;
|
||||
}
|
||||
|
||||
const html = art(path.resolve(__dirname, '../../views/rss.art'), {
|
||||
title: `bilibili ${name}分区`,
|
||||
link: 'https://www.bilibili.com',
|
||||
description: `bilibili ${name}分区`,
|
||||
lastBuildDate: new Date().toUTCString(),
|
||||
item: list && list.map((item) => ({
|
||||
title: `${item.title} - ${item.owner.name}`,
|
||||
description: `${item.desc}<img referrerpolicy="no-referrer" src="${item.pic}">`,
|
||||
pubDate: new Date(item.pubdate * 1000).toUTCString(),
|
||||
link: `https://www.bilibili.com/video/av${item.aid}`
|
||||
})),
|
||||
});
|
||||
callback(html);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
const request = require('request');
|
||||
const art = require('art-template');
|
||||
const path = require('path');
|
||||
const base = require('../base');
|
||||
const mix = require('../../utils/mix');
|
||||
|
||||
module.exports = (req, res) => {
|
||||
const uid = req.params.uid;
|
||||
|
||||
base({
|
||||
req: req,
|
||||
res: res,
|
||||
getHTML: (callback) => {
|
||||
request.post({
|
||||
url: 'https://space.bilibili.com/ajax/member/GetInfo',
|
||||
headers: {
|
||||
'User-Agent': mix.ua,
|
||||
'Referer': `https://space.bilibili.com/${uid}/`,
|
||||
'Origin': 'https://space.bilibili.com'
|
||||
},
|
||||
form: {
|
||||
mid: uid
|
||||
}
|
||||
}, function (err, httpResponse, body) {
|
||||
const name = JSON.parse(body).data.name;
|
||||
request.get({
|
||||
url: `https://api.bilibili.com/x/v2/fav/video?vmid=${uid}&ps=30&tid=0&keyword=&pn=1&order=fav_time`,
|
||||
headers: {
|
||||
'User-Agent': mix.ua,
|
||||
'Referer': `https://space.bilibili.com/${uid}/`,
|
||||
}
|
||||
}, function (err, httpResponse, body) {
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(body);
|
||||
}
|
||||
catch (e) {
|
||||
data = {};
|
||||
}
|
||||
|
||||
const html = art(path.resolve(__dirname, '../../views/rss.art'), {
|
||||
title: `${name} 的 bilibili 空间`,
|
||||
link: `https://space.bilibili.com/${uid}`,
|
||||
description: `${name} 的 bilibili 空间`,
|
||||
lastBuildDate: new Date().toUTCString(),
|
||||
item: data.data && data.data.archives && data.data.archives.map((item) => ({
|
||||
title: `${item.title} - ${item.owner.name}`,
|
||||
description: `${item.desc}<br><img referrerpolicy="no-referrer" src="${item.pic}">`,
|
||||
pubDate: new Date(item.pubdate * 1000).toUTCString(),
|
||||
link: `https://www.bilibili.com/video/av${item.aid}`
|
||||
})),
|
||||
});
|
||||
callback(html);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
Loading…
Reference in New Issue