diff --git a/docs/en/program-update.md b/docs/en/program-update.md index 8a378e5fde103f..05b0de399cb3ae 100644 --- a/docs/en/program-update.md +++ b/docs/en/program-update.md @@ -116,7 +116,7 @@ Language ### BlueStacks 5 Release Notes - + ## Brave diff --git a/docs/program-update.md b/docs/program-update.md index 77a19d36a14f1c..e90bae9d159857 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -114,7 +114,7 @@ pageClass: routes ### BlueStacks 5 版本日誌 - + ## Brave diff --git a/lib/router.js b/lib/router.js index b66b4f55332f9b..22808d3df582f8 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3755,8 +3755,8 @@ router.get('/kingarthur/:type', lazyloadRouteHandler('./routes/kingarthur/index' // router.get('/news/whxw', lazyloadRouteHandler('./routes/news/whxw')); // 游讯网 -router.get('/yxdown/recommend', lazyloadRouteHandler('./routes/yxdown/recommend')); -router.get('/yxdown/news/:category?', lazyloadRouteHandler('./routes/yxdown/news')); +// router.get('/yxdown/recommend', lazyloadRouteHandler('./routes/yxdown/recommend')); +// router.get('/yxdown/news/:category?', lazyloadRouteHandler('./routes/yxdown/news')); // BabeHub router.get('/babehub/search/:keyword?', lazyloadRouteHandler('./routes/babehub/search')); diff --git a/lib/v2/yxdown/maintainer.js b/lib/v2/yxdown/maintainer.js new file mode 100644 index 00000000000000..1e79a5fc256f21 --- /dev/null +++ b/lib/v2/yxdown/maintainer.js @@ -0,0 +1,4 @@ +module.exports = { + '/news/:category?': ['nczitzk'], + '/recommend': ['nczitzk'], +}; diff --git a/lib/routes/yxdown/news.js b/lib/v2/yxdown/news.js similarity index 79% rename from lib/routes/yxdown/news.js rename to lib/v2/yxdown/news.js index 5813f7b1f89deb..3853b8f619c774 100644 --- a/lib/routes/yxdown/news.js +++ b/lib/v2/yxdown/news.js @@ -2,18 +2,20 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); const timezone = require('@/utils/timezone'); const { parseDate } = require('@/utils/parse-date'); +const { rootUrl, getCookie } = require('./utils'); module.exports = async (ctx) => { const category = ctx.params.category ? `${ctx.params.category}/` : ''; - const rootUrl = 'http://www.yxdown.com'; const currentUrl = `${rootUrl}/news/${category}`; - const response = await got({ - method: 'get', - url: currentUrl, - }); + const cookie = await getCookie(); + const response = await got(currentUrl, { + headers: { + cookie, + }, + }); const $ = cheerio.load(response.data); const list = $('.div_zixun h2 a') @@ -30,9 +32,10 @@ module.exports = async (ctx) => { const items = await Promise.all( list.map((item) => ctx.cache.tryGet(item.link, async () => { - const detailResponse = await got({ - method: 'get', - url: item.link, + const detailResponse = await got(item.link, { + headers: { + cookie, + }, }); const content = cheerio.load(detailResponse.data); diff --git a/lib/v2/yxdown/radar.js b/lib/v2/yxdown/radar.js new file mode 100644 index 00000000000000..759908846c0f14 --- /dev/null +++ b/lib/v2/yxdown/radar.js @@ -0,0 +1,19 @@ +module.exports = { + 'yxdown.com': { + _name: '游讯网', + '.': [ + { + title: '资讯', + docs: 'https://docs.rsshub.app/game.html#you-xun-wang', + source: ['/news/:category', '/news'], + target: (params) => `/yxdown/news${params.category ? `/${params.category}` : ''}`, + }, + { + title: '精彩推荐', + docs: 'https://docs.rsshub.app/game.html#you-xun-wang', + source: ['/'], + target: '/yxdown/recommend', + }, + ], + }, +}; diff --git a/lib/routes/yxdown/recommend.js b/lib/v2/yxdown/recommend.js similarity index 74% rename from lib/routes/yxdown/recommend.js rename to lib/v2/yxdown/recommend.js index 092e985d80dee5..cc41f56516e5dc 100644 --- a/lib/routes/yxdown/recommend.js +++ b/lib/v2/yxdown/recommend.js @@ -2,13 +2,15 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); const timezone = require('@/utils/timezone'); const { parseDate } = require('@/utils/parse-date'); +const { rootUrl, getCookie } = require('./utils'); module.exports = async (ctx) => { - const rootUrl = 'http://www.yxdown.com'; - const currentUrl = `${rootUrl}/news`; - const response = await got({ - method: 'get', - url: currentUrl, + const currentUrl = `${rootUrl}/news/`; + const cookie = await getCookie(); + const response = await got(currentUrl, { + headers: { + cookie, + }, }); const $ = cheerio.load(response.data); @@ -27,9 +29,10 @@ module.exports = async (ctx) => { const items = await Promise.all( list.map((item) => ctx.cache.tryGet(item.link, async () => { - const detailResponse = await got({ - method: 'get', - url: item.link, + const detailResponse = await got(item.link, { + headers: { + cookie, + }, }); const content = cheerio.load(detailResponse.data); diff --git a/lib/v2/yxdown/router.js b/lib/v2/yxdown/router.js new file mode 100644 index 00000000000000..cb735657ae64c1 --- /dev/null +++ b/lib/v2/yxdown/router.js @@ -0,0 +1,4 @@ +module.exports = (router) => { + router.get('/news/:category?', require('./news')); + router.get('/recommend', require('./recommend')); +}; diff --git a/lib/v2/yxdown/utils.js b/lib/v2/yxdown/utils.js new file mode 100644 index 00000000000000..73eb4e2f536324 --- /dev/null +++ b/lib/v2/yxdown/utils.js @@ -0,0 +1,17 @@ +const got = require('@/utils/got'); + +const rootUrl = 'http://www.yxdown.com'; + +const getCookie = async () => { + const cookieResponse = await got(rootUrl); + + const cookieRegx = /(?<=.cookie=").*(?=; path)/g; + const cookieStr = cookieResponse.data.match(cookieRegx)[0]; + + return cookieStr; +}; + +module.exports = { + rootUrl, + getCookie, +};