fix(radar)(route): Pixiv search & Radar rules (#7700)

This commit is contained in:
Howard Yin
2021-06-26 17:02:22 -07:00
committed by GitHub
parent 150883ca14
commit 61d9e2dd4e
6 changed files with 40 additions and 12 deletions
+7 -5
View File
@@ -140,24 +140,26 @@
{
title: '用户收藏',
docs: 'https://docs.rsshub.app/social-media.html#pixiv',
source: '/bookmark.php',
target: (params, url) => `/pixiv/user/bookmarks/${new URL(url).searchParams.get('id')}`,
source: '/users/:id/bookmarks/artworks',
target: '/pixiv/user/bookmarks/:id',
},
{
title: '用户动态',
docs: 'https://docs.rsshub.app/social-media.html#pixiv',
source: '/member.php',
target: (params, url) => `/pixiv/user/${new URL(url).searchParams.get('id')}`,
source: '/users/:id',
target: '/pixiv/user/:id',
},
{
title: '排行榜',
docs: 'https://docs.rsshub.app/social-media.html#pixiv',
source: '/ranking.php',
target: (params, url) => `/pixiv/ranking/${new URL(url).searchParams.get('mode') || 'daily'}`,
},
{
title: '关键词',
docs: 'https://docs.rsshub.app/social-media.html#pixiv',
source: '/search.php',
source: ['/tags/:keyword', '/tags/:keyword/:type?'],
target: (params, url) => `/pixiv/search/:keyword/${new URL(url).searchParams.get('order')}/${new URL(url).searchParams.get('mode')}`,
},
{
title: '关注的新作品',
+7 -1
View File
@@ -209,7 +209,13 @@ These feed do not include boosts (a.k.a. reblogs). RSSHub provides a feed for us
### Keyword
<RouteEn author="DIYgod" example="/pixiv/search/麻衣/popular/2" path="/pixiv/search/:keyword/:order?/:r18?" :paramsDesc="['keyword', 'rank mode, empty or other for time order, popular for popular order', 'filte R18 content, 0 to no filter, 1 to only not R18, 2 to only R18, default to 0']" radar="1" rssbud="1"/>
<RouteEn author="DIYgod" example="/pixiv/search/麻衣/popular/2" path="/pixiv/search/:keyword/:order?/:mode?" :paramsDesc="['keyword', 'rank mode, empty or other for time order, popular for popular order', 'filte R18 content']" radar="1" rssbud="1">
| only not R18 | only R18 | no filter |
| ----------------- | ------------------------- | ------------------------- |
| safe | r18 | empty or other |
</RouteEn>
### Following timeline
+6 -1
View File
@@ -529,8 +529,13 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性
### 关键词
<Route author="DIYgod" example="/pixiv/search/麻衣/popular/2" path="/pixiv/search/:keyword/:order?/:r18?" :paramsDesc="['关键词', '排序方式,popular 按热门度排序,空或其他任意值按时间排序', '过滤 R18 内容,0 为不过滤,1 为只看非 R18 内容,2 为只看 R18 内容,默认为 0']" radar="1" rssbud="1"/>
<Route author="DIYgod" example="/pixiv/search/麻衣/popular/2" path="/pixiv/search/:keyword/:order?/:mode?" :paramsDesc="['关键词', '排序方式,popular 按热门度排序,空或其他任意值按时间排序', '过滤方式']" radar="1" rssbud="1">
| 只看非 R18 内容 | 只看 R18 内容 | 不过滤 |
| ----------------- | ------------------------- | ------------------------- |
| safe | r18 | 空或其他任意值 |
</Route>
### 关注的新作品
<Route author="ClarkeCheng" example="/pixiv/user/illustfollows" path="/pixiv/user/illustfollows" radar="1" rssbud="1" selfhost="1"/>
+1 -1
View File
@@ -174,7 +174,7 @@ router.get('/pixiv/user/bookmarks/:id', require('./routes/pixiv/bookmarks'));
router.get('/pixiv/user/illustfollows', require('./routes/pixiv/illustfollow'));
router.get('/pixiv/user/:id', require('./routes/pixiv/user'));
router.get('/pixiv/ranking/:mode/:date?', require('./routes/pixiv/ranking'));
router.get('/pixiv/search/:keyword/:order?/:r18?', require('./routes/pixiv/search'));
router.get('/pixiv/search/:keyword/:order?/:mode?', require('./routes/pixiv/search'));
// pixiv-fanbox
router.get('/fanbox/:user?', require('./routes/fanbox/main'));
+16 -1
View File
@@ -32,12 +32,27 @@ const links = {
week_r18g: 'https://www.pixiv.net/ranking.php?mode=r18g',
};
const alias = {
daily: 'day',
weekly: 'week',
monthly: 'month',
male: 'day_male',
female: 'day_female',
original: 'week_original',
rookie: 'week_rookie',
daily_r18: 'day_r18',
male_r18: 'day_male_r18',
female_r18: 'day_female_r18',
weekly_r18: 'week_r18',
r18g: 'week_r18g',
};
module.exports = async (ctx) => {
if (!config.pixiv || !config.pixiv.refreshToken) {
throw 'pixiv RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#%E9%83%A8%E5%88%86-rss-%E6%A8%A1%E5%9D%97%E9%85%8D%E7%BD%AE">relevant config</a>';
}
const mode = ctx.params.mode;
const mode = alias[ctx.params.mode] ? alias[ctx.params.mode] : ctx.params.mode;
const date = ctx.params.date ? new Date(ctx.params.date) : new Date();
if (!getToken()) {
+3 -3
View File
@@ -10,7 +10,7 @@ module.exports = async (ctx) => {
const keyword = ctx.params.keyword;
const order = ctx.params.order || 'date';
const r18 = ctx.params.r18;
const mode = ctx.params.mode;
if (!getToken()) {
throw 'pixiv not login';
@@ -24,9 +24,9 @@ module.exports = async (ctx) => {
}
let illusts = response.data.illusts;
if (r18 === '1') {
if (mode === 'safe' || mode === '1') {
illusts = illusts.filter((item) => item.x_restrict === 0);
} else if (r18 === '2') {
} else if (mode === 'r18' || mode === '2') {
illusts = illusts.filter((item) => item.x_restrict === 1);
}