-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
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); | ||
require('fs').writeFileSync('./test_osu_429.html', String(response.data)); | ||
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, | ||
}; | ||
}), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
'/packs/:type?': ['JimenezLi'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = { | ||
'ppy.sh': { | ||
_name: 'osu!', | ||
osu: [ | ||
{ | ||
title: 'osu! 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'}`, | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = (router) => { | ||
router.get('/packs/:type?', require('./beatmaps/packs')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters