mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 15:21:59 +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 |
|
| Category | Slug |
|
||||||
| ---------------------- | ------------------- |
|
| ---------------------- | ------------------- |
|
||||||
| All News | |
|
| All News | |
|
||||||
|
| Diablo II: Resurrected | diablo2 |
|
||||||
| Diablo III | diablo3 |
|
| Diablo III | diablo3 |
|
||||||
| Diablo IV | diablo4 |
|
| Diablo IV | diablo4 |
|
||||||
| Diablo: Immortal | diablo-immortal |
|
| Diablo: Immortal | diablo-immortal |
|
||||||
| Hearthstone | hearthstone |
|
| Hearthstone | hearthstone |
|
||||||
| Heroes of the Storm | heroes-of-the-storm |
|
| Heroes of the Storm | heroes-of-the-storm |
|
||||||
| Overwatch | overwatch |
|
| Overwatch 2 | overwatch |
|
||||||
| StarCraft: Remastered | starcraft |
|
| StarCraft: Remastered | starcraft |
|
||||||
| StarCraft II | starcraft2 |
|
| StarCraft II | starcraft2 |
|
||||||
| World of Warcraft | world-of-warcraft |
|
| World of Warcraft | world-of-warcraft |
|
||||||
| Warcraft III: Reforged | warcraft3 |
|
| Warcraft III: Reforged | warcraft3 |
|
||||||
|
| Battle.net | battlenet |
|
||||||
| BlizzCon | blizzcon |
|
| BlizzCon | blizzcon |
|
||||||
| Inside Blizzard | blizzard |
|
| Inside Blizzard | blizzard |
|
||||||
|
|
||||||
@@ -36,17 +38,16 @@ Language codes
|
|||||||
| English (US) | en-us |
|
| English (US) | en-us |
|
||||||
| English (EU) | en-gb |
|
| English (EU) | en-gb |
|
||||||
| Español (EU) | es-es |
|
| Español (EU) | es-es |
|
||||||
| Español (AL) | es-mx |
|
| Español (Latino) | es-mx |
|
||||||
| Français | fr-fr |
|
| Français | fr-fr |
|
||||||
| Italiano | it-it |
|
| Italiano | it-it |
|
||||||
| Português (AL) | pt-br |
|
| Português (Brasil) | pt-br |
|
||||||
| Polski | pl-pl |
|
| Polski | pl-pl |
|
||||||
| Русский | ru-ru |
|
| Русский | ru-ru |
|
||||||
| 한국어 | ko-kr |
|
| 한국어 | ko-kr |
|
||||||
| ภาษาไทย | th-th |
|
| ภาษาไทย | th-th |
|
||||||
| 日本語 | ja-jp |
|
| 日本語 | ja-jp |
|
||||||
| 繁體中文 | zh-tw |
|
| 繁體中文 | zh-tw |
|
||||||
| 简体中文 | zh-cn |
|
|
||||||
|
|
||||||
</RouteEn>
|
</RouteEn>
|
||||||
|
|
||||||
|
|||||||
14
docs/game.md
14
docs/game.md
@@ -61,39 +61,41 @@ pageClass: routes
|
|||||||
分类
|
分类
|
||||||
|
|
||||||
| 分类 | 分类名 |
|
| 分类 | 分类名 |
|
||||||
| -------------------- | ------------------- |
|
| ---------------------- | ------------------- |
|
||||||
| 所有新闻 | |
|
| 所有新闻 | |
|
||||||
|
| Diablo II: Resurrected | diablo2 |
|
||||||
| 暗黑破坏神 III | diablo3 |
|
| 暗黑破坏神 III | diablo3 |
|
||||||
|
| 暗黑破坏神 IV | diablo4 |
|
||||||
| 暗黑破坏神:不朽 | diablo-immortal |
|
| 暗黑破坏神:不朽 | diablo-immortal |
|
||||||
| 炉石传说 | hearthstone |
|
| 炉石传说 | hearthstone |
|
||||||
| 风暴英雄 | heroes-of-the-storm |
|
| 风暴英雄 | heroes-of-the-storm |
|
||||||
| 守望先锋 | overwatch |
|
| 守望先锋 2 | overwatch |
|
||||||
| 星际争霸:重制版 | starcraft |
|
| 星际争霸:重制版 | starcraft |
|
||||||
| 星际争霸 II | starcraft2 |
|
| 星际争霸 II | starcraft2 |
|
||||||
| 魔兽世界 | world-of-warcraft |
|
| 魔兽世界 | world-of-warcraft |
|
||||||
| 魔兽争霸 III:重制版 | warcraft3 |
|
| 魔兽争霸 III:重制版 | warcraft3 |
|
||||||
|
| Battle.net | battlenet |
|
||||||
| 暴雪嘉年华 | blizzcon |
|
| 暴雪嘉年华 | blizzcon |
|
||||||
| 走进暴雪 | blizzard |
|
| 走进暴雪 | blizzard |
|
||||||
|
|
||||||
语言代码
|
语言代码
|
||||||
|
|
||||||
| 语言 | 语言代码 |
|
| 语言 | 语言代码 |
|
||||||
| -------------- | -------- |
|
| ------------------ | -------- |
|
||||||
| Deutsch | de-de |
|
| Deutsch | de-de |
|
||||||
| English (US) | en-us |
|
| English (US) | en-us |
|
||||||
| English (EU) | en-gb |
|
| English (EU) | en-gb |
|
||||||
| Español (EU) | es-es |
|
| Español (EU) | es-es |
|
||||||
| Español (AL) | es-mx |
|
| Español (Latino) | es-mx |
|
||||||
| Français | fr-fr |
|
| Français | fr-fr |
|
||||||
| Italiano | it-it |
|
| Italiano | it-it |
|
||||||
| Português (AL) | pt-br |
|
| Português (Brasil) | pt-br |
|
||||||
| Polski | pl-pl |
|
| Polski | pl-pl |
|
||||||
| Русский | ru-ru |
|
| Русский | ru-ru |
|
||||||
| 한국어 | ko-kr |
|
| 한국어 | ko-kr |
|
||||||
| ภาษาไทย | th-th |
|
| ภาษาไทย | th-th |
|
||||||
| 日本語 | ja-jp |
|
| 日本語 | ja-jp |
|
||||||
| 繁體中文 | zh-tw |
|
| 繁體中文 | zh-tw |
|
||||||
| 简体中文 | zh-cn |
|
|
||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
|||||||
@@ -3408,7 +3408,7 @@ router.get('/rescuetime/release-notes/:os?', lazyloadRouteHandler('./routes/resc
|
|||||||
router.get('/totalcommander/whatsnew', lazyloadRouteHandler('./routes/totalcommander/whatsnew'));
|
router.get('/totalcommander/whatsnew', lazyloadRouteHandler('./routes/totalcommander/whatsnew'));
|
||||||
|
|
||||||
// Blizzard
|
// Blizzard
|
||||||
router.get('/blizzard/news/:language?/:category?', lazyloadRouteHandler('./routes/blizzard/news'));
|
// router.get('/blizzard/news/:language?/:category?', lazyloadRouteHandler('./routes/blizzard/news'));
|
||||||
|
|
||||||
// DeepMind
|
// DeepMind
|
||||||
// router.get('/deepmind/blog/:category?', lazyloadRouteHandler('./routes/deepmind/blog'));
|
// 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 category = ctx.params.category || '';
|
||||||
const language = ctx.params.language || 'en-us';
|
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 currentUrl = `${rootUrl}/${language}/${category}`;
|
||||||
const response = await got({
|
const apiUrl = `${rootUrl}/${language}/blog/list`;
|
||||||
method: 'get',
|
const response = await got(apiUrl, {
|
||||||
url: currentUrl,
|
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')
|
const list = $('.FeaturedArticle-text > a, .ArticleListItem > article > a')
|
||||||
.slice(0, 10)
|
.slice(0, ctx.query.limit ? parseInt(ctx.query.limit, 10) : 30)
|
||||||
.map((_, item) => {
|
.toArray()
|
||||||
|
.map((item) => {
|
||||||
item = $(item);
|
item = $(item);
|
||||||
return {
|
return {
|
||||||
title: item.text(),
|
title: item.text(),
|
||||||
link: `${rootUrl}${item.attr('href')}`,
|
link: `${rootUrl}${item.attr('href')}`,
|
||||||
};
|
};
|
||||||
})
|
});
|
||||||
.get();
|
|
||||||
|
|
||||||
const items = await Promise.all(
|
const items = await Promise.all(
|
||||||
list.map((item) =>
|
list.map((item) =>
|
||||||
ctx.cache.tryGet(item.link, async () => {
|
ctx.cache.tryGet(item.link, async () => {
|
||||||
const detailResponse = await got({
|
const detailResponse = await got(item.link);
|
||||||
method: 'get',
|
|
||||||
url: item.link,
|
|
||||||
});
|
|
||||||
const content = cheerio.load(detailResponse.data);
|
const content = cheerio.load(detailResponse.data);
|
||||||
|
|
||||||
item.author = content('.ArticleDetail-bylineAuthor').text();
|
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');
|
item.pubDate = content('.ArticleDetail-subHeadingLeft time').attr('timestamp');
|
||||||
|
|
||||||
return item;
|
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