-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat(route): add 秀动网 (#12489) * docs(maintainer): amend route path * update(route/showstart): remove 'keyword' param in '/event' path, add tags to xml title * refactor(route/showstart): extract service method * update(showstart/route): add '/search' path * update(route/showstart): add title for '/search' path, clean code * Update website/docs/routes/shopping.mdx * Update lib/v2/showstart/radar.js * Update lib/v2/showstart/radar.js * update(route/showstart): add request utils * update(showstart): use web api * update(showstart): add event tags * update(showstart): change pageSize * fix: add a note to crpsign calculation ---------
- Loading branch information
Showing
9 changed files
with
204 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,4 @@ | ||
module.exports = { | ||
HOST: 'https://www.showstart.com', | ||
TITLE: '秀动网', | ||
}; |
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,18 @@ | ||
const { TITLE, HOST } = require('./const'); | ||
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({ | ||
cityCode, | ||
showStyle, | ||
}); | ||
const { cityName, showName } = await fetchDictionary(cityCode, showStyle); | ||
const tags = [cityName, showName].filter((item) => Boolean(item)).join(' - '); | ||
ctx.state.data = { | ||
title: `${TITLE} - ${tags}`, | ||
link: HOST, | ||
item: items, | ||
}; | ||
}; |
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,4 @@ | ||
module.exports = { | ||
'/event/:cityCode/:showStyle?': ['lchtao26'], | ||
'/search/:keyword': ['lchtao26'], | ||
}; |
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,28 @@ | ||
module.exports = { | ||
'showstart.com': { | ||
_name: '秀动网', | ||
www: [ | ||
{ | ||
title: '演出更新', | ||
docs: 'https://docs.rsshub.app/routes/shopping#xiu-dong-wang-yan-chu-geng-xin', | ||
source: ['/event/list'], | ||
target: (_, url) => { | ||
const search = new URL(url).searchParams; | ||
const cityCode = search.get('cityCode') || 0; | ||
const showStyle = search.get('showStyle') || 0; | ||
return `/showstart/event/${cityCode}/${showStyle}`; | ||
}, | ||
}, | ||
{ | ||
title: '演出搜索', | ||
docs: 'https://docs.rsshub.app/routes/shopping#xiu-dong-wang-yan-chu-sou-suo', | ||
source: ['/event/list'], | ||
target: (_, url) => { | ||
const search = new URL(url).searchParams; | ||
const keyword = search.get('keyword') || ''; | ||
return `/showstart/search/${keyword}`; | ||
}, | ||
}, | ||
], | ||
}, | ||
}; |
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,4 @@ | ||
module.exports = (router) => { | ||
router.get('/event/:cityCode/:showStyle?', require('./event')); | ||
router.get('/search/:keyword', require('./search')); | ||
}; |
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,14 @@ | ||
const { TITLE, HOST } = require('./const'); | ||
const { fetchActivityList } = 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, | ||
}; | ||
}; |
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,53 @@ | ||
const { HOST } = require('./const'); | ||
const { getAccessToken, post } = require('./utils'); | ||
|
||
async function fetchActivityList( | ||
params = { | ||
pageNo: '1', | ||
pageSize: '30', | ||
cityCode: '', | ||
activityIds: '', | ||
coupon: '', | ||
keyword: '', | ||
organizerId: '', | ||
performerId: '', | ||
showStyle: '', | ||
showTime: '', | ||
showType: '', | ||
siteId: '', | ||
sortType: '', | ||
themeId: '', | ||
timeRange: '', | ||
tourId: '', | ||
type: '', | ||
tag: '', | ||
} | ||
) { | ||
const accessToken = await getAccessToken(); | ||
const resp = await post('/web/activity/list', accessToken, params); | ||
return { | ||
items: resp.result.result.map((item) => ({ | ||
title: item.title, | ||
link: `${HOST}/event/${item.id}`, | ||
description: `地点:${item.cityName} | ${item.siteName}`, | ||
})), | ||
}; | ||
} | ||
|
||
async function fetchDictionary(cityCode, showStyle) { | ||
const accessToken = await getAccessToken(); | ||
const resp = await post('/web/activity/list/params', accessToken); | ||
const target = resp.result.find((item) => item.cityCode === cityCode); | ||
if (!target) { | ||
return {}; | ||
} | ||
return { | ||
cityName: target.cityName, | ||
showName: target.styles.find((item) => item.key === showStyle)?.showName, | ||
}; | ||
} | ||
|
||
module.exports = { | ||
fetchActivityList, | ||
fetchDictionary, | ||
}; |
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,67 @@ | ||
const got = require('@/utils/got'); | ||
const md5 = require('@/utils/md5'); | ||
|
||
const uuid = (length = 20) => { | ||
const e = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' + Date.now(); | ||
const r = []; | ||
for (let i = 0; i < length; i++) { | ||
r.push(e.charAt(Math.floor(Math.random() * e.length))); | ||
} | ||
return r.join(''); | ||
}; | ||
|
||
const cookieMap = new Map([['token', uuid(32).toLowerCase()]]); | ||
|
||
const devioceInfo = { | ||
vendorName: '', | ||
deviceMode: '', | ||
deviceName: '', | ||
systemName: '', | ||
systemVersion: '', | ||
cpuMode: ' ', // Note the space | ||
cpuCores: '', | ||
cpuArch: '', | ||
memerySize: '', | ||
diskSize: '', | ||
network: '', | ||
resolution: '1920*1080', | ||
pixelResolution: '', | ||
}; | ||
|
||
const getAccessToken = async () => { | ||
const { result } = await post('/waf/gettoken'); | ||
cookieMap.set('accessToken', result.accessToken.access_token); | ||
cookieMap.set('idToken', result.idToken.id_token); | ||
return cookieMap.get('accessToken'); | ||
}; | ||
|
||
const post = async (requestPath, accessToken = md5(Date.now().toString()), payload) => { | ||
const traceId = uuid(32) + Date.now(); | ||
|
||
const { data: response } = await got.post(`https://www.showstart.com/api${requestPath}`, { | ||
headers: { | ||
cdeviceinfo: encodeURIComponent(JSON.stringify(devioceInfo)), | ||
cdeviceno: cookieMap.get('token'), | ||
cookie: [...cookieMap.entries()].map(([key, value]) => `${key}=${value}`).join('; '), | ||
crpsign: md5(accessToken + /* sign/cusut (empty) + idToken (empty) + userInfo.userId (empty) + */ 'web' + cookieMap.get('token') + (payload ? JSON.stringify(payload) : '') + requestPath + '999web' + traceId), | ||
crtraceid: traceId, | ||
csappid: 'web', | ||
cterminal: 'web', | ||
cusat: accessToken, | ||
cusid: '', | ||
cusit: '', | ||
cusname: '', | ||
cusut: '', | ||
cversion: '999', | ||
}, | ||
json: payload, | ||
}); | ||
|
||
return response; | ||
}; | ||
|
||
module.exports = { | ||
post, | ||
getAccessToken, | ||
uuid, | ||
}; |
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