diff --git a/docs/install/README.md b/docs/install/README.md index 497de10e7..9d48e9707 100644 --- a/docs/install/README.md +++ b/docs/install/README.md @@ -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=...` 即可获取全文 diff --git a/lib/config.js b/lib/config.js index 2157eaf25..fa66e17ec 100644 --- a/lib/config.js +++ b/lib/config.js @@ -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, diff --git a/lib/routes/ehentai/ehapi.js b/lib/routes/ehentai/ehapi.js index de5c91510..b97c14ed3 100644 --- a/lib/routes/ehentai/ehapi.js +++ b/lib/routes/ehentai/ehapi.js @@ -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 = ``; + const description = `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 }; diff --git a/lib/routes/ehentai/favorites.js b/lib/routes/ehentai/favorites.js index 83a61129b..1fa7123e8 100644 --- a/lib/routes/ehentai/favorites.js +++ b/lib/routes/ehentai/favorites.js @@ -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 relevant config'; } 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, + }; + } }; diff --git a/lib/routes/ehentai/search.js b/lib/routes/ehentai/search.js index a01296e82..180dfbb1b 100644 --- a/lib/routes/ehentai/search.js +++ b/lib/routes/ehentai/search.js @@ -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, + }; + } }; diff --git a/lib/routes/ehentai/tag.js b/lib/routes/ehentai/tag.js index f66239308..a50be06fd 100644 --- a/lib/routes/ehentai/tag.js +++ b/lib/routes/ehentai/tag.js @@ -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, + }; + } };