mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 06:30:40 +08:00
feat: Add method studios (#4570)
This commit is contained in:
@@ -43,6 +43,18 @@ pageClass: routes
|
||||
<Route author="miaoyafeng" example="/invisionapp/inside-design" path="/invisionapp/inside-design">
|
||||
</Route>
|
||||
|
||||
## Method Studios
|
||||
|
||||
### 菜单
|
||||
|
||||
<Route author="MisteryMonster" example="/method-studios/games" path="/method-studios/:menu?" :paramsDesc="['地址栏下 /en 后的栏目: `features`, `advertising`, `episodic`, `games`, `methodmade`']">
|
||||
|
||||
不支持`news`和`main`。
|
||||
|
||||
默认为 'https://www.methodstudios.com/en/features' 下的栏目。
|
||||
|
||||
</Route>
|
||||
|
||||
## UI 中国
|
||||
|
||||
### 推荐文章
|
||||
|
||||
@@ -43,6 +43,18 @@ Some tags are rarely used: `Script`, `direction`, `production`, `design-concep
|
||||
<RouteEn author="miaoyafeng" example="/invisionapp/inside-design" path="/invisionapp/inside-design">
|
||||
</RouteEn>
|
||||
|
||||
## Method Studios
|
||||
|
||||
### Menus
|
||||
|
||||
<RouteEn author="MisteryMonster" path="/method-studios/:menu?" example="/method-studios/games" :paramsDesc="['URL behind /en: `features`, `advertising`, `episodic`, `games`, `methodmade`']">
|
||||
|
||||
Not support `main`, `news`.
|
||||
|
||||
Default is under 'https://www.methodstudios.com/en/features'.
|
||||
|
||||
</RouteEn>
|
||||
|
||||
## Unit Image
|
||||
|
||||
### Films
|
||||
|
||||
@@ -2574,6 +2574,9 @@ router.get('/zhuixinfan/list', require('./routes/zhuixinfan/list'));
|
||||
// scoresaber
|
||||
router.get('/scoresaber/user/:id', require('./routes/scoresaber/user'));
|
||||
|
||||
// method-studios
|
||||
router.get('/method-studios/:menu?', require('./routes/method-studios/index'));
|
||||
|
||||
// blow-studio
|
||||
router.get('/blow-studio', require('./routes/blow-studio/work'));
|
||||
|
||||
|
||||
60
lib/routes/method-studios/index.js
Executable file
60
lib/routes/method-studios/index.js
Executable file
@@ -0,0 +1,60 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const menu = ctx.params.menu || 'features';
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `https://www.methodstudios.com/en/${menu}`,
|
||||
});
|
||||
const data = response.data;
|
||||
const $ = cheerio.load(data); // 使用 cheerio 加载返回的 HTML
|
||||
const list = $('div.grid>div.grid-item>div a').get().slice(0, 6);
|
||||
const articledata = await Promise.all(
|
||||
list.map(async (item) => {
|
||||
const link = `https:${$(item)
|
||||
.attr('href')
|
||||
.replace(/https:/, '')}`;
|
||||
|
||||
const cache = await ctx.cache.get(link);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
|
||||
const response2 = await got({
|
||||
method: 'get',
|
||||
url: link,
|
||||
});
|
||||
|
||||
const articleHtml = response2.data;
|
||||
const $2 = cheerio.load(articleHtml);
|
||||
|
||||
$2('div.carousel-text').remove();
|
||||
$2('div.carousel-nav').remove();
|
||||
$2('i').remove();
|
||||
const content = $2('.content-placeholder')
|
||||
.html()
|
||||
.replace(/<video*.+poster=/g, '<video controls="controls" poster=')
|
||||
.replace(/<div*.+>/g, '')
|
||||
.replace(/<.?div>/g, '');
|
||||
const single = {
|
||||
describe: content,
|
||||
title: $2('.content-placeholder').find('h2').text(),
|
||||
link: link,
|
||||
};
|
||||
ctx.cache.set(link, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `Method Studios | ${menu}`,
|
||||
link: 'https://www.methodstudios.com/',
|
||||
description: $('description').text(),
|
||||
item: list.map((item, index) => ({
|
||||
title: `${articledata[index].title}`,
|
||||
description: `${articledata[index].describe}`,
|
||||
link: `${articledata[index].link}`,
|
||||
})),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user