From 9d4efc58bb0684e6de93832753f9367a51ca7791 Mon Sep 17 00:00:00 2001 From: Keo Date: Sat, 25 Oct 2025 13:52:04 +0800 Subject: [PATCH] feat(route): add NTR BLOG (#20369) * feat(route): add NTR BLOG * add feed lang * Update lib/routes/ntrblog/articles.ts Co-authored-by: Tony * Update lib/routes/ntrblog/articles.ts Co-authored-by: Tony * update removal selectors -------- --- lib/routes/ntrblog/articles.ts | 76 +++++++++++++++++++++++++++++++++ lib/routes/ntrblog/namespace.ts | 7 +++ 2 files changed, 83 insertions(+) create mode 100644 lib/routes/ntrblog/articles.ts create mode 100644 lib/routes/ntrblog/namespace.ts diff --git a/lib/routes/ntrblog/articles.ts b/lib/routes/ntrblog/articles.ts new file mode 100644 index 000000000..5f0d1468a --- /dev/null +++ b/lib/routes/ntrblog/articles.ts @@ -0,0 +1,76 @@ +import { Route, Data, DataItem } from '@/types'; +import cache from '@/utils/cache'; +import got from '@/utils/got'; +import { load } from 'cheerio'; +import Parser from 'rss-parser'; + +type CustomItem = { issued: string }; +const parser = new Parser({ + customFields: { + item: ['issued'], + }, +}); + +export const route: Route = { + path: '/articles', + categories: ['anime'], + example: '/ntrblog/articles', + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + nsfw: true, + }, + name: 'Articles', + maintainers: ['keocheung'], + radar: [ + { + source: ['ntrblog.com'], + }, + ], + handler, +}; + +async function handler(): Promise { + const feed = await parser.parseURL('https://ntrblog.com/atom.xml'); + + const items = await Promise.all( + feed.items.map((item) => { + if (!item.link) { + return item; + } + return cache.tryGet(item.link, async () => { + const { data: response } = await got(item.link); + const $ = load(response); + const content = $('div.article-body'); + content.find('#twitter-widget-1').remove(); + content.find('[id^="ldblog_related_articles_"]').remove(); + content.find('#ad2').remove(); + item.content = `
${content.html()}
`; + return item; + }); + }) + ); + + return { + title: feed.title || 'NTR BLOG(寝取られブログ)', + link: feed.link || 'https://ntrblog.com', + description: feed.description || 'NTR BLOG(寝取られブログ)最新文章', + image: feed.image?.url, + item: items.map( + (item): DataItem => ({ + title: item.title || '', + link: item.link || '', + author: item.author || '', + pubDate: item.issued ? new Date(item.issued) : undefined, + description: item.content || '', + image: item.enclosure?.url, + guid: item.guid, + }) + ), + language: 'ja', + }; +} diff --git a/lib/routes/ntrblog/namespace.ts b/lib/routes/ntrblog/namespace.ts new file mode 100644 index 000000000..a806a7853 --- /dev/null +++ b/lib/routes/ntrblog/namespace.ts @@ -0,0 +1,7 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: 'NTR BLOG(寝取られブログ)', + url: 'ntrblog.com', + lang: 'ja', +};