diff --git a/docs/en/game.md b/docs/en/game.md index ae8ef3fb42..f00174ef2e 100755 --- a/docs/en/game.md +++ b/docs/en/game.md @@ -15,16 +15,18 @@ Categories | Category | Slug | | ---------------------- | ------------------- | | All News | | +| Diablo II: Resurrected | diablo2 | | Diablo III | diablo3 | | Diablo IV | diablo4 | | Diablo: Immortal | diablo-immortal | | Hearthstone | hearthstone | | Heroes of the Storm | heroes-of-the-storm | -| Overwatch | overwatch | +| Overwatch 2 | overwatch | | StarCraft: Remastered | starcraft | | StarCraft II | starcraft2 | | World of Warcraft | world-of-warcraft | | Warcraft III: Reforged | warcraft3 | +| Battle.net | battlenet | | BlizzCon | blizzcon | | Inside Blizzard | blizzard | @@ -32,21 +34,20 @@ Language codes | Language | Code | | -------------- | ----- | -| Deutsch | de-de | -| English (US) | en-us | -| English (EU) | en-gb | -| Español (EU) | es-es | -| Español (AL) | es-mx | -| Français | fr-fr | -| Italiano | it-it | -| Português (AL) | pt-br | -| Polski | pl-pl | -| Русский | ru-ru | -| 한국어 | ko-kr | -| ภาษาไทย | th-th | -| 日本語 | ja-jp | -| 繁體中文 | zh-tw | -| 简体中文 | zh-cn | +| Deutsch | de-de | +| English (US) | en-us | +| English (EU) | en-gb | +| Español (EU) | es-es | +| Español (Latino) | es-mx | +| Français | fr-fr | +| Italiano | it-it | +| Português (Brasil) | pt-br | +| Polski | pl-pl | +| Русский | ru-ru | +| 한국어 | ko-kr | +| ภาษาไทย | th-th | +| 日本語 | ja-jp | +| 繁體中文 | zh-tw | diff --git a/docs/game.md b/docs/game.md index 78e8d88ebe..0f6e356323 100644 --- a/docs/game.md +++ b/docs/game.md @@ -60,40 +60,42 @@ pageClass: routes 分类 -| 分类 | 分类名 | -| -------------------- | ------------------- | -| 所有新闻 | | -| 暗黑破坏神 III | diablo3 | -| 暗黑破坏神:不朽 | diablo-immortal | -| 炉石传说 | hearthstone | -| 风暴英雄 | heroes-of-the-storm | -| 守望先锋 | overwatch | -| 星际争霸:重制版 | starcraft | -| 星际争霸 II | starcraft2 | -| 魔兽世界 | world-of-warcraft | -| 魔兽争霸 III:重制版 | warcraft3 | -| 暴雪嘉年华 | blizzcon | -| 走进暴雪 | blizzard | +| 分类 | 分类名 | +| ---------------------- | ------------------- | +| 所有新闻 | | +| Diablo II: Resurrected | diablo2 | +| 暗黑破坏神 III | diablo3 | +| 暗黑破坏神 IV | diablo4 | +| 暗黑破坏神:不朽 | diablo-immortal | +| 炉石传说 | hearthstone | +| 风暴英雄 | heroes-of-the-storm | +| 守望先锋 2 | overwatch | +| 星际争霸:重制版 | starcraft | +| 星际争霸 II | starcraft2 | +| 魔兽世界 | world-of-warcraft | +| 魔兽争霸 III:重制版 | warcraft3 | +| Battle.net | battlenet | +| 暴雪嘉年华 | blizzcon | +| 走进暴雪 | blizzard | 语言代码 -| 语言 | 语言代码 | -| -------------- | -------- | -| Deutsch | de-de | -| English (US) | en-us | -| English (EU) | en-gb | -| Español (EU) | es-es | -| Español (AL) | es-mx | -| Français | fr-fr | -| Italiano | it-it | -| Português (AL) | pt-br | -| Polski | pl-pl | -| Русский | ru-ru | -| 한국어 | ko-kr | -| ภาษาไทย | th-th | -| 日本語 | ja-jp | -| 繁體中文 | zh-tw | -| 简体中文 | zh-cn | +| 语言 | 语言代码 | +| ------------------ | -------- | +| Deutsch | de-de | +| English (US) | en-us | +| English (EU) | en-gb | +| Español (EU) | es-es | +| Español (Latino) | es-mx | +| Français | fr-fr | +| Italiano | it-it | +| Português (Brasil) | pt-br | +| Polski | pl-pl | +| Русский | ru-ru | +| 한국어 | ko-kr | +| ภาษาไทย | th-th | +| 日本語 | ja-jp | +| 繁體中文 | zh-tw | diff --git a/lib/router.js b/lib/router.js index 3ad08da3de..a210fdfd02 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3408,7 +3408,7 @@ router.get('/rescuetime/release-notes/:os?', lazyloadRouteHandler('./routes/resc router.get('/totalcommander/whatsnew', lazyloadRouteHandler('./routes/totalcommander/whatsnew')); // Blizzard -router.get('/blizzard/news/:language?/:category?', lazyloadRouteHandler('./routes/blizzard/news')); +// router.get('/blizzard/news/:language?/:category?', lazyloadRouteHandler('./routes/blizzard/news')); // DeepMind // router.get('/deepmind/blog/:category?', lazyloadRouteHandler('./routes/deepmind/blog')); diff --git a/lib/v2/blizzard/maintainer.js b/lib/v2/blizzard/maintainer.js new file mode 100644 index 0000000000..6ab639cac3 --- /dev/null +++ b/lib/v2/blizzard/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/news/:language?/:category?': ['nczitzk'], +}; diff --git a/lib/routes/blizzard/news.js b/lib/v2/blizzard/news.js similarity index 58% rename from lib/routes/blizzard/news.js rename to lib/v2/blizzard/news.js index 9302f7f97f..7f85a4c5cd 100644 --- a/lib/routes/blizzard/news.js +++ b/lib/v2/blizzard/news.js @@ -5,37 +5,36 @@ module.exports = async (ctx) => { const category = ctx.params.category || ''; const language = ctx.params.language || 'en-us'; - const rootUrl = `https://${language === 'zh-cn' ? 'cn.' : ''}news.blizzard.com`; + const rootUrl = 'https://news.blizzard.com'; const currentUrl = `${rootUrl}/${language}/${category}`; - const response = await got({ - method: 'get', - url: currentUrl, + const apiUrl = `${rootUrl}/${language}/blog/list`; + const response = await got(apiUrl, { + searchParams: { + community: category === '' ? 'all' : category, + }, }); - const $ = cheerio.load(response.data); + const $ = cheerio.load(response.data.html, null, false); - const list = $('.FeaturedArticle-text a, .ArticleListItem article a') - .slice(0, 10) - .map((_, item) => { + const list = $('.FeaturedArticle-text > a, .ArticleListItem > article > a') + .slice(0, ctx.query.limit ? parseInt(ctx.query.limit, 10) : 30) + .toArray() + .map((item) => { item = $(item); return { title: item.text(), link: `${rootUrl}${item.attr('href')}`, }; - }) - .get(); + }); 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); const content = cheerio.load(detailResponse.data); item.author = content('.ArticleDetail-bylineAuthor').text(); - item.description = content('.ArticleDetail-content').html(); + item.description = content('.ArticleDetail-headingImageBlock').html() + content('.ArticleDetail-content').html(); item.pubDate = content('.ArticleDetail-subHeadingLeft time').attr('timestamp'); return item; diff --git a/lib/v2/blizzard/radar.js b/lib/v2/blizzard/radar.js new file mode 100644 index 0000000000..2bfd592f4a --- /dev/null +++ b/lib/v2/blizzard/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'blizzard.com': { + _name: 'Blizzard', + news: [ + { + title: 'News', + docs: 'https://docs.rsshub.app/game.html#blizzard', + source: ['/:language/:category?', '/:language'], + target: '/blizzard/news/:language/:category?', + }, + ], + }, +}; diff --git a/lib/v2/blizzard/router.js b/lib/v2/blizzard/router.js new file mode 100644 index 0000000000..9aab65fa03 --- /dev/null +++ b/lib/v2/blizzard/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/news/:language?/:category?', require('./news')); +};