Co-authored-by: Tony <TonyRL@users.noreply.github.com>
Co-authored-by: DIYgod <diy.d.god@gmail.com>
This commit is contained in:
Fatpandac
2022-01-22 19:20:07 +00:00
committed by GitHub
co-authored by Tony DIYgod
parent 94104c0018
commit 3478eebd01
6 changed files with 91 additions and 0 deletions
+12
View File
@@ -253,6 +253,18 @@ pageClass: routes
</Route>
## iwara
### 用户
<Route author="Fatpandac" example="/iwara/users/kelpie/video" path="/iwara/users/:username/:type?" :paramsDesc="['用户昵称', 'type 默认为 video']" radar="1" rssbud="1">
| type | 视频 | 图片 |
| :--: | :---: | :---: |
| 参数 | video | image |
</Route>
## Kemono
### Posts
+12
View File
@@ -79,3 +79,15 @@ For example: https://www.webtoons.com/zh-hant/drama/gongzhuweimian/list?title_no
### [Naver](https://comic.naver.com)
<RouteEn author="zfanta" example="/webtoons/naver/651673" path="/webtoons/naver/:titleId" :paramsDesc="['titleId of naver webtoon']" />
## iwara
### User
<RouteEn author="Fatpandac" example="/iwara/users/kelpie/video" path="/iwara/users/:username/:type?" :paramsDesc="['username, can find in userpage', 'video by default']" radar="1" rssbud="1">
| type | video | image |
| :--: | :---: | :---: |
| | video | image |
</RouteEn>
+42
View File
@@ -0,0 +1,42 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const rootUrl = 'https://ecchi.iwara.tv';
const typeMap = {
video: 'Videos',
image: 'Images',
};
const selectorMap = {
video: 'div.node.node-video.node-teaser.node-teaser.clearfix',
image: 'div.node.node-image.node-teaser.node-teaser.clearfix',
};
module.exports = async (ctx) => {
const username = ctx.params.username;
const type = ctx.params.type ?? 'video';
const userUrl = `${rootUrl}/users/${username}`;
const response = await got.get(userUrl);
const $ = cheerio.load(response.data);
const list = $(selectorMap[type]);
const items = list
.map((_, item) => {
const imageUrl = 'https:' + $(item).find('img').attr('src');
return {
title: $(item).find('h3.title').text(),
author: username,
link: rootUrl + $(item).find('h3.title > a').attr('href'),
description: `<img src="${imageUrl}">`,
};
})
.get();
ctx.state.data = {
title: `${username}'s iwara - ${typeMap[type]}`,
link: userUrl,
item: items,
};
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/users/:username?/:type?': ['Fatpandac'],
};
+19
View File
@@ -0,0 +1,19 @@
module.exports = {
'iwara.tv': {
_name: 'iwara',
ecchi: [
{
title: '用户视频',
docs: '',
source: '/users/:username',
target: '/iwara/users/:username?/video',
},
{
title: '用户图片',
docs: '',
source: '/users/:username',
target: '/iwara/users/:username?/image',
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/users/:username?/:type?', require('./index'));
};