feat: support 5music new releases (#18628)

* feat: support 5music new releases

* fix: Please use .toArray() instead.

* fix: warnning

* fix: reviews
This commit is contained in:
Nagara 2025-03-19 11:31:42 +08:00 committed by GitHub
parent f0ea62cc33
commit 8a943edae9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 96 additions and 0 deletions

View File

@ -0,0 +1,87 @@
import { Route } from '@/types';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
export const route: Route = {
path: '/new-releases/:category?',
categories: ['shopping'],
example: '/5music/new-releases',
parameters: { category: 'Category, see below, defaults to all' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['www.5music.com.tw/New_releases.asp', 'www.5music.com.tw/'],
target: '/new-releases',
},
],
name: '新貨上架',
maintainers: ['gideonsenku'],
handler,
description: `Categories:
| | 西 | | | |
| ---- | ---- | ---- | ---- | ---- |
| A | B | F | M | D |`,
url: 'www.5music.com.tw/New_releases.asp',
};
async function handler(ctx) {
const category = ctx.req.param('category') ?? 'A';
const url = `https://www.5music.com.tw/New_releases.asp?mut=${category}`;
const { data } = await got(url);
const $ = load(data);
const items = $('.releases-list .tbody > .box')
.toArray()
.map((item) => {
const $item = $(item);
const cells = $item.find('.td');
// 解析艺人名称 (可能包含中英文名)
const artistCell = $(cells[0]);
const artist = artistCell
.find('a')
.toArray()
.map((el) => $(el).text().trim())
.join(' / ');
// 解析专辑信息
const albumCell = $(cells[1]);
const album = albumCell.find('a').first().text().trim();
const albumLink = albumCell.find('a').first().attr('href');
const releaseDate = $(cells[2]).text().trim();
const company = $(cells[3]).text().trim();
const format = $(cells[4]).text().trim();
return {
title: `${artist} - ${album}`,
description: `
<p>艺人: ${artist}</p>
<p>专辑: ${album}</p>
<p>发行公司: ${company}</p>
<p>格式: ${format}</p>
<p>发行日期: ${releaseDate}</p>
`,
link: albumLink ? `https://www.5music.com.tw/${albumLink}` : url,
pubDate: parseDate(releaseDate),
category: format,
author: artist,
};
});
return {
title: '五大唱片 - 新货上架',
link: url,
item: items,
language: 'zh-tw',
};
}

View File

@ -0,0 +1,9 @@
import type { Namespace } from '@/types';
export const namespace: Namespace = {
name: '五大唱片',
url: '5music.com.tw',
lang: 'zh-TW',
categories: ['shopping'],
description: '五大唱片是台湾五大唱片股份有限公司的简称成立于1990年是台湾最大的唱片公司之一。',
};