mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 05:59:00 +08:00
fix(route): duplicate entries in the Blizzard feed (#12828)
* fix(route): duplicate entries in the Blizzard feed * refactor: migrate to v2 ---------
This commit is contained in:
@@ -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 |
|
||||
|
||||
</RouteEn>
|
||||
|
||||
|
||||
64
docs/game.md
64
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 |
|
||||
|
||||
</Route>
|
||||
|
||||
|
||||
@@ -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'));
|
||||
|
||||
3
lib/v2/blizzard/maintainer.js
Normal file
3
lib/v2/blizzard/maintainer.js
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/news/:language?/:category?': ['nczitzk'],
|
||||
};
|
||||
@@ -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;
|
||||
13
lib/v2/blizzard/radar.js
Normal file
13
lib/v2/blizzard/radar.js
Normal file
@@ -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?',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
3
lib/v2/blizzard/router.js
Normal file
3
lib/v2/blizzard/router.js
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/news/:language?/:category?', require('./news'));
|
||||
};
|
||||
Reference in New Issue
Block a user