fix(route): nga 匿名帖子获取失败 (#10695)

* fix

* add new domain

* list format

* fix
This commit is contained in:
syrinka
2022-09-04 19:27:03 +08:00
committed by GitHub
parent cde7722bee
commit d0fcff9fbb
2 changed files with 36 additions and 50 deletions
+5 -2
View File
@@ -49,6 +49,9 @@ module.exports = async (ctx) => {
.replace(/\[font=(.+?)\](.+?)\[\/font\]/g, '<span style="font-family:$1;">$2</span>')
.replace(/\[size=(.+?)\](.+?)\[\/size\]/g, '<span style="font-size:$1;">$2</span>')
.replace(/\[align=(.+?)\](.+?)\[\/align\]/g, '<span style="text-align:$1;">$2</span>');
// 列表
str = deepReplace(str, /\[\*\](.+?)(?=\[\*\]|\[\/list\])/g, '<li>$1</li>');
str = deepReplace(str, /\[list\](.+?)\[\/list\]/g, '<ul>$1</ul>');
// 图片
str = str.replace(/\[img\](.+?)\[\/img\]/g, (m, src) => `<img src='${src[0] === '.' ? 'https://img.nga.178.com/attachments' + src.substr(1) : src}'></img>`);
// 折叠
@@ -58,7 +61,7 @@ module.exports = async (ctx) => {
.replace(/\[@(.+?)\]/g, '<a href="https://nga.178.com/nuke.php?func=ucp&username=$1">@$1</a>')
.replace(/\[uid=(\d+)\](.+?)\[\/uid\]/g, '<a href="https://nga.178.com/nuke.php?func=ucp&uid=$1">@$2</a>')
.replace(/\[tid=(\d+)\](.+?)\[\/tid\]/g, '<a href="https://nga.178.com/read.php?tid=$1">$2</a>')
.replace(/\[pid=(\d+),(\d+),(\d+)\](.+?)\[\/pid\]/g, (m, tid, pid, page, str) => {
.replace(/\[pid=(\d+),(\d+),(\d+)\](.+?)\[\/pid\]/g, (m, pid, tid, page, str) => {
const url = `https://nga.178.com/read.php?tid=${tid}&page=${page}#pid${pid}Anchor`;
return `<a href="${url}">${str}</a>`;
});
@@ -91,7 +94,7 @@ module.exports = async (ctx) => {
.find('.posterinfo a')
.first()
.attr('href')
.match(/&uid=(\d+)/)[1];
.match(/&uid=(-?\d+)$/)[1];
const poster = authorName || posterMap[posterId].username;
const content = post.find('.postcontent').first();
const description = formatContent(content.html());
+31 -48
View File
@@ -1,56 +1,39 @@
const rules = [
{
title: '分区帖子',
docs: 'https://docs.rsshub.app/bbs.html#nga-fen-qu-tie-zi',
source: '/thread.php',
target: (params, url) => new URL(url).searchParams.get('fid') && `/nga/forum/${new URL(url).searchParams.get('fid')}`,
},
{
title: '帖子',
docs: 'https://docs.rsshub.app/bbs.html#nga-tie-zi',
source: '/read.php',
target: (params, url) => new URL(url).searchParams.get('tid') && `/nga/post/${new URL(url).searchParams.get('tid')}`,
},
{
title: '帖子 - 只看作者',
docs: 'https://docs.rsshub.app/bbs.html#nga-tie-zi',
source: '/read.php',
target: (params, url, document) => {
const tid = new URL(url).searchParams.get('tid');
const authorId = document.documentElement.innerHTML.match(/commonui\.userInfo\.setAll\(\s{3}{"(\d+)"/)[1];
return `/nga/post/${tid}/${authorId}`;
},
},
];
module.exports = {
'nga.cn': {
_name: 'NGA',
bbs: [
{
title: '分区帖子',
docs: 'https://docs.rsshub.app/bbs.html#nga-fen-qu-tie-zi',
source: '/thread.php',
target: (params, url) => new URL(url).searchParams.get('fid') && `/nga/forum/${new URL(url).searchParams.get('fid')}`,
},
{
title: '帖子',
docs: 'https://docs.rsshub.app/bbs.html#nga-tie-zi',
source: '/read.php',
target: (params, url) => new URL(url).searchParams.get('tid') && `/nga/post/${new URL(url).searchParams.get('tid')}`,
},
{
title: '帖子 - 只看作者',
docs: 'https://docs.rsshub.app/bbs.html#nga-tie-zi',
source: '/read.php',
target: (params, url, document) => {
const tid = new URL(url).searchParams.get('tid');
const authorId = document.documentElement.innerHTML.match(/commonui\.userInfo\.setAll\(\s{3}{"(\d+)"/)[1];
return `/nga/post/${tid}/${authorId}`;
},
},
],
bbs: rules,
},
'178.com': {
_name: 'NGA',
nga: [
{
title: '分区帖子',
docs: 'https://docs.rsshub.app/bbs.html#nga-fen-qu-tie-zi',
source: '/thread.php',
target: (params, url) => new URL(url).searchParams.get('fid') && `/nga/forum/${new URL(url).searchParams.get('fid')}`,
},
{
title: '帖子',
docs: 'https://docs.rsshub.app/bbs.html#nga-tie-zi',
source: '/read.php',
target: (params, url) => new URL(url).searchParams.get('tid') && `/nga/post/${new URL(url).searchParams.get('tid')}`,
},
{
title: '帖子 - 只看作者',
docs: 'https://docs.rsshub.app/bbs.html#nga-tie-zi',
source: '/read.php',
target: (params, url, document) => {
const tid = new URL(url).searchParams.get('tid');
const authorId = document.documentElement.innerHTML.match(/commonui\.userInfo\.setAll\(\s{3}{"(\d+)"/)[1];
return `/nga/post/${tid}/${authorId}`;
},
},
],
nga: rules,
},
'ngabbs.com': {
_name: 'NGA',
'.': rules,
},
};