feat(route): Nyaa migrated to v2 and add sukebei support (#10067)

* feat(route): Nyaa migrated to v2 and add sukebei

- 将 nyaa 的实现更新到 v2
- 新增 sukebei.nyaa.si 的搜索支持

* docs(nyaa): fix typo in nyaa document

Co-authored-by: noname <noname@noname.no>
This commit is contained in:
noname1897
2022-06-30 01:53:56 +08:00
committed by GitHub
co-authored by noname
parent 3f3f437641
commit 4751b026a3
7 changed files with 57 additions and 7 deletions
+6 -2
View File
@@ -261,9 +261,13 @@ See [Directory](https://www.javlibrary.com/en/star_list.php) to view all stars.
## Nyaa
### Seatch Result
### Search Result
<RouteEn author="Lava-Swimmer" example="/nyaa/search/psycho-pass" path="/nyaa/search/:keyword" :paramsDesc="['Search keyword']" supportBT="1"/>
<RouteEn author="Lava-Swimmer noname1897" example="/nyaa/search/psycho-pass" path="/nyaa/search/:query?" :paramsDesc="['Search keyword']" supportBT="1" radar="1"/>
### Sukebei Search Result
<RouteEn author="Lava-Swimmer noname1897" example="/nyaa/sukebei/search/hi" path="/nyaa/sukebei/search/:query?" :paramsDesc="['Search keyword']" supportBT="1" radar="1"/>
## PornHub
+5 -1
View File
@@ -900,7 +900,11 @@ JavDB 有多个备用域名,本路由默认使用永久域名 <https://javdb.c
### 搜索结果
<Route author="Lava-Swimmer" example="/nyaa/search/psycho-pass" path="/nyaa/search/:keyword" :paramsDesc="['搜索关键字']" supportBT="1"/>
<Route author="Lava-Swimmer noname1897" example="/nyaa/search/psycho-pass" path="/nyaa/search/:query?" :paramsDesc="['搜索关键字']" supportBT="1" radar="1"/>
### Sukebei 搜索结果
<Route author="Lava-Swimmer noname1897" example="/nyaa/sukebei/search/hi" path="/nyaa/sukebei/search/:query?" :paramsDesc="['搜索关键字']" supportBT="1" radar="1"/>
## OneJAV
+2 -2
View File
@@ -2265,8 +2265,8 @@ router.get('/transferwise/pair/:source/:target', lazyloadRouteHandler('./routes/
// chocolatey
router.get('/chocolatey/software/:name?', lazyloadRouteHandler('./routes/chocolatey/software'));
// Nyaa
router.get('/nyaa/search/:query?', lazyloadRouteHandler('./routes/nyaa/search'));
// Nyaa migrated to v2
// router.get('/nyaa/search/:query?', lazyloadRouteHandler('./routes/nyaa/search'));
// 片源网 migrated to v2
// router.get('/pianyuan/index/:media?', lazyloadRouteHandler('./routes/pianyuan/app'));
+4
View File
@@ -0,0 +1,4 @@
module.exports = {
'/search/:query?': ['Lava-Swimmer', 'noname1897'],
'/subekei/search/:query?': ['Lava-Swimmer', 'noname1897'],
};
+32
View File
@@ -0,0 +1,32 @@
module.exports = {
'nyaa.si': {
_name: 'nyaa',
'.': [
{
title: '搜索结果',
docs: 'https://docs.rsshub.app/multimedia.html#nyaa-sou-suo-jie-guo',
source: '/',
target: (params, url) => {
url = new URL(url);
if (url.hostname.split('.')[0] === 'nyaa') {
const searchParams = url.searchParams;
const query = searchParams.has('q') ? searchParams.get('q') : '';
return `/nyaa/search/${query}`;
}
},
},
],
'sukebei': [
{
title: 'sukebei 搜索结果',
docs: 'https://docs.rsshub.app/multimedia.html#nyaa-sukebei-sou-suo-jie-guo',
source: '/',
target: (params, url) => {
const searchParams = new URL(url).searchParams;
const query = searchParams.has('q') ? searchParams.get('q') : '';
return `/nyaa/sukebei/search/${query}`;
},
},
],
},
};
+4
View File
@@ -0,0 +1,4 @@
module.exports = (router) => {
router.get('/search/:query?', require('./search'));
router.get('/sukebei/search/:query?', require('./search'));
};
@@ -11,8 +11,10 @@ module.exports = async (ctx) => {
},
});
const rootURL = ctx.routerPath.split('/')[1] === 'sukebei' ? 'https://sukebei.nyaa.si' : 'https://nyaa.si';
const { query = '' } = ctx.params;
const feed = await parser.parseURL(`https://nyaa.si/?page=rss&c=0_0&f=0&q=${encodeURI(query)}`);
const feed = await parser.parseURL(`${rootURL}/?page=rss&c=0_0&f=0&q=${encodeURI(query)}`);
feed.items.map((item) => {
item.link = item.guid;
@@ -24,7 +26,7 @@ module.exports = async (ctx) => {
ctx.state.data = {
title: feed.title,
link: `https://nyaa.si/?f=0&c=0_0&q=${query}`,
link: `${rootURL}/?f=0&c=0_0&q=${query}`,
description: feed.description,
item: feed.items,
};