From fed70ac07decd13b9c7a2d9e0dac675d4a7b0cf7 Mon Sep 17 00:00:00 2001 From: cnkmmk <22782790+cnkmmk@users.noreply.github.com> Date: Fri, 22 Mar 2024 13:11:34 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E7=94=AC=E5=93=A5?= =?UTF-8?q?=E4=BE=83=E4=BE=83=E4=BE=83YouTube=E6=95=99=E7=A8=8B=E6=91=98?= =?UTF-8?q?=E8=A6=81=E9=9A=8F=E7=AC=94=20(#14885)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com> --- lib/routes/ygkkk/namespace.ts | 6 +++++ lib/routes/ygkkk/rss.ts | 48 +++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 lib/routes/ygkkk/namespace.ts create mode 100644 lib/routes/ygkkk/rss.ts diff --git a/lib/routes/ygkkk/namespace.ts b/lib/routes/ygkkk/namespace.ts new file mode 100644 index 000000000..c9495f6c5 --- /dev/null +++ b/lib/routes/ygkkk/namespace.ts @@ -0,0 +1,6 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: "甬哥侃侃侃YouTube教程摘要随笔", + url: 'ygkkk.blogspot.com', +}; diff --git a/lib/routes/ygkkk/rss.ts b/lib/routes/ygkkk/rss.ts new file mode 100644 index 000000000..df65a7eef --- /dev/null +++ b/lib/routes/ygkkk/rss.ts @@ -0,0 +1,48 @@ +import { Route } from '@/types'; +import got from '@/utils/got'; +import { load } from 'cheerio'; + +export const route: Route = { + path: '/', + categories: ['blog'], + example: '/ygkkk', + radar: [ + { + source: ['ygkkk.blogspot.com/'], + }, + ], + name: '最新发表', + maintainers: ['cnkmmk'], + handler, + url: 'ygkkk.blogspot.com/', +}; + +async function handler() { + const currentUrl = 'https://ygkkk.blogspot.com'; + const response = await got(`${currentUrl}/feeds/posts/default?alt=rss`); + const $ = load(response.data, { xmlMode: true }); + const title_main = $('channel > title').text(); + const description_main = $('channel > description').text(); + const items = $('channel > item') + .map((_, item) => { + const $item = $(item); + const link = $item.find('link').text(); + const title = $item.find('title').text(); + const description = $item.find('description').text(); + const pubDate = $item.find('pubDate').text(); + return { + link, + pubDate, // no need to normalize because it's from a valid RSS feed + title, + description, + }; + }) + .get(); + + return { + title: title_main, + description: description_main, + link: currentUrl, + item: items, + }; +}