feat(route): ExHentai (#9190)

* 添加里站

* lint
This commit is contained in:
Howard Yin
2022-02-25 00:43:18 +08:00
committed by GitHub
parent b44b7aa92a
commit 136d462f09
6 changed files with 60 additions and 23 deletions
+1
View File
@@ -721,6 +721,7 @@ RSSHub 支持使用访问密钥 / 码,白名单和黑名单三种方式进行
- `EH_IPB_MEMBER_ID`: E-Hentai 账户登录后 cookie 的 `ipb_member_id` 值
- `EH_IPB_PASS_HASH`: E-Hentai 账户登录后 cookie 的 `ipb_pass_hash` 值
- `EH_SK`: E-Hentai 账户登录后 cookie 中的`sk`值
- `EH_IGNEOUS`: ExHentai 账户登录后 cookie 中的`igneous`值。若设置此值,RSS数据将全部从里站获取,`EH_SK`将被忽略
- 南方周末付费全文
- `INFZM_COOKIE`: infzm 账户登陆后的 cookie,目前只需要 `passport_session=...` 即可获取全文
+1
View File
@@ -209,6 +209,7 @@ const calculateValue = () => {
ipb_member_id: envs.EH_IPB_MEMBER_ID,
ipb_pass_hash: envs.EH_IPB_PASS_HASH,
sk: envs.EH_SK,
igneous: envs.EH_IGNEOUS,
},
infzm: {
cookie: envs.INFZM_COOKIE,
+16 -6
View File
@@ -3,14 +3,24 @@ const cheerio = require('cheerio');
const config = require('@/config').value.ehentai;
const headers = {};
const has_cookie = config.ipb_member_id && config.ipb_pass_hash && config.sk;
const has_cookie = config.ipb_member_id && config.ipb_pass_hash && (config.sk || config.igneous);
const from_ex = has_cookie && config.igneous;
if (has_cookie) {
const { ipb_member_id, ipb_pass_hash, sk } = config;
headers.cookie = `ipb_member_id=${ipb_member_id};ipb_pass_hash=${ipb_pass_hash};sk=${sk}`;
if (from_ex) {
const { ipb_member_id, ipb_pass_hash, igneous } = config;
headers.cookie = `ipb_member_id=${ipb_member_id};ipb_pass_hash=${ipb_pass_hash};igneous=${igneous}`;
} else {
const { ipb_member_id, ipb_pass_hash, sk } = config;
headers.cookie = `ipb_member_id=${ipb_member_id};ipb_pass_hash=${ipb_pass_hash};sk=${sk}`;
}
}
function ehgot(url) {
return got({ method: 'get', url: `https://e-hentai.org/${url}`, headers });
if (from_ex) {
return got({ method: 'get', url: `https://exhentai.org/${url}`, headers });
} else {
return got({ method: 'get', url: `https://e-hentai.org/${url}`, headers });
}
}
async function parsePage(cache, data, get_bittorrent = false) {
@@ -26,7 +36,7 @@ async function parsePage(cache, data, get_bittorrent = false) {
const el_img = el.find('td.gl2c div.glthumb div img');
const title = el_a.find('div.glink').html();
const thumbnail = el_img.attr('data-src') ? el_img.attr('data-src') : el_img.attr('src');
const description = `<img src='${thumbnail}'>`;
const description = `<img src='${thumbnail}' alt='thumbnail'>`;
const pubDate = el.find('div[id^="posted_"]').html();
const link = el_a.attr('href');
if (title && link) {
@@ -130,4 +140,4 @@ function getTagItems(cache, tag, page, get_bittorrent = false) {
return gatherItemsByPage(cache, `tag/${tag}/${page}`, get_bittorrent);
}
module.exports = { getFavoritesItems, getSearchItems, getTagItems };
module.exports = { getFavoritesItems, getSearchItems, getTagItems, has_cookie, from_ex };
+14 -7
View File
@@ -1,8 +1,7 @@
const EhAPI = require('./ehapi');
const config = require('@/config').value;
module.exports = async (ctx) => {
if (!config.ehentai || !config.ehentai.ipb_member_id || !config.ehentai.ipb_pass_hash || !config.ehentai.sk) {
if (!EhAPI.has_cookie) {
throw 'Ehentai favorites 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 favcat = ctx.params.favcat ? parseInt(ctx.params.favcat) : 0;
@@ -11,9 +10,17 @@ module.exports = async (ctx) => {
const inline_set = ctx.params.order === 'posted' ? 'fs_p' : 'fs_f';
const items = await EhAPI.getFavoritesItems(ctx.cache, page, favcat, inline_set, bittorrent);
ctx.state.data = {
title: 'E-Hentai Favorites',
link: `https://e-hentai.org/favorites.php?favcat=${favcat}&inline_set=${inline_set}`,
item: items,
};
if (EhAPI.from_ex) {
ctx.state.data = {
title: 'ExHentai Favorites',
link: `https://exhentai.org/favorites.php?favcat=${favcat}&inline_set=${inline_set}`,
item: items,
};
} else {
ctx.state.data = {
title: 'E-Hentai Favorites',
link: `https://e-hentai.org/favorites.php?favcat=${favcat}&inline_set=${inline_set}`,
item: items,
};
}
};
+14 -5
View File
@@ -17,9 +17,18 @@ module.exports = async (ctx) => {
if (match !== null) {
title = match[1];
}
ctx.state.data = {
title: title + ' - E-Hentai Search ',
link: `https://e-hentai.org/?${params}`,
item: items,
};
if (EhAPI.from_ex) {
ctx.state.data = {
title: title + ' - ExHentai Search ',
link: `https://exhentai.org/?${params}`,
item: items,
};
} else {
ctx.state.data = {
title: title + ' - E-Hentai Search ',
link: `https://e-hentai.org/?${params}`,
item: items,
};
}
};
+14 -5
View File
@@ -5,9 +5,18 @@ module.exports = async (ctx) => {
const tag = ctx.params.tag;
const bittorrent = ctx.params.bittorrent || false;
const items = await EhAPI.getTagItems(ctx.cache, tag, page, bittorrent);
ctx.state.data = {
title: tag + ' - E-Hentai Tag',
link: `https://e-hentai.org/tag/${tag}`,
item: items,
};
if (EhAPI.from_ex) {
ctx.state.data = {
title: tag + ' - ExHentai Tag',
link: `https://exhentai.org/tag/${tag}`,
item: items,
};
} else {
ctx.state.data = {
title: tag + ' - E-Hentai Tag',
link: `https://e-hentai.org/tag/${tag}`,
item: items,
};
}
};