diff --git a/lib/router.js b/lib/router.js
index 9ba588b47..a5a00f7c9 100644
--- a/lib/router.js
+++ b/lib/router.js
@@ -911,7 +911,7 @@ router.get('/4gamers/tag/:tag', lazyloadRouteHandler('./routes/4gamers/tag'));
router.get('/4gamers/topic/:topic', lazyloadRouteHandler('./routes/4gamers/topic'));
// 大麦网
-router.get('/damai/activity/:city/:category/:subcategory/:keyword?', lazyloadRouteHandler('./routes/damai/activity'));
+// router.get('/damai/activity/:city/:category/:subcategory/:keyword?', lazyloadRouteHandler('./routes/damai/activity'));
// 桂林电子科技大学新闻资讯
router.get('/guet/xwzx/:type?', lazyloadRouteHandler('./routes/guet/news'));
diff --git a/lib/routes/damai/activity.js b/lib/routes/damai/activity.js
deleted file mode 100644
index f20245c46..000000000
--- a/lib/routes/damai/activity.js
+++ /dev/null
@@ -1,28 +0,0 @@
-const got = require('@/utils/got');
-
-module.exports = async (ctx) => {
- const city = ctx.params.city === '全部' ? '' : ctx.params.city;
- const category = ctx.params.category === '全部' ? '' : ctx.params.category;
- const subcategory = ctx.params.subcategory === '全部' ? '' : ctx.params.subcategory;
- const keyword = ctx.params.keyword ? ctx.params.keyword : '';
-
- const url = `https://search.damai.cn/searchajax.html?keyword=${encodeURIComponent(keyword)}&cty=${encodeURIComponent(city)}&ctl=${encodeURIComponent(category)}&sctl=${encodeURIComponent(
- subcategory
- )}&tsg=0&st=&et=&order=3&pageSize=30&currPage=1&tn=`;
-
- const response = await got.get(url);
- const data = response.data;
- const list = data.pageData.resultData;
-
- ctx.state.data = {
- title: `大麦网票务 - ${city ? city : '全国'} - ${category ? category : '全部分类'}${subcategory ? ' - ' + subcategory : ''}${keyword ? ' - ' + keyword : ''}`,
- link: 'https://search.damai.cn/search.htm',
- item: list.map((item) => ({
- title: item.nameNoHtml,
- author: item.actors ? item.actors.replace(/<[^<>]*>/, '') : '大麦网',
- description: `
${item.description}
地点:${item.venuecity} | ${item.venue}
时间:${item.showtime}
票价:${item.price_str}
`, - pubDate: new Date(), - link: `https://detail.damai.cn/item.htm?id=${item.projectid}`, - })), - }; -}; diff --git a/lib/v2/damai/activity.js b/lib/v2/damai/activity.js new file mode 100644 index 000000000..bc6bb8ea9 --- /dev/null +++ b/lib/v2/damai/activity.js @@ -0,0 +1,44 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { art } = require('@/utils/render'); +const { join } = require('path'); + +module.exports = async (ctx) => { + const city = ctx.params.city === '全部' ? '' : ctx.params.city; + const category = ctx.params.category === '全部' ? '' : ctx.params.category; + const subcategory = ctx.params.subcategory === '全部' ? '' : ctx.params.subcategory; + const keyword = ctx.params.keyword ? ctx.params.keyword : ''; + + const url = 'https://search.damai.cn/searchajax.html'; + + const response = await got(url, { + searchParams: { + keyword, + cty: city, + ctl: category, + sctl: subcategory, + tsg: 0, + st: '', + et: '', + order: 3, + pageSize: 30, + currPage: 1, + tn: '', + }, + }); + const data = response.data; + const list = data.pageData.resultData || []; + + ctx.state.data = { + title: `大麦网票务 - ${city || '全国'} - ${category || '全部分类'}${subcategory ? ' - ' + subcategory : ''}${keyword ? ' - ' + keyword : ''}`, + link: 'https://search.damai.cn/search.htm', + item: list.map((item) => ({ + title: item.nameNoHtml, + author: item.actors ? cheerio.load(item.actors, null, false).text() : '大麦网', + description: art(join(__dirname, 'templates/activity.art'), { + item, + }), + link: `https://detail.damai.cn/item.htm?id=${item.projectid}`, + })), + }; +}; diff --git a/lib/v2/damai/maintainer.js b/lib/v2/damai/maintainer.js new file mode 100644 index 000000000..1e5144889 --- /dev/null +++ b/lib/v2/damai/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/activity/:city/:category/:subcategory/:keyword?': ['hoilc'], +}; diff --git a/lib/v2/damai/radar.js b/lib/v2/damai/radar.js new file mode 100644 index 000000000..bd47baad7 --- /dev/null +++ b/lib/v2/damai/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'damai.cn': { + _name: '大麦网', + search: [ + { + title: '票务更新', + docs: 'https://docs.rsshub.app/routes/shopping#da-mai-wang', + source: ['/search.html'], + target: (_params, url) => `/damai/activity/全部/全部/全部/${new URL(url).searchParams.get('keyword') || ''}`, + }, + ], + }, +}; diff --git a/lib/v2/damai/router.js b/lib/v2/damai/router.js new file mode 100644 index 000000000..98e08502e --- /dev/null +++ b/lib/v2/damai/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/activity/:city/:category/:subcategory/:keyword?', require('./activity')); +}; diff --git a/lib/v2/damai/templates/activity.art b/lib/v2/damai/templates/activity.art new file mode 100644 index 000000000..5e0e359c5 --- /dev/null +++ b/lib/v2/damai/templates/activity.art @@ -0,0 +1,5 @@ +{{@ item.description }}
+地点:{{ item.venuecity }} | {{ item.venue }}
+时间:{{ item.showtime }}
+票价:{{ item.price_str }}
diff --git a/website/docs/routes/shopping.mdx b/website/docs/routes/shopping.mdx index 749e0a035..767cdd6bc 100644 --- a/website/docs/routes/shopping.mdx +++ b/website/docs/routes/shopping.mdx @@ -239,7 +239,7 @@ For instance, in `https://www.zagg.com/en_us/new-arrivals?brand=164&cat=3038%2C3 ### 票务更新 {#da-mai-wang-piao-wu-geng-xin} -