mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-13 00:35:19 +08:00
fix: undefined error when no magnet & torrent (#7745)
This commit is contained in:
@@ -92,18 +92,25 @@ module.exports = async (ctx) => {
|
||||
}
|
||||
const description = (postMessage.html() || '抓取原帖失败').replace(/ignore_js_op/g, 'div');
|
||||
|
||||
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,
|
||||
link: itemUrl,
|
||||
description,
|
||||
pubDate: new Date(date).toUTCString(),
|
||||
enclosure_url: enclosureUrl,
|
||||
enclosure_type: isMag ? 'application/x-bittorrent' : 'application/octet-stream',
|
||||
};
|
||||
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',
|
||||
};
|
||||
Object.assign(single, enclosure);
|
||||
}
|
||||
if (description !== '抓取原帖失败') {
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user