mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-19 09:52:21 +08:00
feat(route): add osu! (#13366)
* feat(route): add osu! * Remove test code * Update lib/v2/osu/radar.js ---------
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { type = 'standard' } = ctx.params;
|
||||
|
||||
const link = `https://osu.ppy.sh/beatmaps/packs?type=${type}`;
|
||||
|
||||
const response = await got.get(link);
|
||||
const $ = cheerio.load(response.data);
|
||||
const itemList = $('.beatmap-pack');
|
||||
|
||||
ctx.state.data = {
|
||||
title: `osu! Beatmap Pack - ${type}`,
|
||||
link,
|
||||
item: itemList.toArray().map((element) => {
|
||||
const item = $(element);
|
||||
const title = item.find('.beatmap-pack__name').text().trim();
|
||||
const link = item.find('.beatmap-pack__header').attr('href');
|
||||
// Trying to get the description will return 429 (Too Many Requests).
|
||||
const description = item.find('.beatmap-pack__body').html();
|
||||
const pubDate = parseDate(item.find('.beatmap-pack__date').text(), 'YYYY-MM-DD');
|
||||
const author = item.find('.beatmap-pack__author--bold').text().trim();
|
||||
|
||||
return {
|
||||
title,
|
||||
link,
|
||||
description,
|
||||
pubDate,
|
||||
author,
|
||||
};
|
||||
}),
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/packs/:type?': ['JimenezLi'],
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'ppy.sh': {
|
||||
_name: 'osu!',
|
||||
osu: [
|
||||
{
|
||||
title: 'Beatmap Pack',
|
||||
docs: 'https://docs.rsshub.app/routes/game#osu-beatmap-packs',
|
||||
source: '/beatmaps/packs',
|
||||
target: (params, url) => `https://osu.ppy.sh/beatmaps/packs?type=${new URL(url).searchParams.get('type') ?? 'standard'}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/packs/:type?', require('./beatmaps/packs'));
|
||||
};
|
||||
@@ -398,6 +398,12 @@ Sorting types, default to `date`:
|
||||
|
||||
<Route author="hoilc" example="/nintendo/system-update" path="/nintendo/system-update"/>
|
||||
|
||||
## osu! {#osu}
|
||||
|
||||
### Beatmap Packs {#osu-beatmap-packs}
|
||||
|
||||
<Route author="JimenezLi" example="/osu/packs" path="/osu/packs/:type?" paramsDesc={['pack type, default to `standard`, can choose from `featured`, `tournament`, `loved`, `chart`, `theme` and `artist`']} radar="1"/>
|
||||
|
||||
## PlayStation Store {#playstation-store}
|
||||
|
||||
### Game List(Hong Kong) {#playstation-store-game-list-hong-kong}
|
||||
|
||||
Reference in New Issue
Block a user