feat(route): add 甬哥侃侃侃YouTube教程摘要随笔 (#14885)
Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
import type { Namespace } from '@/types';
|
||||
|
||||
export const namespace: Namespace = {
|
||||
name: "甬哥侃侃侃YouTube教程摘要随笔",
|
||||
url: 'ygkkk.blogspot.com',
|
||||
};
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user