feat(route/秀动网): add more routes (#13884)
* feat(route): add artist route * feat(route): add brand route * chore: merge '/params' route into '/search' route * chore: fix and clean code * chore: sort new entries in alphabetical order. * chore: add new routes in maintainer * chore: sort maintain entries in alphabetical order. * fix: fix event route
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
const { TITLE, HOST } = require('./const');
|
||||
const { fetchPerformerInfo } = require('./service');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id;
|
||||
const artist = await fetchPerformerInfo({
|
||||
performerId: id,
|
||||
});
|
||||
ctx.state.data = {
|
||||
title: `${TITLE} - ${artist.name}`,
|
||||
description: artist.content,
|
||||
link: `${HOST}/artist/${artist.id}`,
|
||||
item: artist.activityList,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
const { TITLE, HOST } = require('./const');
|
||||
const { fetchBrandInfo } = require('./service');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id;
|
||||
const brand = await fetchBrandInfo({
|
||||
brandId: id,
|
||||
});
|
||||
ctx.state.data = {
|
||||
title: `${TITLE} - ${brand.name}`,
|
||||
description: brand.content,
|
||||
link: `${HOST}/host/${brand.id}`,
|
||||
item: brand.activityList,
|
||||
};
|
||||
};
|
||||
@@ -4,7 +4,7 @@ const { fetchActivityList, fetchDictionary } = require('./service');
|
||||
module.exports = async (ctx) => {
|
||||
const cityCode = parseInt(ctx.params.cityCode);
|
||||
const showStyle = parseInt(ctx.params.showStyle);
|
||||
const { items } = await fetchActivityList({
|
||||
const items = await fetchActivityList({
|
||||
cityCode,
|
||||
showStyle,
|
||||
});
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
module.exports = {
|
||||
'/artist/:id': ['lchtao26'],
|
||||
'/brand/:id': ['lchtao26'],
|
||||
'/event/:cityCode/:showStyle?': ['lchtao26'],
|
||||
'/search/:keyword': ['lchtao26'],
|
||||
'/search/:type/:keyword?': ['lchtao26'],
|
||||
};
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
const { TITLE, HOST } = require('./const');
|
||||
const { fetchCityList, fetchStyleList } = require('./service');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const type = ctx.params.type;
|
||||
switch (type) {
|
||||
case 'city':
|
||||
ctx.state.data = {
|
||||
title: `${TITLE} - 演出城市`,
|
||||
link: `HOST`,
|
||||
item: await fetchCityList(),
|
||||
};
|
||||
break;
|
||||
case 'style':
|
||||
ctx.state.data = {
|
||||
title: `${TITLE} - 演出风格`,
|
||||
link: HOST,
|
||||
item: await fetchStyleList(),
|
||||
};
|
||||
break;
|
||||
}
|
||||
};
|
||||
@@ -20,9 +20,21 @@ module.exports = {
|
||||
target: (_, url) => {
|
||||
const search = new URL(url).searchParams;
|
||||
const keyword = search.get('keyword') || '';
|
||||
return `/showstart/search/${keyword}`;
|
||||
return `/showstart/search/event/${keyword}`;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '音乐人 - 演出更新',
|
||||
docs: 'https://docs.rsshub.app/routes/shopping#yin-yue-ren-yan-chu-geng-xin',
|
||||
source: ['/artist/:id'],
|
||||
target: '/showstart/artist/:id',
|
||||
},
|
||||
{
|
||||
title: '厂牌 - 演出更新',
|
||||
docs: 'https://docs.rsshub.app/routes/shopping#chang-pai-yan-chu-geng-xin',
|
||||
source: ['/host/:id'],
|
||||
target: '/showstart/brand/:id',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/artist/:id', require('./artist'));
|
||||
router.get('/brand/:id', require('./brand'));
|
||||
router.get('/event/:cityCode/:showStyle?', require('./event'));
|
||||
router.get('/search/:keyword?', require('./search'));
|
||||
router.get('/params/:type', require('./params'));
|
||||
router.get('/search/:type/:keyword?', require('./search'));
|
||||
};
|
||||
|
||||
+47
-10
@@ -1,14 +1,51 @@
|
||||
const { TITLE, HOST } = require('./const');
|
||||
const { fetchActivityList } = require('./service');
|
||||
const { fetchActivityList, fetchPerformerList, fetchBrandList, fetchCityList, fetchStyleList } = require('./service');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const keyword = ctx.params.keyword;
|
||||
const { items } = await fetchActivityList({
|
||||
keyword,
|
||||
});
|
||||
ctx.state.data = {
|
||||
title: `${TITLE} - ${keyword}`,
|
||||
link: HOST,
|
||||
item: items,
|
||||
};
|
||||
const type = ctx.params.type || '';
|
||||
const keyword = ctx.params.keyword || '';
|
||||
|
||||
switch (type) {
|
||||
case 'event':
|
||||
ctx.state.data = {
|
||||
title: `${TITLE} - 搜演出 - ${keyword || '全部'}`,
|
||||
link: HOST,
|
||||
item: await fetchActivityList({ keyword }),
|
||||
};
|
||||
break;
|
||||
case 'artist':
|
||||
ctx.state.data = {
|
||||
title: `${TITLE} - 搜艺人 - ${keyword || '全部'}`,
|
||||
link: HOST,
|
||||
item: await fetchPerformerList({ searchKeyword: keyword }),
|
||||
};
|
||||
break;
|
||||
case 'brand':
|
||||
ctx.state.data = {
|
||||
title: `${TITLE} - 搜厂牌 - ${keyword || '全部'}`,
|
||||
link: HOST,
|
||||
item: await fetchBrandList({ searchKeyword: keyword }),
|
||||
};
|
||||
break;
|
||||
case 'city':
|
||||
ctx.state.data = {
|
||||
title: `${TITLE} - 搜城市 - ${keyword || '全部'}`,
|
||||
link: HOST,
|
||||
item: await fetchCityList(keyword),
|
||||
};
|
||||
break;
|
||||
case 'style':
|
||||
ctx.state.data = {
|
||||
title: `${TITLE} - 搜风格 - ${keyword || '全部'}`,
|
||||
link: HOST,
|
||||
item: await fetchStyleList(keyword),
|
||||
};
|
||||
break;
|
||||
default:
|
||||
ctx.state.data = {
|
||||
title: `${TITLE} - 搜演出 - ${type || '全部'}`,
|
||||
link: HOST,
|
||||
item: await fetchActivityList({ keyword: type }),
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
+94
-18
@@ -25,49 +25,121 @@ async function fetchActivityList(
|
||||
) {
|
||||
const accessToken = await getAccessToken();
|
||||
const resp = await post('/web/activity/list', accessToken, params);
|
||||
return resp.result.result.map((item) => formatActivity(item));
|
||||
}
|
||||
|
||||
function formatActivity(item) {
|
||||
const image = (src) => (src ? `<img src="${src}" />` : '');
|
||||
const time = (time) => (time ? `<p>演出时间:${time}</p>` : '');
|
||||
const address = (cityName, siteName) => (cityName || siteName ? `<p>地址:${[cityName, siteName].join(' - ')}</p>` : '');
|
||||
const performers = (name) => (name ? `<p>艺人:${name}</p>` : '');
|
||||
const price = (price) => (price ? `<p>票价:${price}</p>` : '');
|
||||
|
||||
return {
|
||||
items: resp.result.result.map((item) => ({
|
||||
title: item.title,
|
||||
link: `${HOST}/event/${item.id}`,
|
||||
description: [image(item.poster), time(item.showTime), address(item.cityName, item.siteName), performers(item.performers), price(item.price)].join(''),
|
||||
})),
|
||||
title: item.title,
|
||||
link: `${HOST}/event/${item.id}`,
|
||||
description: [image(item.poster), time(item.showTime), address(item.cityName, item.siteName), performers(item.performers), price(item.price)].join(''),
|
||||
};
|
||||
}
|
||||
|
||||
async function fetchPerformerList(
|
||||
params = {
|
||||
pageNo: '1',
|
||||
pageSize: '30',
|
||||
searchKeyword: '',
|
||||
styleId: '',
|
||||
}
|
||||
) {
|
||||
const accessToken = await getAccessToken();
|
||||
const resp = await post('/web/performer/list', accessToken, params);
|
||||
return resp.result.result.map((item) => ({
|
||||
title: item.name,
|
||||
link: `${HOST}/artist/${item.id}`,
|
||||
description: `id: ${item.id}`,
|
||||
}));
|
||||
}
|
||||
|
||||
async function fetchPerformerInfo(
|
||||
params = {
|
||||
performerId: '',
|
||||
}
|
||||
) {
|
||||
const accessToken = await getAccessToken();
|
||||
const resp = await post('/web/performer/info', accessToken, params);
|
||||
return {
|
||||
id: params.id,
|
||||
name: resp.result.name,
|
||||
content: resp.result.content,
|
||||
avatar: resp.result.avatar,
|
||||
poster: resp.result.poster,
|
||||
styles: resp.result.styles,
|
||||
activityList: resp.result.activities.map((item) => formatActivity(item)),
|
||||
};
|
||||
}
|
||||
|
||||
async function fetchBrandInfo(
|
||||
params = {
|
||||
brandId: '',
|
||||
}
|
||||
) {
|
||||
const accessToken = await getAccessToken();
|
||||
const resp = await post('/web/brand/info', accessToken, params);
|
||||
return {
|
||||
id: params.id,
|
||||
name: resp.result.name,
|
||||
content: resp.result.content,
|
||||
avatar: resp.result.avatar,
|
||||
poster: resp.result.poster,
|
||||
activityList: resp.result.activities.map((item) => formatActivity(item)),
|
||||
};
|
||||
}
|
||||
|
||||
async function fetchBrandList(
|
||||
params = {
|
||||
pageNo: '1',
|
||||
pageSize: '30',
|
||||
searchKeyword: '',
|
||||
}
|
||||
) {
|
||||
const accessToken = await getAccessToken();
|
||||
const resp = await post('/web/brand/list', accessToken, params);
|
||||
return resp.result.result.map((item) => ({
|
||||
title: item.name,
|
||||
link: `${HOST}/host/${item.id}`,
|
||||
description: `id: ${item.id}`,
|
||||
}));
|
||||
}
|
||||
|
||||
async function fetchParams() {
|
||||
const accessToken = await getAccessToken();
|
||||
return post('/web/activity/list/params', accessToken);
|
||||
}
|
||||
|
||||
async function fetchCityList() {
|
||||
async function fetchCityList(keyword = '') {
|
||||
const resp = await fetchParams();
|
||||
const cities = sortBy(resp.result, 'cityCode');
|
||||
return cities.map((item) => ({
|
||||
title: item.cityName,
|
||||
link: `${HOST}/event/list?cityCode=${item.cityCode}`,
|
||||
description: `cityCode: ${item.cityCode}`,
|
||||
}));
|
||||
return cities
|
||||
.filter((item) => item.cityName.includes(keyword.trim()))
|
||||
.map((item) => ({
|
||||
title: item.cityName,
|
||||
link: `${HOST}/event/list?cityCode=${item.cityCode}`,
|
||||
description: `cityCode: ${item.cityCode}`,
|
||||
}));
|
||||
}
|
||||
|
||||
// styles is embed in each city item
|
||||
// so we need to fetch all city items and then extract styles from them
|
||||
async function fetchStyleList() {
|
||||
async function fetchStyleList(keyword = '') {
|
||||
const resp = await fetchParams();
|
||||
let styles = resp.result.flatMap((item) => item.styles);
|
||||
styles = uniqBy(styles, 'key');
|
||||
styles = sortBy(styles, 'key');
|
||||
return styles.map((item) => ({
|
||||
title: item.showName,
|
||||
link: `${HOST}/event/list?showStyle=${item.key}`,
|
||||
description: `showStyle: ${item.key}`,
|
||||
}));
|
||||
return styles
|
||||
.filter((item) => item.showName.includes(keyword.trim()))
|
||||
.map((item) => ({
|
||||
title: item.showName,
|
||||
link: `${HOST}/event/list?showStyle=${item.key}`,
|
||||
description: `showStyle: ${item.key}`,
|
||||
}));
|
||||
}
|
||||
|
||||
async function fetchDictionary(cityCode, showStyle) {
|
||||
@@ -86,5 +158,9 @@ module.exports = {
|
||||
fetchActivityList,
|
||||
fetchCityList,
|
||||
fetchStyleList,
|
||||
fetchPerformerList,
|
||||
fetchPerformerInfo,
|
||||
fetchBrandList,
|
||||
fetchBrandInfo,
|
||||
fetchDictionary,
|
||||
};
|
||||
|
||||
@@ -711,10 +711,9 @@ For instance, in `https://www.zagg.com/en_us/new-arrivals?brand=164&cat=3038%2C3
|
||||
|
||||
:::tip
|
||||
|
||||
路由参数查询
|
||||
- 演出城市 `cityCode` 查询: `/showstart/search/city/:keyword`, 如: https://rsshub.app/showstart/search/city/杭州
|
||||
|
||||
- cityCode: https://rsshub.app/showstart/params/city
|
||||
- showStyle: https://rsshub.app/showstart/params/style
|
||||
- 演出风格 `showStyle` 查询: `/showstart/search/style/:keyword`,如: https://rsshub.app/showstart/search/style/摇滚
|
||||
|
||||
:::
|
||||
|
||||
@@ -722,6 +721,26 @@ For instance, in `https://www.zagg.com/en_us/new-arrivals?brand=164&cat=3038%2C3
|
||||
|
||||
<Route author="lchtao26" example="/showstart/search/live" path="/showstart/search/:keyword" paramsDesc={['搜索关键词']}/>
|
||||
|
||||
### 音乐人 - 演出更新 {#yin-yue-ren-yan-chu-geng-xin}
|
||||
|
||||
<Route author="lchtao26" example="/showstart/artist/301783" path="/showstart/artist/:id" paramsDesc={['音乐人 ID']}/>
|
||||
|
||||
:::tip
|
||||
|
||||
音乐人 ID 查询: `/showstart/search/artist/:keyword`,如: https://rsshub.app/showstart/search/artist/周杰伦
|
||||
|
||||
:::
|
||||
|
||||
### 厂牌 - 演出更新 {#chang-pai-yan-chu-geng-xin}
|
||||
|
||||
<Route author="lchtao26" example="/showstart/brand/34707" path="/showstart/brand/:id" paramsDesc={['厂牌 ID']}/>
|
||||
|
||||
:::tip
|
||||
|
||||
厂牌 ID 查询: `/showstart/search/brand/:keyword`,如: https://rsshub.app/showstart/search/brand/声场
|
||||
|
||||
:::
|
||||
|
||||
## 优衣库 {#you-yi-ku}
|
||||
|
||||
### Stylingbook {#you-yi-ku-stylingbook}
|
||||
|
||||
Reference in New Issue
Block a user