Skip to content

Commit

Permalink
fix(route): Fix the BBC Chinese 404 page not found. (#13205)
Browse files Browse the repository at this point in the history
* fix: BBC News rss fetching error

* refactor: migrate to v2

---------
  • Loading branch information
qyx596 authored Sep 5, 2023
1 parent 44aa011 commit 54f7b45
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ router.get('/rs05/rs05', lazyloadRouteHandler('./routes/rs05/rs05'));
router.get('/qutoutiao/category/:cid', lazyloadRouteHandler('./routes/qutoutiao/category'));

// BBC
router.get('/bbc/:site?/:channel?', lazyloadRouteHandler('./routes/bbc/index'));
// router.get('/bbc/:site?/:channel?', lazyloadRouteHandler('./routes/bbc/index'));

// 看雪
router.get('/pediy/topic/:category?/:type?', lazyloadRouteHandler('./routes/pediy/topic'));
Expand Down
8 changes: 4 additions & 4 deletions lib/routes/bbc/index.js → lib/v2/bbc/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ module.exports = async (ctx) => {
title = 'BBC News 中文网';

if (!channel) {
feed = await parser.parseURL('http://www.bbc.co.uk/zhongwen/simp/index.xml');
feed = await parser.parseURL('https://www.bbc.co.uk/zhongwen/simp/index.xml');
} else {
feed = await parser.parseURL(`http://www.bbc.co.uk/zhongwen/simp/${channel}/index.xml`);
feed = await parser.parseURL(`https://www.bbc.co.uk/zhongwen/simp/${channel}/index.xml`);
}
break;

case 'traditionalchinese':
title = 'BBC News 中文網';

if (!channel) {
feed = await parser.parseURL('http://www.bbc.co.uk/zhongwen/trad/index.xml');
feed = await parser.parseURL('https://www.bbc.co.uk/zhongwen/trad/index.xml');
} else {
feed = await parser.parseURL(`http://www.bbc.co.uk/zhongwen/trad/${channel}/index.xml`);
feed = await parser.parseURL(`https://www.bbc.co.uk/zhongwen/trad/${channel}/index.xml`);
}
link = 'https://www.bbc.com/zhongwen/trad';
break;
Expand Down
4 changes: 4 additions & 0 deletions lib/v2/bbc/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
'/:channel': ['HenryQW', 'DIYgod'],
'/:lang/:channel?': ['HenryQW'],
};
11 changes: 11 additions & 0 deletions lib/v2/bbc/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
'bbc.com': {
_name: 'BBC',
'.': [
{
title: 'News',
docs: 'https://docs.rsshub.app/routes/traditional-media#bbc',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/bbc/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/:site?/:channel?', require('./index'));
};
File renamed without changes.
16 changes: 12 additions & 4 deletions website/docs/routes/traditional-media.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ There is no RSS source for Al Jazeera Chinese, returning homepage content by def

## BBC {#bbc}

### BBC {#bbc-bbc}
### News {#bbc-news}

<Route author="HenryQW DIYgod" example="/bbc/world-asia" path="/bbc/:channel?" paramsDesc={['channel, default to `top stories`']}>

Expand All @@ -136,11 +136,19 @@ Support major channels, refer to [BBC RSS feeds](https://www.bbc.co.uk/news/1062

</Route>

### BBC Chinese {#bbc-bbc-chinese}
### BBC 中文网 {#bbc-bbc-zhong-wen-wang}

<Route author="HenryQW" example="/bbc/chinese/business" path="/bbc/:lang/:channel?" paramsDesc={['lang, Simplified or Traditional Chinese','channel, default to `top stories`']}>
<Route author="HenryQW" example="/bbc/chinese/business" path="/bbc/:lang/:channel?" paramsDesc={['语言,简体或繁体中文','频道,默认为主页']}>

See [BBC 中文网](/routes/traditional-media#bbc-bbc-zhong-wen-wang).
支持大部分频道,频道名称见 [BBC 中文网 RSS 服务](https://www.bbc.com/zhongwen/simp/services/2009/09/000000_rss)

简体版:

- 频道,如金融财经 `https://www.bbc.co.uk/zhongwen/simp/business/index.xml` 则为 `/bbc/chinese/business`.

繁體版:

- 频道,如金融財經 `https://www.bbc.co.uk/zhongwen/trad/business/index.xml` 则为 `/bbc/traditionalchinese/business`.

</Route>

Expand Down

0 comments on commit 54f7b45

Please sign in to comment.