mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-05 04:11:26 +08:00
* fix(route) thepaper now use nextjs as backend * Id to Name for channel and list * summary ok * determine the detail by null check instead of type check * list_url for better reading * add failback of thumbnail * fix video article * add list for thepaper * add list for thepaper * del the dup line * small fix and optimize * add maintainer
71 lines
2.7 KiB
JavaScript
71 lines
2.7 KiB
JavaScript
const cheerio = require('cheerio');
|
|
const { parseDate } = require('@/utils/parse-date');
|
|
const got = require('@/utils/got');
|
|
const { art } = require('@/utils/render');
|
|
const path = require('path');
|
|
|
|
module.exports = {
|
|
ProcessItem: async (item, ctx) => {
|
|
if (item.link) {
|
|
// external link
|
|
return {
|
|
title: item.name,
|
|
link: item.link,
|
|
description: item.name,
|
|
pubDate: parseDate(item.pubTimeLong),
|
|
media: {
|
|
content: {
|
|
url: item.pic,
|
|
},
|
|
},
|
|
};
|
|
} else {
|
|
const itemUrl = `https://m.thepaper.cn/detail/${item.contId}`;
|
|
return await ctx.cache.tryGet(itemUrl, async () => {
|
|
const res = await got(itemUrl);
|
|
const data = JSON.parse(cheerio.load(res.data)('#__NEXT_DATA__').html());
|
|
const detailData = data.props.pageProps.detailData;
|
|
|
|
const contentDetail = detailData.contentDetail || detailData.liveDetail;
|
|
let description = contentDetail.content || contentDetail.summary;
|
|
|
|
if (contentDetail.videos) {
|
|
description =
|
|
art(path.join(__dirname, 'templates/video_detail.art'), {
|
|
videos: contentDetail.videos,
|
|
}) + description;
|
|
}
|
|
|
|
return {
|
|
title: contentDetail.name,
|
|
link: itemUrl,
|
|
description,
|
|
pubDate: parseDate(contentDetail.pubTime),
|
|
author: contentDetail.author,
|
|
media: {
|
|
content: {
|
|
url: item.pic || contentDetail.sharePic || (contentDetail.videos && contentDetail.videos.coverUrl),
|
|
},
|
|
thumbnails: {
|
|
url: item.pic || contentDetail.sharePic,
|
|
},
|
|
},
|
|
};
|
|
});
|
|
}
|
|
},
|
|
ChannelIdToName: (nodeId, next_data) => next_data.props.appProps.menu.channelList.find((c) => c.nodeId.toString() === nodeId.toString()).name,
|
|
ListIdToName: (listId, next_data) => {
|
|
const channelList = next_data.props.appProps.menu.channelList;
|
|
for (const c of channelList) {
|
|
if (c.childNodeList && c.childNodeList.length > 0) {
|
|
for (const l of c.childNodeList) {
|
|
if (l.nodeId.toString() === listId.toString()) {
|
|
return l.name;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
};
|