mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-19 06:38:55 +08:00
fix(route): fix route chiculture that can not parse date correctly sometimes (#12161)
* fix(route): chiculture can not parse date correctly sometimes * fix: radar target
This commit is contained in:
@@ -3703,7 +3703,7 @@ router.get('/gab/popular/:sort?', lazyloadRouteHandler('./routes/gab/explore'));
|
|||||||
router.get('/phrack', lazyloadRouteHandler('./routes/phrack/index'));
|
router.get('/phrack', lazyloadRouteHandler('./routes/phrack/index'));
|
||||||
|
|
||||||
// 通識·現代中國
|
// 通識·現代中國
|
||||||
router.get('/chiculture/topic/:category?', lazyloadRouteHandler('./routes/chiculture/topic'));
|
// router.get('/chiculture/topic/:category?', lazyloadRouteHandler('./routes/chiculture/topic'));
|
||||||
|
|
||||||
// CQUT News
|
// CQUT News
|
||||||
router.get('/cqut/news', lazyloadRouteHandler('./routes/universities/cqut/cqut-news'));
|
router.get('/cqut/news', lazyloadRouteHandler('./routes/universities/cqut/cqut-news'));
|
||||||
|
|||||||
3
lib/v2/chiculture/maintainer.js
Normal file
3
lib/v2/chiculture/maintainer.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
'/topic/:category?': ['nczitzk'],
|
||||||
|
};
|
||||||
16
lib/v2/chiculture/radar.js
Normal file
16
lib/v2/chiculture/radar.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
module.exports = {
|
||||||
|
'chiculture.org.hk': {
|
||||||
|
_name: '通識・現代中國',
|
||||||
|
'.': [
|
||||||
|
{
|
||||||
|
title: '議題熱話',
|
||||||
|
docs: 'https://docs.rsshub.app/new-media.html#tong-shi-・-xian-dai-zhong-guo',
|
||||||
|
source: ['/tc/hot-topics'],
|
||||||
|
target: (_, url) => {
|
||||||
|
const searchParams = new URL(url).searchParams;
|
||||||
|
return `/chiculture${searchParams.has('category') ? `/${searchParams.get('category')}` : ''}`;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
3
lib/v2/chiculture/router.js
Normal file
3
lib/v2/chiculture/router.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = (router) => {
|
||||||
|
router.get('/topic/:category?', require('./topic'));
|
||||||
|
};
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
const got = require('@/utils/got');
|
const got = require('@/utils/got');
|
||||||
const date = require('@/utils/date');
|
|
||||||
const cheerio = require('cheerio');
|
const cheerio = require('cheerio');
|
||||||
|
const timezone = require('@/utils/timezone');
|
||||||
|
const { parseDate } = require('@/utils/parse-date');
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
const category = ctx.params.category || '';
|
const category = ctx.params.category || '';
|
||||||
@@ -15,7 +16,7 @@ module.exports = async (ctx) => {
|
|||||||
const list = response.data.data.map((item) => ({
|
const list = response.data.data.map((item) => ({
|
||||||
title: item.title,
|
title: item.title,
|
||||||
pubDate: item.tags,
|
pubDate: item.tags,
|
||||||
link: `${rootUrl}/${item.url}`,
|
link: `${rootUrl}${item.url}`,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const items = await Promise.all(
|
const items = await Promise.all(
|
||||||
@@ -30,16 +31,17 @@ module.exports = async (ctx) => {
|
|||||||
const pubDate = detailResponse.data.match(/上載日期:(.*)<\/p>/);
|
const pubDate = detailResponse.data.match(/上載日期:(.*)<\/p>/);
|
||||||
|
|
||||||
if (pubDate) {
|
if (pubDate) {
|
||||||
item.pubDate = date(pubDate[1]);
|
item.pubDate = parseDate(pubDate[1]);
|
||||||
} else if (item.title.indexOf('一周時事通識') > -1) {
|
} else if (item.title.indexOf('一周時事通識') > -1) {
|
||||||
for (const tag of item.pubDate) {
|
for (const tag of item.pubDate) {
|
||||||
if (tag.title.match(/^\d{4}年$/)) {
|
if (tag.title.match(/^\d{4}年$/)) {
|
||||||
item.pubDate = date(`${tag.title.replace('年', '')}-${item.title.replace(/)/g, '').split('- ')[1].split('/').reverse().join('-')}`);
|
const monthDayStr = item.title.split('- ')[1] ? item.title.split('- ')[1] : item.title.split('-')[1];
|
||||||
|
item.pubDate = timezone(parseDate(monthDayStr, 'D/M'), +8);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (item.title.match(/^\d{4}年新聞回顧$/)) {
|
} else if (item.title.match(/^\d{4}年新聞回顧$/)) {
|
||||||
item.pubDate = date(`${item.title.split('年')[0]}-12-31`);
|
item.pubDate = parseDate(`${item.title.split('年')[0]}-12-31`);
|
||||||
} else {
|
} else {
|
||||||
item.pubDate = '';
|
item.pubDate = '';
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user