mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-06 21:18:57 +08:00
feat: add common-utils (#2374)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const got = require('@/utils/got');
|
||||
const { toTitleCase } = require('@/utils/common-utils');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
@@ -34,19 +35,27 @@ module.exports = async (ctx) => {
|
||||
const result = list.map((item) => {
|
||||
const $ = cheerio.load(item);
|
||||
return {
|
||||
title: $('.product_title').text(),
|
||||
title: $('.product_title')
|
||||
.text()
|
||||
.trim(),
|
||||
url: 'https://www.metacritic.com' + $('.product_title > a').attr('href'),
|
||||
metascore: $('.brief_metascore').text(),
|
||||
userscore: $('.textscore').text(),
|
||||
date: $('.release_date > .data').text(),
|
||||
metascore: $('.brief_metascore')
|
||||
.text()
|
||||
.trim(),
|
||||
userscore: $('.textscore')
|
||||
.text()
|
||||
.trim(),
|
||||
date: $('.release_date > .data')
|
||||
.text()
|
||||
.trim(),
|
||||
};
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: `Metacritic ${ctx.params.platform} ${title}`,
|
||||
title: toTitleCase(`Metacritic ${ctx.params.platform} games ${title}`),
|
||||
link: url,
|
||||
item: result.map((item) => ({
|
||||
title: `${item.metascore === 'tbd' ? '' : [item.metascore]} ${item.title}`,
|
||||
title: `${item.metascore === 'tbd' ? '' : '[' + item.metascore + ']'} ${item.title}`,
|
||||
description: `Release Date: ${item.date} <br> Metacritic Score: ${item.metascore} <br> User Score: ${item.userscore} <br>`,
|
||||
link: item.url,
|
||||
})),
|
||||
|
||||
Reference in New Issue
Block a user