feat: add fantia search & ranking (#6245)
This commit is contained in:
parent
2d508960bf
commit
c7b50b2b30
|
|
@ -76,6 +76,62 @@ pageClass: routes
|
|||
|
||||
## Fantia
|
||||
|
||||
### 搜索
|
||||
|
||||
<Route author="nczitzk" example="/fantia/search/posts/all/daily" path="/fantia/search/:type?/:caty?/:peroid?/:order?/:rating?/:keyword?" :paramsDesc="['类型,见下表,默认为 posts','分类,见下表,也可在搜索页的 URL 中找到,默认为 すべてのクリエイター', '排行时段,见下表,填写该字段即返回排行榜,默认为空,即不排名' ,'排序,见下表,默认为 更新の新しい順', 'R18显示,见下表,默认为 すべて', '关键字,默认为空']">
|
||||
|
||||
类型
|
||||
|
||||
| クリエイター | 投稿 | 商品 | コミッション |
|
||||
| ------------ | ----- | -------- | ------------ |
|
||||
| fanclubs | posts | products | commissions |
|
||||
|
||||
分类
|
||||
|
||||
| 分类 | 分类名 |
|
||||
| ---------------------- | ---------- |
|
||||
| イラスト | illust |
|
||||
| 漫画 | comic |
|
||||
| コスプレ | cosplay |
|
||||
| YouTuber・配信者 | youtuber |
|
||||
| Vtuber | vtuber |
|
||||
| 音声作品・ASMR | voice |
|
||||
| 声優・歌い手 | voiceactor |
|
||||
| アイドル | idol |
|
||||
| アニメ・映像・写真 | anime |
|
||||
| 3D | 3d |
|
||||
| ゲーム制作 | game |
|
||||
| 音楽 | music |
|
||||
| 小説 | novel |
|
||||
| ドール | doll |
|
||||
| アート・デザイン | art |
|
||||
| プログラム | program |
|
||||
| 創作・ハンドメイド | handmade |
|
||||
| 歴史・評論・情報 | history |
|
||||
| 鉄道・旅行・ミリタリー | railroad |
|
||||
| ショップ | shop |
|
||||
| その他 | other |
|
||||
|
||||
排行时段
|
||||
|
||||
| デイリー | ウィークリー | マンスリー | 全期間 |
|
||||
| -------- | ------------ | ---------- | ------ |
|
||||
| daily | weekly | monthly | all |
|
||||
|
||||
排序
|
||||
|
||||
| 更新の新しい順 | 更新の古い順 | 投稿の新しい順 | 投稿の古い順 | お気に入り数順 |
|
||||
| -------------- | ------------ | -------------- | ------------ | -------------- |
|
||||
| updater | update_old | newer | create_old | popular |
|
||||
|
||||
R18 显示
|
||||
|
||||
| すべて | 一般のみ | R18 のみ |
|
||||
| ------ | -------- | -------- |
|
||||
| all | general | adult |
|
||||
|
||||
</Route>
|
||||
|
||||
### 用户投稿
|
||||
|
||||
<Route author="nczitzk" example="/fantia/user/3498" path="/fantia/user/:id" :paramsDesc="['用户 id,可在用户页 URL 中找到']" />
|
||||
|
|
|
|||
|
|
@ -3513,6 +3513,7 @@ router.get('/uisdc/zt/:title?', require('./routes/uisdc/zt'));
|
|||
router.get('/uisdc/topic/:title?/:sort?', require('./routes/uisdc/topic'));
|
||||
|
||||
// Fantia
|
||||
router.get('/fantia/search/:type?/:caty?/:peroid?/:order?/:rating?/:keyword?', require('./routes/fantia/search'));
|
||||
router.get('/fantia/user/:id', require('./routes/fantia/user'));
|
||||
|
||||
// i-Cable
|
||||
|
|
|
|||
|
|
@ -0,0 +1,66 @@
|
|||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const type = ctx.params.type || 'posts';
|
||||
const caty = ctx.params.caty || '';
|
||||
const order = ctx.params.order || 'updater';
|
||||
const rating = ctx.params.rating || 'all';
|
||||
const keyword = ctx.params.keyword || '';
|
||||
const peroid = ctx.params.peroid || '';
|
||||
|
||||
const rootUrl = 'https://fantia.jp';
|
||||
const apiUrl = `${rootUrl}/api/v1/search/${type}?keyword=${keyword}&peroid=${peroid}&brand_type=0&category=${caty === 'all' ? '' : caty}&order=${order}${
|
||||
rating === 'all' ? '' : rating === 'general' ? '&rating=general' : '&adult=1'
|
||||
}&per_page=30`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: apiUrl,
|
||||
});
|
||||
|
||||
let items = {};
|
||||
|
||||
switch (type) {
|
||||
case 'fanclubs': {
|
||||
items = response.data.fanclubs.map((item) => ({
|
||||
title: item.fanclub_name_with_creator_name,
|
||||
link: `${rootUrl}/fanclubs/${item.id}`,
|
||||
description: `${item.icon ? `<img src="${item.icon.main}">` : ''}"><p>${item.title}</p>`,
|
||||
}));
|
||||
break;
|
||||
}
|
||||
case 'posts': {
|
||||
items = response.data.posts.map((item) => ({
|
||||
title: item.title,
|
||||
link: `${rootUrl}/posts/${item.id}`,
|
||||
pubDate: new Date(item.posted_at).toUTCString(),
|
||||
author: item.fanclub.fanclub_name_with_creator_name,
|
||||
description: `${item.comment ? `<p>${item.comment}</p>` : ''}<img src="${item.thumb ? item.thumb.main : item.thumb_micro}">`,
|
||||
}));
|
||||
break;
|
||||
}
|
||||
case 'products': {
|
||||
items = response.data.products.map((item) => ({
|
||||
title: item.name,
|
||||
link: `${rootUrl}/products/${item.id}`,
|
||||
author: item.fanclub.fanclub_name_with_creator_name,
|
||||
description: `${item.buyable_lowest_plan.description ? `<p>${item.buyable_lowest_plan.description}</p>` : ''}<img src="${item.thumb ? item.thumb.main : item.thumb_micro}">`,
|
||||
}));
|
||||
break;
|
||||
}
|
||||
case 'commissions': {
|
||||
items = response.data.commissions.map((item) => ({
|
||||
title: item.name,
|
||||
link: `${rootUrl}/commissions/${item.id}`,
|
||||
author: item.fanclub.fanclub_name_with_creator_name,
|
||||
description: `${item.buyable_lowest_plan.description ? `<p>${item.buyable_lowest_plan.description}</p>` : ''}<img src="${item.thumb ? item.thumb.main : item.thumb_micro}">`,
|
||||
}));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ctx.state.data = {
|
||||
title: `Fantia - Search ${type}`,
|
||||
link: apiUrl.replace('api/v1/search/', ''),
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue