feat(route): iwara用户订阅列表 (#10517)

* feat(route): iwara用户订阅列表

* Update Error message in iwara subscription

Co-authored-by: FeCCC <964575805@qq.com>
This commit is contained in:
FeCCC
2022-08-18 04:43:27 +04:00
committed by GitHub
co-authored by FeCCC
parent 0896c39c31
commit 1a9fc89ff7
10 changed files with 92 additions and 0 deletions
+12
View File
@@ -327,6 +327,18 @@ pageClass: routes
</Route>
### 用户订阅列表
<Route author="FeCCC" example="/iwara/subscriptions" path="/iwara/subscriptions" radar="1" rssbud="1" selfhost="1">
::: warning 注意
用户动态需要 iwara 登录后的 Cookie 值,所以只能自建,详情见[部署页面](/install/#route-specific-configurations)的配置模块。
:::
</Route>
## Kemono
### Posts
+12
View File
@@ -36,6 +36,18 @@ For more tags, please go to [Search torrent](https://bangumi.moe/search/index)
</RouteEn>
### User Subscriptions
<RouteEn author="FeCCC" example="/iwara/subscriptions" path="/iwara/subscriptions" radar="1" rssbud="1" selfhost="1">
::: warning
This route requires Cookie, therefore it's only available when self-hosting, refer to the [Deploy Guide](/en/install/#route-specific-configurations) for route-specific configurations.
:::
</RouteEn>
## Kemono
### Posts
+4
View File
@@ -626,6 +626,10 @@ See docs of the specified route and `lib/config.js` for detailed information.
Warning: Two Factor Authentication is **not** supported.
- Iwara:
- `IWARA_COOKIE`: Cookie of Iwara User
- Last.fm
- `LASTFM_API_KEY`: Last.fm API Key
+4
View File
@@ -663,6 +663,10 @@ RSSHub 支持使用访问密钥 / 码,白名单和黑名单三种方式进行
注意,暂**不支持**两步验证。
- Iwara:
- `IWARA_COOKIE`: Iwara 登录后的 Cookie 值
- Last.fm 全部路由:[申请地址](https://www.last.fm/api/)
- `LASTFM_API_KEY`: Last.fm API Key
+3
View File
@@ -178,6 +178,9 @@ const calculateValue = () => {
password: envs.IG_PASSWORD,
proxy: envs.IG_PROXY,
},
iwara: {
cookie: envs.IWARA_COOKIE,
},
lastfm: {
api_key: envs.LASTFM_API_KEY,
},
+1
View File
@@ -1,3 +1,4 @@
module.exports = {
'/users/:username?/:type?': ['Fatpandac'],
'/subscriptions': ['FeCCC'],
};
+6
View File
@@ -14,6 +14,12 @@ module.exports = {
source: '/users/:username',
target: '/iwara/users/:username?/image',
},
{
title: '用户订阅列表',
docs: 'https://docs.rsshub.app/anime.html#iwara',
source: '',
target: '/iwara/subscriptions',
},
],
},
};
+1
View File
@@ -1,3 +1,4 @@
module.exports = function (router) {
router.get('/users/:username?/:type?', require('./index'));
router.get('/subscriptions', require('./subscriptions'));
};
+48
View File
@@ -0,0 +1,48 @@
const got = require('@/utils/got');
const config = require('@/config').value;
const cheerio = require('cheerio');
const { art } = require('@/utils/render');
const path = require('path');
module.exports = async (ctx) => {
const rootUrl = `https://ecchi.iwara.tv/subscriptions`;
const cookie = config.iwara.cookie;
if (cookie === undefined) {
throw Error('Iwara subscription RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
const response = await got({
method: 'get',
url: rootUrl,
headers: {
Cookie: cookie,
},
});
const $ = cheerio.load(response.data);
const username = $('a.btn.btn-info.btn-sm.user').text().trim();
const list = $('div.views-column');
const items = list
.map((_, item) => {
const imageUrl = 'https:' + $(item).find('img').attr('src');
const type = $(item).find('div.field').hasClass('field-type-video') ? 'Video' : 'Image';
return {
title: $(item).find('h3.title').text(),
author: username,
link: rootUrl + $(item).find('h3.title > a').attr('href'),
category: type,
description: art(path.join(__dirname, 'templates/subscriptions.art'), {
type,
imageUrl,
}),
};
})
.get();
ctx.state.data = {
title: `${username}'s iwara Subscription`,
link: rootUrl,
item: items,
};
};
+1
View File
@@ -0,0 +1 @@
<h3>{{ type }}</h3><br><img src="{{ imageUrl }}">