diff --git a/lib/routes/dsndsht23/index.js b/lib/routes/dsndsht23/index.js index 44f0e0359..69f87758f 100644 --- a/lib/routes/dsndsht23/index.js +++ b/lib/routes/dsndsht23/index.js @@ -1,5 +1,6 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); +const url = require('url'); const host = 'https://www.sehuatang.net/'; @@ -90,7 +91,10 @@ module.exports = async (ctx) => { } } const description = (postMessage.html() || '抓取原帖失败').replace(/ignore_js_op/g, 'div'); - const enclosureUrl = postMessage.find('div.blockcode li').text(); + + const magnet = postMessage.find('div.blockcode li').text(); + const isMag = magnet.startsWith('magnet'); + const enclosureUrl = isMag ? magnet : url.resolve(host, postMessage.find('a[href^=forum\\.php\\?mod\\=attachment]:not([href$=nothumb\\=yes])').attr('href')); const single = { title: title, @@ -98,7 +102,7 @@ module.exports = async (ctx) => { description: description, pubDate: new Date(date).toUTCString(), enclosure_url: enclosureUrl, - enclosure_type: 'application/x-bittorrent', + enclosure_type: isMag ? 'application/x-bittorrent' : 'application/octet-stream', }; if (description !== '抓取原帖失败') { ctx.cache.set(itemUrl, JSON.stringify(single));