From 06d5a479033f6560c833d12fa3ba941cdcc87c6a Mon Sep 17 00:00:00 2001 From: junfengP <840282629@qq.com> Date: Thu, 21 Jan 2021 07:27:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=89=B2=E8=8A=B1=E5=A0=82=20(#6733)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/DIYgod/RSSHub/issues/6702 Co-authored-by: junfeng --- lib/routes/dsndsht23/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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));