From 945769067133c5b78b7612529351f18fef3bb8f9 Mon Sep 17 00:00:00 2001 From: Tony Date: Fri, 1 Mar 2024 15:25:24 +0000 Subject: [PATCH 1/4] chore: fix labelling --- .github/labeler.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/labeler.yml b/.github/labeler.yml index f858c6c82..e8fbd45f7 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -10,7 +10,7 @@ core enhancement: - changed-files: - any-glob-to-any-file: ['lib/routes/index.ts'] - - all-globs-to-any-file: ['lib/**', '!/lib/config.ts', '!lib/routes/**'] + - all-globs-to-any-file: ['lib/**', '!/lib/config.ts', '!lib/routes/**', '!lib/routes-deprecated/**'] dependencies: - changed-files: From 8171d927f19a4898cf8656a59b24d7a6e8939252 Mon Sep 17 00:00:00 2001 From: Tony Date: Fri, 1 Mar 2024 23:57:02 +0800 Subject: [PATCH 2/4] fix(route): migrate tongli (#14618) --- lib/router.js | 2 +- lib/routes-deprecated/tongli/news.js | 45 ---------------------- lib/routes/tongli/maintainer.js | 3 ++ lib/routes/tongli/news.js | 56 ++++++++++++++++++++++++++++ lib/routes/tongli/radar.js | 16 ++++++++ lib/routes/tongli/router.js | 3 ++ website/docs/routes/reading.mdx | 6 +-- 7 files changed, 82 insertions(+), 49 deletions(-) delete mode 100644 lib/routes-deprecated/tongli/news.js create mode 100644 lib/routes/tongli/maintainer.js create mode 100644 lib/routes/tongli/news.js create mode 100644 lib/routes/tongli/radar.js create mode 100644 lib/routes/tongli/router.js diff --git a/lib/router.js b/lib/router.js index d2950d08e..007cbf31b 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1741,7 +1741,7 @@ router.get('/melon/chart/:category?', lazyloadRouteHandler('./routes/melon/chart // router.get('/zimuxia/:category?', lazyloadRouteHandler('./routes/zimuxia/index')); // 东立出版 -router.get('/tongli/news/:type', lazyloadRouteHandler('./routes/tongli/news')); +// router.get('/tongli/news/:type', lazyloadRouteHandler('./routes/tongli/news')); // 海南大学 router.get('/hainanu/ssszs', lazyloadRouteHandler('./routes/hainanu/ssszs')); diff --git a/lib/routes-deprecated/tongli/news.js b/lib/routes-deprecated/tongli/news.js deleted file mode 100644 index 3eb400293..000000000 --- a/lib/routes-deprecated/tongli/news.js +++ /dev/null @@ -1,45 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); -module.exports = async (ctx) => { - const { type } = ctx.params; - const baseURL = 'https://www.tongli.com.tw/'; - const link = `${baseURL}TNews_List.aspx?Type=${type}&Page=1`; - const res = await got.get(link); - const $ = cheerio.load(res.data); - const title = $('entry_title .n1').text(); - const _list = $('.news_list ul li') - .map(function () { - let link = $(this).find('.title a').attr('href'); - /^https?:\/\//.test(link) || (link = baseURL + link); - return { - title: $(this).find('.title a').text(), - link, - pubDate: new Date($(this).find('.date').text()), - }; - }) - .get(); - const list = await Promise.all( - _list.map(async (item) => { - const { title, link, pubDate } = item; - const description = await ctx.cache.tryGet(link, async () => { - const res = await got.get(link); - const $ = cheerio.load(res.data); - if (/^https:\/\/tonglinv\.pixnet\.net/.test(link)) { - return $('.article-content-inner').html(); - } else if (/^https?:\/\/blog\.xuite\.net\//.test(link)) { - return $('#content_all').html(); - } else if (/TNews_View\.aspx/.test(link)) { - return $('#ContentPlaceHolder1_TNewsContent').html(); - } else { - return ''; - } - }); - return { title, link, description, pubDate }; - }) - ); - ctx.state.data = { - title, - link, - item: list, - }; -}; diff --git a/lib/routes/tongli/maintainer.js b/lib/routes/tongli/maintainer.js new file mode 100644 index 000000000..14bdb5e1c --- /dev/null +++ b/lib/routes/tongli/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/news/:type': ['CokeMine'], +}; diff --git a/lib/routes/tongli/news.js b/lib/routes/tongli/news.js new file mode 100644 index 000000000..bfd486a28 --- /dev/null +++ b/lib/routes/tongli/news.js @@ -0,0 +1,56 @@ +import cache from '@/utils/cache'; +import got from '@/utils/got'; +import { parseDate } from '@/utils/parse-date'; +import * as cheerio from 'cheerio'; + +module.exports = async (ctx) => { + const { type } = ctx.req.param(); + const baseURL = 'https://www.tongli.com.tw/'; + const url = `${baseURL}TNews_List.aspx`; + const { data: res, url: link } = await got(url, { + searchParams: { + Type: type, + Page: 1, + }, + }); + const $ = cheerio.load(res); + + const list = $('.news_list ul li') + .toArray() + .map((item) => { + item = $(item); + const a = item.find('.title a'); + return { + title: a.text(), + link: a.attr('href').startsWith('http') ? a.attr('href') : baseURL + a.attr('href'), + pubDate: parseDate(item.find('.date').text(), 'YYYY.MM.DD'), + }; + }); + + const items = await Promise.all( + list.map((item) => + cache.tryGet(item.link, async () => { + const { data: res } = await got(item.link); + const $ = cheerio.load(res); + + if (/^https:\/\/tonglinv\.pixnet\.net/.test(item.link)) { + item.description = $('.article-content-inner').html(); + } else if (/^https?:\/\/blog\.xuite\.net\//.test(item.link)) { + item.description = $('#content_all').html(); + } else if (/TNews_View\.aspx/.test(item.link)) { + item.description = $('#ContentPlaceHolder1_TNewsContent').html(); + } else { + item.description = ''; + } + + return item; + }) + ) + ); + + ctx.set('data', { + title: $('.entry_title .n1').text(), + link, + item: items, + }); +}; diff --git a/lib/routes/tongli/radar.js b/lib/routes/tongli/radar.js new file mode 100644 index 000000000..ff2a3faad --- /dev/null +++ b/lib/routes/tongli/radar.js @@ -0,0 +1,16 @@ +module.exports = { + 'tongli.com.tw': { + _name: '東立出版社', + '.': [ + { + title: '新聞', + docs: 'https://docs.rsshub.app/routes/reading#dong-li-chu-ban-she', + source: ['/TNews_List.aspx'], + target: (_param, url) => { + const searchParams = new URL(url).searchParams; + return searchParams.has('Type') ? `/tongli/news/${searchParams.get('Type')}` : null; + }, + }, + ], + }, +}; diff --git a/lib/routes/tongli/router.js b/lib/routes/tongli/router.js new file mode 100644 index 000000000..2b5d6cd30 --- /dev/null +++ b/lib/routes/tongli/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/news/:type', '/news'); +}; diff --git a/website/docs/routes/reading.mdx b/website/docs/routes/reading.mdx index 6f69c7ba6..1a7130d20 100644 --- a/website/docs/routes/reading.mdx +++ b/website/docs/routes/reading.mdx @@ -234,11 +234,11 @@ | 0 | 1 | 2 | 3 | 4 | 6 | -## 东立出版 {#dong-li-chu-ban} +## 東立出版社 {#dong-li-chu-ban-she} -### NEWS 资讯 {#dong-li-chu-ban-news-zi-xun} +### 新聞 {#dong-li-chu-ban-she-xin-wen} - + ## 飞地 {#fei-di} From 62b5a8415958642d27e6cba936899670e0a9b989 Mon Sep 17 00:00:00 2001 From: Tony Date: Fri, 1 Mar 2024 20:26:57 +0000 Subject: [PATCH 3/4] chore: fix labelling --- .github/labeler.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/labeler.yml b/.github/labeler.yml index e8fbd45f7..55529fa85 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -10,7 +10,7 @@ core enhancement: - changed-files: - any-glob-to-any-file: ['lib/routes/index.ts'] - - all-globs-to-any-file: ['lib/**', '!/lib/config.ts', '!lib/routes/**', '!lib/routes-deprecated/**'] + - all-globs-to-any-file: ['lib/**', '!lib/config.ts', '!lib/router.js', '!lib/routes/**', '!lib/routes-deprecated/**'] dependencies: - changed-files: From 90d0b33febe8d9fd82266884223861a602d85bc0 Mon Sep 17 00:00:00 2001 From: Tony Date: Sat, 2 Mar 2024 04:28:57 +0800 Subject: [PATCH 4/4] fix(route): gamer ani (#14621) --- lib/router.js | 4 +-- lib/routes-deprecated/anigamer/anime.js | 14 -------- lib/routes-deprecated/anigamer/new-anime.js | 22 ------------- lib/routes/gamer/ani/anime.js | 33 +++++++++++++++++++ lib/routes/gamer/ani/new-anime.js | 21 ++++++++++++ lib/routes/gamer/maintainer.js | 2 ++ lib/routes/gamer/radar.js | 20 ++++++++++-- lib/routes/gamer/router.js | 2 ++ website/docs/routes/anime.mdx | 36 +++++++++++++++------ website/docs/routes/bbs.mdx | 6 ---- website/docs/routes/game.mdx | 14 -------- 11 files changed, 103 insertions(+), 71 deletions(-) delete mode 100644 lib/routes-deprecated/anigamer/anime.js delete mode 100644 lib/routes-deprecated/anigamer/new-anime.js create mode 100644 lib/routes/gamer/ani/anime.js create mode 100644 lib/routes/gamer/ani/new-anime.js diff --git a/lib/router.js b/lib/router.js index 007cbf31b..b1a0e8069 100644 --- a/lib/router.js +++ b/lib/router.js @@ -433,8 +433,8 @@ router.get('/miniflux/subscription/:parameters?', lazyloadRouteHandler('./routes router.get('/miniflux/:feeds/:parameters?', lazyloadRouteHandler('./routes/miniflux/get-entries')); // 動畫瘋 -router.get('/anigamer/new_anime', lazyloadRouteHandler('./routes/anigamer/new-anime')); -router.get('/anigamer/anime/:sn', lazyloadRouteHandler('./routes/anigamer/anime')); +// router.get('/anigamer/new_anime', lazyloadRouteHandler('./routes/anigamer/new-anime')); +// router.get('/anigamer/anime/:sn', lazyloadRouteHandler('./routes/anigamer/anime')); // 中国药科大学 router.get('/cpu/home', lazyloadRouteHandler('./routes/universities/cpu/home')); diff --git a/lib/routes-deprecated/anigamer/anime.js b/lib/routes-deprecated/anigamer/anime.js deleted file mode 100644 index a601f7365..000000000 --- a/lib/routes-deprecated/anigamer/anime.js +++ /dev/null @@ -1,14 +0,0 @@ -const got = require('@/utils/got'); - -module.exports = async (ctx) => { - const { anime } = await got.get(`https://api.gamer.com.tw/mobile_app/anime/v1/video.php?sn=0&anime_sn=${ctx.params.sn}`).then((r) => r.data); - ctx.state.data = { - title: anime.title, - link: `https://ani.gamer.com.tw/animeRef.php?sn=${anime.anime_sn}`, - description: ` ` + anime.content.trim(), - item: anime.volumes[0].map((item) => ({ - title: `${anime.title} 第 ${item.volume} 集`, - link: `https://ani.gamer.com.tw/animeVideo.php?sn=${item.video_sn}`, - })), - }; -}; diff --git a/lib/routes-deprecated/anigamer/new-anime.js b/lib/routes-deprecated/anigamer/new-anime.js deleted file mode 100644 index c974fda86..000000000 --- a/lib/routes-deprecated/anigamer/new-anime.js +++ /dev/null @@ -1,22 +0,0 @@ -const got = require('@/utils/got'); -const { parseDate } = require('@/utils/parse-date'); -const timezone = require('@/utils/timezone'); - -module.exports = async (ctx) => { - const rootUrl = 'https://ani.gamer.com.tw'; - const response = await got.get('https://api.gamer.com.tw/mobile_app/anime/v3/index.php'); - const newAnime = response.data.data.newAnime; - ctx.state.data = { - title: '動畫瘋最後更新', - link: `${rootUrl}/`, - item: newAnime.date.map((item) => { - const date = `${item.upTime} ${item.upTimeHours}`; - return { - title: `${item.title} ${item.volume}`, - description: ``, - link: `${rootUrl}/animeVideo.php?sn=${item.videoSn}`, - pubDate: timezone(parseDate(date, 'MM/DD HH:mm'), +8), - }; - }), - }; -}; diff --git a/lib/routes/gamer/ani/anime.js b/lib/routes/gamer/ani/anime.js new file mode 100644 index 000000000..2ac7189af --- /dev/null +++ b/lib/routes/gamer/ani/anime.js @@ -0,0 +1,33 @@ +import got from '@/utils/got'; + +module.exports = async (ctx) => { + const { sn } = ctx.req.param(); + + const { data: response } = await got('https://api.gamer.com.tw/mobile_app/anime/v3/video.php', { + searchParams: { + sn, + }, + }); + + if (response.error) { + throw new Error(response.error.message); + } + + const anime = response.data.anime; + const title = anime.title.replaceAll(/\[\d+?]$/g, '').trim(); + + const items = anime.volumes[0] + .map((item) => ({ + title: `${title} 第 ${item.volume} 集`, + description: ``, + link: `https://ani.gamer.com.tw/animeVideo.php?sn=${item.video_sn}`, + })) + .toReversed(); + + ctx.set('data', { + title, + link: `https://ani.gamer.com.tw/animeRef.php?sn=${anime.anime_sn}`, + description: anime.content?.trim(), + item: items, + }); +}; diff --git a/lib/routes/gamer/ani/new-anime.js b/lib/routes/gamer/ani/new-anime.js new file mode 100644 index 000000000..a7efac419 --- /dev/null +++ b/lib/routes/gamer/ani/new-anime.js @@ -0,0 +1,21 @@ +import got from '@/utils/got'; +import { parseDate } from '@/utils/parse-date'; +import timezone from '@/utils/timezone'; + +module.exports = async (ctx) => { + const rootUrl = 'https://ani.gamer.com.tw'; + const { data: response } = await got('https://api.gamer.com.tw/mobile_app/anime/v3/index.php'); + + const items = response.data.newAnime.date.map((item) => ({ + title: `${item.title} ${item.volume}`, + description: ``, + link: `${rootUrl}/animeVideo.php?sn=${item.videoSn}`, + pubDate: timezone(parseDate(`${item.upTime} ${item.upTimeHours}`, 'MM/DD HH:mm'), +8), + })); + + ctx.set('data', { + title: '動畫瘋最後更新', + link: rootUrl, + item: items, + }); +}; diff --git a/lib/routes/gamer/maintainer.js b/lib/routes/gamer/maintainer.js index c6b032f3c..5c102b0bc 100644 --- a/lib/routes/gamer/maintainer.js +++ b/lib/routes/gamer/maintainer.js @@ -1,4 +1,6 @@ module.exports = { + '/anime/:sn': ['maple3142'], '/gnn/:category?': ['Arracc'], '/hot/:bsn': ['nczitzk', 'TonyRL'], + '/new_anime': ['maple3142'], }; diff --git a/lib/routes/gamer/radar.js b/lib/routes/gamer/radar.js index d189edd40..bd52c80c2 100644 --- a/lib/routes/gamer/radar.js +++ b/lib/routes/gamer/radar.js @@ -4,15 +4,29 @@ module.exports = { acg: [ { title: 'GNN 新聞', - docs: 'https://docs.rsshub.app/routes/bbs#ba-ha-mu-te-dian-wan-zi-xun-zhan', + docs: 'https://docs.rsshub.app/routes/anime#ba-ha-mu-te-dian-wan-zi-xun-zhan', source: ['/news.php'], target: (params, url) => `/gamer/gnn/${new URL(url).searchParams.get('p')}`, }, ], + ani: [ + { + title: '動畫瘋 - 最後更新', + docs: 'https://docs.rsshub.app/routes/anime#ba-ha-mu-te-dian-wan-zi-xun-zhan', + source: ['/'], + target: '/gamer/new_anime', + }, + { + title: '動畫瘋 - 動畫', + docs: 'https://docs.rsshub.app/routes/anime#ba-ha-mu-te-dian-wan-zi-xun-zhan', + source: ['/animeVideo.php'], + target: (_params, url) => `/gamer/anime/${new URL(url).searchParams.get('sn')}`, + }, + ], forum: [ { title: '熱門推薦', - docs: 'https://docs.rsshub.app/routes/bbs#ba-ha-mu-te-dian-wan-zi-xun-zhan', + docs: 'https://docs.rsshub.app/routes/anime#ba-ha-mu-te-dian-wan-zi-xun-zhan', source: ['/A.php', '/B.php'], target: (params, url) => `/gamer/hot/${new URL(url).searchParams.get('bsn')}`, }, @@ -20,7 +34,7 @@ module.exports = { gnn: [ { title: 'GNN 新聞', - docs: 'https://docs.rsshub.app/routes/bbs#ba-ha-mu-te-dian-wan-zi-xun-zhan', + docs: 'https://docs.rsshub.app/routes/anime#ba-ha-mu-te-dian-wan-zi-xun-zhan', source: ['/index.php'], target: (params, url) => `/gamer/gnn/${new URL(url).searchParams.get('k')}`, }, diff --git a/lib/routes/gamer/router.js b/lib/routes/gamer/router.js index 394758b27..b3ef0c955 100644 --- a/lib/routes/gamer/router.js +++ b/lib/routes/gamer/router.js @@ -1,4 +1,6 @@ module.exports = function (router) { + router.get('/ani/anime/:sn', './ani/anime'); + router.get('/ani/new_anime', './ani/new-anime'); router.get('/gnn/:category?', './gnn-index'); router.get('/hot/:bsn', './hot'); }; diff --git a/website/docs/routes/anime.mdx b/website/docs/routes/anime.mdx index b82463fcb..f9599ca6d 100644 --- a/website/docs/routes/anime.mdx +++ b/website/docs/routes/anime.mdx @@ -556,6 +556,32 @@ You can use some RSS parsing libraries (like `feedpraser` in `Python`) to receiv +## 巴哈姆特電玩資訊站 {#ba-ha-mu-te-dian-wan-zi-xun-zhan} + +### GNN 新聞 {#ba-ha-mu-te-dian-wan-zi-xun-zhan-gnn-xin-wen} + + + | 首頁 | PC | TV 掌機 | 手機遊戲 | 動漫畫 | 主題報導 | 活動展覽 | 電競 | + | ---- | -- | ------- | -------- | ------ | -------- | -------- | ---- | + | 缺省 | 1 | 3 | 4 | 5 | 9 | 11 | 13 | + + | Switch | PS5 | PS4 | XboxOne | XboxSX | PC 單機 | PC 線上 | iOS | Android | Web | 漫畫 | 動畫 | + | ------ | --- | --- | ------- | ------ | ------- | ------- | --- | ------- | --- | ----- | ----- | + | ns | ps5 | ps4 | xbone | xbsx | pc | olg | ios | android | web | comic | anime | + + +### 熱門推薦 {#ba-ha-mu-te-dian-wan-zi-xun-zhan-re-men-tui-jian} + + + +### 動畫瘋 - 最後更新 {#ba-ha-mu-te-dian-wan-zi-xun-zhan-dong-hua-feng-zui-hou-geng-xin} + + + +### 動畫瘋 - 動畫 {#ba-ha-mu-te-dian-wan-zi-xun-zhan-dong-hua-feng-dong-hua} + + + ## 包子漫画 {#bao-zi-man-hua} ### 订阅漫画 {#bao-zi-man-hua-ding-yue-man-hua} @@ -578,16 +604,6 @@ You can use some RSS parsing libraries (like `feedpraser` in `Python`) to receiv | manhuaqingbao | qingxiaoshuoqingbao | manhuazhoubian | shengyouqingbao | yinyuezixun | youxizixun | meituxinshang | manzhanqingbao | dazahui | -## 動畫瘋 {#dong-hua-feng} - -### 最後更新 {#dong-hua-feng-zui-hou-geng-xin} - - - -### 動畫 {#dong-hua-feng-dong-hua} - - - ## 動漫狂 {#dong-man-kuang} ### 漫画更新 {#dong-man-kuang-man-hua-geng-xin} diff --git a/website/docs/routes/bbs.mdx b/website/docs/routes/bbs.mdx index dff5df015..22632efcb 100644 --- a/website/docs/routes/bbs.mdx +++ b/website/docs/routes/bbs.mdx @@ -374,12 +374,6 @@ If you opt to enable `fulltext` feature, consider adding `limit` parameter to yo -## 巴哈姆特電玩資訊站 {#ba-ha-mu-te-dian-wan-zi-xun-zhan} - -### 熱門推薦 {#ba-ha-mu-te-dian-wan-zi-xun-zhan-re-men-tui-jian} - - - ## 百度贴吧 {#bai-du-tie-ba} ### 帖子列表 {#bai-du-tie-ba-tie-zi-lie-biao} diff --git a/website/docs/routes/game.mdx b/website/docs/routes/game.mdx index 52b957f66..b78c9d2be 100644 --- a/website/docs/routes/game.mdx +++ b/website/docs/routes/game.mdx @@ -624,20 +624,6 @@ Due to the regional restrictions, an RSSHub deployment in China Mainland may not The year, month and day provided under UTC time zone are the same as the official website, so please ignore the specific time!!! -## 巴哈姆特 {#ba-ha-mu-te} - -### GNN 新聞 {#ba-ha-mu-te-gnn-xin-wen} - - - | 首頁 | PC | TV 掌機 | 手機遊戲 | 動漫畫 | 主題報導 | 活動展覽 | 電競 | - | ---- | -- | ------- | -------- | ------ | -------- | -------- | ---- | - | 缺省 | 1 | 3 | 4 | 5 | 9 | 11 | 13 | - - | Switch | PS5 | PS4 | XboxOne | XboxSX | PC 單機 | PC 線上 | iOS | Android | Web | 漫畫 | 動畫 | - | ------ | --- | --- | ------- | ------ | ------- | ------- | --- | ------- | --- | ----- | ----- | - | ns | ps5 | ps4 | xbone | xbsx | pc | olg | ios | android | web | comic | anime | - - ## 触乐 {#chu-le} ### 栏目 {#chu-le-lan-mu}