diff --git a/docs/multimedia.md b/docs/multimedia.md
index 29595ac55..95a22b07e 100644
--- a/docs/multimedia.md
+++ b/docs/multimedia.md
@@ -1443,11 +1443,11 @@ JavDB 有多个备用域名,本路由默认使用永久域名
-## 色花堂中文论坛
+## 色花堂
### 分区帖子
-
+
**原创 BT 电影**
diff --git a/lib/router.js b/lib/router.js
index 6fa07be24..f04d80ad7 100644
--- a/lib/router.js
+++ b/lib/router.js
@@ -1639,11 +1639,11 @@ router.get('/enclavebooks/user/:uid', lazyloadRouteHandler('./routes/enclavebook
router.get('/enclavebooks/collection/:uid', lazyloadRouteHandler('./routes/enclavebooks/collection.js'));
// 色花堂
-router.get('/dsndsht23/picture/:subforumid', lazyloadRouteHandler('./routes/dsndsht23/index'));
-router.get('/dsndsht23/bt/:subforumid?', lazyloadRouteHandler('./routes/dsndsht23/index'));
-router.get('/dsndsht23/:subforumid?/:type?', lazyloadRouteHandler('./routes/dsndsht23/index'));
-router.get('/dsndsht23/:subforumid?', lazyloadRouteHandler('./routes/dsndsht23/index'));
-router.get('/dsndsht23', lazyloadRouteHandler('./routes/dsndsht23/index'));
+// router.get('/dsndsht23/picture/:subforumid', lazyloadRouteHandler('./routes/dsndsht23/index'));
+// router.get('/dsndsht23/bt/:subforumid?', lazyloadRouteHandler('./routes/dsndsht23/index'));
+// router.get('/dsndsht23/:subforumid?/:type?', lazyloadRouteHandler('./routes/dsndsht23/index'));
+// router.get('/dsndsht23/:subforumid?', lazyloadRouteHandler('./routes/dsndsht23/index'));
+// router.get('/dsndsht23', lazyloadRouteHandler('./routes/dsndsht23/index'));
// 数英网最新文章
router.get('/digitaling/index', lazyloadRouteHandler('./routes/digitaling/index'));
diff --git a/lib/routes/dsndsht23/index.js b/lib/v2/dsndsht23/index.js
similarity index 51%
rename from lib/routes/dsndsht23/index.js
rename to lib/v2/dsndsht23/index.js
index 0d68ba0bc..1aac5fe1f 100644
--- a/lib/routes/dsndsht23/index.js
+++ b/lib/v2/dsndsht23/index.js
@@ -1,6 +1,6 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
-const url = require('url');
+const { parseDate } = require('@/utils/parse-date');
const host = 'https://www.sehuatang.net/';
@@ -26,7 +26,7 @@ const forumIdMaps = {
};
module.exports = async (ctx) => {
- const subformName = ctx.params.subforumid || 'gqzwzm';
+ const subformName = ctx.params.subforumid ?? 'gqzwzm';
const subformId = subformName in forumIdMaps ? forumIdMaps[subformName] : subformName;
const typefilter = ctx.params.type ? `&filter=typeid&typeid=${ctx.params.type}` : '';
const link = `${host}forum.php?mod=forumdisplay&orderby=dateline&fid=${subformId}${typefilter}`;
@@ -35,9 +35,7 @@ module.exports = async (ctx) => {
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
};
let c;
- const response = await got({
- method: 'get',
- url: link,
+ const response = await got(link, {
headers,
hooks: {
beforeRedirect: [
@@ -57,65 +55,61 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('#threadlisttableid tbody[id^=normalthread]')
- .slice(0, 25)
+ .slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 25)
.map(function () {
const info = {
title: '[' + $(this).find('th em a').text() + '] ' + $(this).find('a.xst').text(),
link: $(this).find('a.xst').attr('href'),
- date: $(this).find('td.by').find('em span span').attr('title'),
+ date: $(this).find('td.by').find('em span span').attr('title') || $(this).find('td.by').find('em span').first().text(),
};
return info;
})
.get();
const out = await Promise.all(
- list.map(async (info) => {
+ list.map((info) => {
const title = info.title;
const date = info.date;
const itemUrl = host + info.link;
- const cache = await ctx.cache.get(itemUrl);
- if (cache) {
- return Promise.resolve(JSON.parse(cache));
- }
+ return ctx.cache.tryGet(itemUrl, async () => {
+ const response = await got(itemUrl, {
+ headers,
+ });
- const response = await got.get(itemUrl, { headers });
-
- const $ = cheerio.load(response.data);
- const postMessage = $("td[id^='postmessage']").slice(0, 1);
- const images = $(postMessage).find('img');
- for (let k = 0; k < images.length; k++) {
- if (!$(images[k]).attr('file') || $(images[k]).attr('file') === 'undefined') {
- $(images[k]).replaceWith('');
- } else {
- $(images[k]).replaceWith(`
`);
+ const $ = cheerio.load(response.data);
+ const postMessage = $("td[id^='postmessage']").slice(0, 1);
+ const images = $(postMessage).find('img');
+ for (let k = 0; k < images.length; k++) {
+ if (!$(images[k]).attr('file') || $(images[k]).attr('file') === 'undefined') {
+ $(images[k]).replaceWith('');
+ } else {
+ $(images[k]).replaceWith(`
`);
+ }
}
- }
- const description = (postMessage.html() || '抓取原帖失败').replace(/ignore_js_op/g, 'div');
+ const description = (postMessage.html() || '抓取原帖失败').replace(/ignore_js_op/g, 'div');
- const single = {
- title,
- link: itemUrl,
- description,
- pubDate: new Date(date).toUTCString(),
- };
- const magnet = postMessage.find('div.blockcode li').text();
- const isMag = magnet.startsWith('magnet');
- const torrent = postMessage.find('a[href^=forum\\.php\\?mod\\=attachment]:not([href$=nothumb\\=yes])').attr('href');
-
- const hasEnclosureUrl = isMag || torrent !== undefined;
- if (hasEnclosureUrl) {
- const enclosureUrl = isMag ? magnet : url.resolve(host, torrent);
- const enclosure = {
- enclosure_url: enclosureUrl,
- enclosure_type: isMag ? 'application/x-bittorrent' : 'application/octet-stream',
+ const single = {
+ title,
+ link: itemUrl,
+ description,
+ pubDate: date ? parseDate(date) : null,
};
- Object.assign(single, enclosure);
- }
- if (description !== '抓取原帖失败') {
- ctx.cache.set(itemUrl, JSON.stringify(single));
- }
- return Promise.resolve(single);
+ const magnet = postMessage.find('div.blockcode li').first().text();
+ const isMag = magnet.startsWith('magnet');
+ const torrent = postMessage.find('a[href^=forum\\.php\\?mod\\=attachment]:not([href$=nothumb\\=yes])').attr('href');
+
+ const hasEnclosureUrl = isMag || torrent !== undefined;
+ if (hasEnclosureUrl) {
+ const enclosureUrl = isMag ? magnet : new URL(torrent, host).href;
+ const enclosure = {
+ enclosure_url: enclosureUrl,
+ enclosure_type: isMag ? 'application/x-bittorrent' : 'application/octet-stream',
+ };
+ Object.assign(single, enclosure);
+ }
+ return single;
+ });
})
);
diff --git a/lib/v2/dsndsht23/maintainer.js b/lib/v2/dsndsht23/maintainer.js
new file mode 100644
index 000000000..599f29ca4
--- /dev/null
+++ b/lib/v2/dsndsht23/maintainer.js
@@ -0,0 +1,7 @@
+module.exports = {
+ '/bt/:subforumid?': ['qiwihui', 'junfengP', 'nczitzk'],
+ '/picture/:subforumid': ['qiwihui', 'junfengP', 'nczitzk'],
+ '/:subforumid?/:type?': ['qiwihui', 'junfengP', 'nczitzk'],
+ '/:subforumid?': ['qiwihui', 'junfengP', 'nczitzk'],
+ '/': ['qiwihui', 'junfengP', 'nczitzk'],
+};
diff --git a/lib/v2/dsndsht23/radar.js b/lib/v2/dsndsht23/radar.js
new file mode 100644
index 000000000..1037947f0
--- /dev/null
+++ b/lib/v2/dsndsht23/radar.js
@@ -0,0 +1,19 @@
+module.exports = {
+ 'sehuatang.net': {
+ _name: '色花堂',
+ '.': [
+ {
+ title: '分区帖子',
+ docs: 'https://docs.rsshub.app/multimedia.html#se-hua-tang-fen-qu-tie-zi',
+ source: ['/:category', '/'],
+ target: (params, url) => {
+ const theUrl = new URL(url);
+ const matches = String(theUrl).match(/forum-(\d)+-\d+/);
+ const fid = theUrl.searchParams.get('fid') || (matches ? matches[1] : '');
+ const tid = theUrl.searchParams.get('typeid');
+ return `/dsndsht23${fid ? `/${fid}` : ''}${tid ? `/${tid}` : ''}`;
+ },
+ },
+ ],
+ },
+};
diff --git a/lib/v2/dsndsht23/router.js b/lib/v2/dsndsht23/router.js
new file mode 100644
index 000000000..77b1145c7
--- /dev/null
+++ b/lib/v2/dsndsht23/router.js
@@ -0,0 +1,7 @@
+module.exports = function (router) {
+ router.get('/bt/:subforumid?', require('./index'));
+ router.get('/picture/:subforumid', require('./index'));
+ router.get('/:subforumid?/:type?', require('./index'));
+ router.get('/:subforumid?', require('./index'));
+ router.get('', require('./index'));
+};