diff --git a/docs/en/multimedia.md b/docs/en/multimedia.md index 80545236e00811..97a2ff230a710c 100644 --- a/docs/en/multimedia.md +++ b/docs/en/multimedia.md @@ -66,6 +66,18 @@ Official RSS: https://eztv.io/ezrss.xml +## Melon + +### Chart + + + +| 24H | 일간 | 주간 | 월간 | +| - | - | - | - | +| | day | week | month | + + + ## Nyaa ### Seatch Result diff --git a/docs/multimedia.md b/docs/multimedia.md index c96f20bdd38a7f..cdc5e3a9c8b35b 100644 --- a/docs/multimedia.md +++ b/docs/multimedia.md @@ -443,6 +443,18 @@ pageClass: routes +## Melon + +### Chart + + + +| 24H | 일간 | 주간 | 월간 | +| --- | ---- | ---- | ----- | +| | day | week | month | + + + ## Mp4Ba ### 影视分类 diff --git a/lib/router.js b/lib/router.js index 5c591ef45f7009..41892a7ed69ebf 100644 --- a/lib/router.js +++ b/lib/router.js @@ -4071,6 +4071,9 @@ router.get('/jisilu/topic/:user', require('./routes/jisilu/topic')); // Constitutional Court of Baden-Württemberg (Germany) router.get('/verfghbw/press/:keyword?', require('./routes/verfghbw/press')); +// Melon +router.get('/melon/chart/:category?', require('./routes/melon/chart')); + // 弯弯字幕组 router.get('/wanwansub/info/:id', require('./routes/wanwansub/info')); router.get('/wanwansub/:id?', require('./routes/wanwansub/index')); diff --git a/lib/routes/melon/chart.js b/lib/routes/melon/chart.js new file mode 100644 index 00000000000000..e7388c8fc39d04 --- /dev/null +++ b/lib/routes/melon/chart.js @@ -0,0 +1,41 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const category = ctx.params.category; + + const rootUrl = 'https://www.melon.com'; + const currentUrl = `${rootUrl}/chart/${category ? category + '/' : ''}index.htm`; + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + const items = $('tr[data-song-no]') + .map((_, item) => { + item = $(item); + + const image = item + .find('.image_typeAll img') + .attr('src') + .split(/\/melon\//)[0]; + const title = item.find('.rank01').text(); + const name = item.find('.rank02').text(); + const album = item.find('.rank03').text(); + + return { + link: currentUrl, + title: item.find('.rank01').text(), + description: `

${title}

${name}

${album}

`, + }; + }) + .get(); + + ctx.state.data = { + title: $('title').text(), + link: currentUrl, + item: items, + }; +};