style: auto format

This commit is contained in:
github-actions[bot]
2023-02-07 15:13:35 +00:00
parent fbabfc2a21
commit e83d4864d7
3 changed files with 113 additions and 109 deletions
+12 -12
View File
@@ -891,18 +891,6 @@ IPFS 网关有可能失效,那时候换成其他网关。
<Route author="Cerebrater xosdy" example="/matters/author/az" path="/matters/author/:uid" :paramsDesc="['作者 id,可在作者主页的 URL 找到']" radar="1" rssbud="1"/>
## 迈凯伦赛车
### 文章
<Route author="Bubbu0129" example="/mclaren/en/all" path="/mclaren/:lang/:category?" :paramsDesc="['支持英语(en)、简体中文(zh)、与西班牙语(es)。', '默认输出所有媒体(all);见下表:']" radar="1" rssbud="1">
| 所有媒体 | 文章 | 报道 | 图库 | 视频 | 博客 | 图文 (Photo Essay) |
| -------- | ---- | ---- | ---- | ---- | ---- | ------------------ |
| all | article | report | gallery | video | blog | photo\_essay |
</Route>
## Mirror
### User
@@ -3027,6 +3015,18 @@ column 为 third 时可选的 category:
</Route>
## 迈凯伦赛车
### 文章
<Route author="Bubbu0129" example="/mclaren/en/all" path="/mclaren/:lang/:category?" :paramsDesc="['支持英语(en)、简体中文(zh)、与西班牙语(es)。', '默认输出所有媒体(all);见下表:']" radar="1" rssbud="1">
| 所有媒体 | 文章 | 报道 | 图库 | 视频 | 博客 | 图文 (Photo Essay) |
| ---- | ------- | ------ | ------- | ----- | ---- | ---------------- |
| all | article | report | gallery | video | blog | photo_essay |
</Route>
## 慢雾科技
### 动态
+83 -82
View File
@@ -4,92 +4,93 @@ const path = require('path');
const { art } = require('@/utils/render');
module.exports = async (ctx) => {
let baseUrl, apiUrl;
let title, description;
let lang = ctx.params.lang;
switch (lang) {
case 'en':
baseUrl = 'https://www.mclaren.com';
title = 'McLaren Racing – Official Website';
description = 'Latest news and insight from McLaren Racing. Team and driver updates, videos and McLaren Formula 1 LIVE commentary.';
lang = 'en-UK';
break;
case 'zh':
baseUrl = 'https://cn.mclaren.com';
title = '迈凯伦赛车 — 官方网站';
description = '来自迈凯伦一级方程式车队的最新消息。 查看车队和车手近况、视频以及比赛中的迈凯伦实况评论和实时数据。';
lang = 'zh-CN';
break;
case 'es':
baseUrl = 'https://es.mclaren.com';
title = 'McLaren Racing - Sitio web oficial';
description = 'Consulta las últimas noticias del equipo de Fórmula 1 McLaren. Incluye información sobre el equipo, las últimas actualizaciones de los pilotos y McLaren LIVE, una aplicación con la que podrás seguir los comentarios en directo.';
lang = 'es-ES';
break;
default:
throw Error(`Language '${lang}' is not supported.`);
};
let baseUrl, apiUrl;
let title, description;
let lang = ctx.params.lang;
switch (lang) {
case 'en':
baseUrl = 'https://www.mclaren.com';
title = 'McLaren Racing – Official Website';
description = 'Latest news and insight from McLaren Racing. Team and driver updates, videos and McLaren Formula 1 LIVE commentary.';
lang = 'en-UK';
break;
case 'zh':
baseUrl = 'https://cn.mclaren.com';
title = '迈凯伦赛车 — 官方网站';
description = '来自迈凯伦一级方程式车队的最新消息。 查看车队和车手近况、视频以及比赛中的迈凯伦实况评论和实时数据。';
lang = 'zh-CN';
break;
case 'es':
baseUrl = 'https://es.mclaren.com';
title = 'McLaren Racing - Sitio web oficial';
description =
'Consulta las últimas noticias del equipo de Fórmula 1 McLaren. Incluye información sobre el equipo, las últimas actualizaciones de los pilotos y McLaren LIVE, una aplicación con la que podrás seguir los comentarios en directo.';
lang = 'es-ES';
break;
default:
throw Error(`Language '${lang}' is not supported.`);
}
const { category = 'all' } = ctx.params;
const categoryArr = ['all', 'article', 'report', 'gallery', 'video', 'blog', 'photo_essay'];
if (!categoryArr.includes(category)) {
throw Error(`Category '${category}' is not supported.`);
};
const { category = 'all' } = ctx.params;
const categoryArr = ['all', 'article', 'report', 'gallery', 'video', 'blog', 'photo_essay'];
if (!categoryArr.includes(category)) {
throw Error(`Category '${category}' is not supported.`);
}
const link = baseUrl + '/racing/articles/';
apiUrl = baseUrl + '/racing/api/grid-search/?count=30&offset=0&type=';
// count: number of requested entries; default to 16, up to 30.
// offset: default to 0.
if (category !== 'all') {
apiUrl += category;
}
const link = baseUrl + '/racing/articles/';
apiUrl = baseUrl + '/racing/api/grid-search/?count=30&offset=0&type=';
// count: number of requested entries; default to 16, up to 30.
// offset: default to 0.
if (category !== 'all') {
apiUrl += category;
}
const response = await got(apiUrl);
const response = await got(apiUrl);
const html = response.data.html;
const $ = cheerio.load(html);
const list = $('li')
.toArray()
.map((item) => {
item = $(item);
const thumbnailUrl = item.find('div.start-grid-content__img').attr('style').slice(22, -2);
return {
link: baseUrl + item.find('a.start-grid-content__link').attr('href'),
thumbnailUrl, // Pass the thumbnail image
};
});
const html = response.data.html;
const $ = cheerio.load(html);
const list = $('li')
.toArray()
.map((item) => {
item = $(item);
const thumbnailUrl = item.find('div.start-grid-content__img').attr('style').slice(22, -2);
return {
link: baseUrl + item.find('a.start-grid-content__link').attr('href'),
thumbnailUrl, // Pass the thumbnail image
};
});
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const itemRep = await got(item.link);
const $ = cheerio.load(itemRep.data);
$('.livestream--wrapper').last().remove();
item.title = $('meta[property="og:title"]').attr('content').slice(17);
item.pubDate = Date.parse($('time[datetime]').first().attr('datetime'));
const artParams = {
desc: $('meta[property="og:description"]').attr('content'),
heroUrl: $('meta[property="og:image"]').attr('content'),
videoId: $('a[data-video-id]').attr('data-video-id'),
};
$('.meta--hold, .show-for-small').remove();
artParams.content = $('div.article-body').html();
item.description = art(path.join(__dirname, 'templates/desc.art'), artParams);
item.media = {
thumbnail: {
url: item.thumbnailUrl,
},
};
return item;
})
)
);
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const itemRep = await got(item.link);
const $ = cheerio.load(itemRep.data);
$('.livestream--wrapper').last().remove();
item.title = $('meta[property="og:title"]').attr('content').slice(17);
item.pubDate = Date.parse($('time[datetime]').first().attr('datetime'));
const artParams = {
desc: $('meta[property="og:description"]').attr('content'),
heroUrl: $('meta[property="og:image"]').attr('content'),
videoId: $('a[data-video-id]').attr('data-video-id'),
};
$('.meta--hold, .show-for-small').remove();
artParams.content = $('div.article-body').html();
item.description = art(path.join(__dirname, 'templates/desc.art'), artParams);
item.media = {
thumbnail: {
url: item.thumbnailUrl,
},
};
return item;
})
)
);
ctx.state.data = {
language: lang,
title,
description,
link,
item: items,
};
ctx.state.data = {
language: lang,
title,
description,
link,
item: items,
};
};
+18 -15
View File
@@ -1,25 +1,28 @@
module.exports = {
'mclaren.com': {
_name: 'Mclaren Racing',
www: [{
title: 'Mclaren Racing',
docs: 'https://docs.rsshub.app/new-media.html#mai-kai-lun-sai-che',
source: '/racing/articles/',
target: '/mclaren/en/all'
www: [
{
title: 'Mclaren Racing',
docs: 'https://docs.rsshub.app/new-media.html#mai-kai-lun-sai-che',
source: '/racing/articles/',
target: '/mclaren/en/all',
},
],
cn: [{
title: '迈凯伦赛车',
docs: 'https://docs.rsshub.app/new-media.html#mai-kai-lun-sai-che',
source: '/racing/articles/',
target: '/mclaren/zh/all'
cn: [
{
title: '迈凯伦赛车',
docs: 'https://docs.rsshub.app/new-media.html#mai-kai-lun-sai-che',
source: '/racing/articles/',
target: '/mclaren/zh/all',
},
],
es: [{
title: 'Mclaren Racing',
docs: 'https://docs.rsshub.app/new-media.html#mai-kai-lun-sai-che',
source: '/racing/articles/',
target: '/mclaren/es/all'
es: [
{
title: 'Mclaren Racing',
docs: 'https://docs.rsshub.app/new-media.html#mai-kai-lun-sai-che',
source: '/racing/articles/',
target: '/mclaren/es/all',
},
],
},