-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(route): add Nicesss呦糖社 #14364
feat(route): add Nicesss呦糖社 #14364
Changes from 1 commit
cd39d13
c002e29
abb8f2f
01642f6
f44d47e
8025f2c
18dc959
df87a65
8188d54
7a76157
e4fd5c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const utils = require('./utils'); | ||
|
||
module.exports = async (ctx) => { | ||
let category = decodeURIComponent(ctx.params.category); | ||
const limit = ctx.params.limit || 20; | ||
const items = []; | ||
let currPage = 1; | ||
|
||
switch (category) { | ||
case '秀人': | ||
case '秀人网': | ||
case 'XiuRen': | ||
category = 'xr'; | ||
break; | ||
case '韩国': | ||
case '韩国美女': | ||
case '韩国美女写真': | ||
case '秘境': | ||
category = 'mij'; | ||
break; | ||
case '丝袜': | ||
case '丝袜美女': | ||
case '丝袜美女写真': | ||
case '丝真': | ||
category = 'siz'; | ||
break; | ||
case '热门': | ||
case '热门美女': | ||
case '热门美女写真': | ||
case '热站': | ||
category = 'rez'; | ||
break; | ||
case '私影': | ||
category = '私影'; | ||
break; | ||
case 'cos': | ||
case 'Cos': | ||
case 'cosplay': | ||
case 'Cosplay': | ||
category = 'cosplya'; | ||
break; | ||
default: | ||
category = 'xr'; | ||
break; | ||
} | ||
|
||
do { | ||
const url = `https://www.nicesss.com/${category}/page/${currPage}`; | ||
try { | ||
// eslint-disable-next-line no-await-in-loop | ||
const { data: response } = await got(url); | ||
|
||
const content = cheerio.load(response); | ||
// eslint-disable-next-line no-await-in-loop | ||
const newItems = await utils.ProcessItems(ctx, content); | ||
|
||
items.push(...newItems); | ||
} catch { | ||
break; | ||
} | ||
} while (items.length < limit && currPage++ < 10); | ||
|
||
ctx.state.data = { | ||
title: `呦糖社 - “${category}”Category结果`, | ||
link: `https://www.nicesss.com/${category}`, | ||
description: `呦糖社 - “${category}”Category结果`, | ||
image: 'https://www.nicesss.com/wp-content/themes/ripro/assets/images/logo/logo-light.png', | ||
icon: 'https://www.nicesss.com/wp-content/themes/ripro/assets/images/favicon/favicon.png', | ||
logo: 'https://www.nicesss.com/wp-content/themes/ripro/assets/images/favicon/favicon.png', | ||
item: items.slice(0, limit), | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const utils = require('./utils'); | ||
|
||
module.exports = async (ctx) => { | ||
const limit = ctx.params.limit || 24; | ||
const items = []; | ||
let currPage = 1; | ||
do { | ||
const url = `https://www.nicesss.com/page/${currPage}`; | ||
try { | ||
// eslint-disable-next-line no-await-in-loop | ||
const { data: response } = await got(url); | ||
|
||
const content = cheerio.load(response); | ||
// eslint-disable-next-line no-await-in-loop | ||
const newItems = await utils.ProcessItems(ctx, content); | ||
|
||
items.push(...newItems); | ||
} catch { | ||
break; | ||
} | ||
} while (items.length < limit && currPage++ < 10); | ||
|
||
ctx.state.data = { | ||
title: '呦糖社 - 首页', | ||
link: 'https://www.nicesss.com/', | ||
description: '呦糖社 - 首页', | ||
image: 'https://www.nicesss.com/wp-content/themes/ripro/assets/images/logo/logo-light.png', | ||
icon: 'https://www.nicesss.com/wp-content/themes/ripro/assets/images/favicon/favicon.png', | ||
logo: 'https://www.nicesss.com/wp-content/themes/ripro/assets/images/favicon/favicon.png', | ||
item: items.slice(0, limit), | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
'/:limit?': ['Steven-Fake'], | ||
'/search/:keyword/:limit?': ['Steven-Fake'], | ||
'/tag/:tag/:limit?': ['Steven-Fake'], | ||
'/category/:category/:limit?': ['Steven-Fake'], | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = (router) => { | ||
router.get('/:limit?', require('./index')); | ||
router.get('/search/:keyword/:limit?', require('./search')); | ||
router.get('/tag/:tag/:limit?', require('./tag')); | ||
router.get('/category/:category/:limit?', require('./category')); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const utils = require('./utils'); | ||
|
||
module.exports = async (ctx) => { | ||
const keyword = decodeURIComponent(ctx.params.keyword); | ||
const limit = ctx.params.limit || 20; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use the common parameter |
||
const items = []; | ||
let currPage = 1; | ||
do { | ||
const url = `https://www.nicesss.com/page/${currPage}?s=${keyword}`; | ||
try { | ||
// eslint-disable-next-line no-await-in-loop | ||
const { data: response } = await got(url); | ||
|
||
const content = cheerio.load(response); | ||
// eslint-disable-next-line no-await-in-loop | ||
const newItems = await utils.ProcessItems(ctx, content); | ||
|
||
items.push(...newItems); | ||
} catch { | ||
break; | ||
} | ||
} while (items.length < limit && currPage++ < 10); | ||
|
||
ctx.state.data = { | ||
title: `呦糖社 - “${keyword}”搜索结果`, | ||
link: `https://www.nicesss.com/?s=${keyword}`, | ||
description: `呦糖社 - “${keyword}”搜索结果`, | ||
image: 'https://www.nicesss.com/wp-content/themes/ripro/assets/images/logo/logo-light.png', | ||
icon: 'https://www.nicesss.com/wp-content/themes/ripro/assets/images/favicon/favicon.png', | ||
logo: 'https://www.nicesss.com/wp-content/themes/ripro/assets/images/favicon/favicon.png', | ||
item: items.slice(0, limit), | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const utils = require('./utils'); | ||
|
||
module.exports = async (ctx) => { | ||
const tag = decodeURIComponent(ctx.params.tag); | ||
const limit = ctx.params.limit || 20; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use the common parameter |
||
const items = []; | ||
let currPage = 1; | ||
do { | ||
const url = `https://www.nicesss.com/archives/tag/${tag}/page/${currPage}`; | ||
try { | ||
// eslint-disable-next-line no-await-in-loop | ||
const { data: response } = await got(url); | ||
|
||
const content = cheerio.load(response); | ||
// eslint-disable-next-line no-await-in-loop | ||
const newItems = await utils.ProcessItems(ctx, content); | ||
|
||
items.push(...newItems); | ||
} catch { | ||
break; | ||
} | ||
} while (items.length < limit && currPage++ < 10); | ||
|
||
ctx.state.data = { | ||
title: `呦糖社 - “${tag}”Tag结果`, | ||
link: `https://www.nicesss.com/archives/tag/${tag}`, | ||
description: `呦糖社 - “${tag}”Tag结果`, | ||
image: 'https://www.nicesss.com/wp-content/themes/ripro/assets/images/logo/logo-light.png', | ||
icon: 'https://www.nicesss.com/wp-content/themes/ripro/assets/images/favicon/favicon.png', | ||
logo: 'https://www.nicesss.com/wp-content/themes/ripro/assets/images/favicon/favicon.png', | ||
item: items.slice(0, limit), | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
function ParseImgs(html) { | ||
// 解析详情页的全部图片 | ||
const $ = cheerio.load(html); | ||
|
||
return $('img.alignnone') | ||
.toArray() | ||
.map((img) => { | ||
const src = img.attribs['data-srcset']; | ||
const alt = img.attribs.alt; | ||
return { src, alt }; | ||
}); | ||
} | ||
function ParseDownloadLinks(html, defaultDrive) { | ||
// 解析详情页的全部下载链接 | ||
const $ = cheerio.load(html); | ||
const links = $('center button a').toArray(); | ||
|
||
return links.slice(0, Math.floor(links.length / 2)).map((link) => { | ||
const href = link.attribs.href; | ||
let text = ''; | ||
if (href.includes('rosefile')) { | ||
text = 'RoseFile'; | ||
} else if (href.includes('77file')) { | ||
text = '77File'; | ||
} else if (href.includes('stfly') || href.includes('shrinkme') || href.includes('ouo.io') || href.includes('link1s')) { | ||
|
||
text = defaultDrive; | ||
} else { | ||
text = '未知下载方式'; | ||
} | ||
|
||
return { href, text }; | ||
}); | ||
} | ||
|
||
module.exports = { | ||
ProcessItems: async (ctx, content) => { | ||
let items = content('div.row.posts-wrapper article') // 列表页数据,基本信息 | ||
.toArray() | ||
.map((item) => { | ||
item = content(item); | ||
const link = item.find('a').first().attr('href'); | ||
|
||
return { | ||
title: item.find('h2').text(), | ||
link, | ||
pubDate: parseDate(item.find('time').attr('datetime')), | ||
author: item.find('span.meta-category').first().text(), | ||
}; | ||
}); | ||
|
||
items = await Promise.all( | ||
// 获取详情页数据 | ||
items.map((item) => | ||
ctx.cache.tryGet(item.link, async () => { | ||
const { data: detailResponse } = await got(item.link); | ||
const content = cheerio.load(detailResponse); | ||
|
||
const uploader = content('span.sjblog-name a').first(); | ||
const uploadDate = content('span.sjblog-time').first(); | ||
let metaInfos = []; | ||
|
||
metaInfos = content('font') // 部分元信息 | ||
.toArray() | ||
.map((info) => { | ||
info = content(info); | ||
return { | ||
key: info | ||
.text() | ||
.split(':')[0] | ||
.replaceAll(/\[|]|-|[A-Za-z]/g, ''), | ||
value: info.text().split(':')[1], | ||
}; | ||
}); | ||
if (metaInfos.length === 0) { | ||
metaInfos = [ | ||
{ key: '解压密码', value: '未知密码' }, | ||
{ key: '下载网盘', value: '未知网盘' }, | ||
{ key: '图片像素', value: '未知' }, | ||
{ key: '联系邮箱', value: '未知' }, | ||
]; | ||
} | ||
let tags = content('div.entry-tags').first(); | ||
tags = tags | ||
.find('a') | ||
.toArray() | ||
.map((tag) => content(tag).text()); | ||
const imgs = ParseImgs(detailResponse); // 详情页,预览图列表 | ||
const downloadLinks = ParseDownloadLinks(detailResponse, metaInfos[1].value); // 详情页,下载链接列表 | ||
|
||
item.category = tags; | ||
item.author = uploader.text(); | ||
// 如果downloadLinks中有defaultDrive的,将其设为item.enclosure_url | ||
item.enclosure_url = downloadLinks.find((link) => link.text === metaInfos[1].value)?.href || ''; | ||
item.description = ` | ||
<ul> | ||
<li> | ||
<b>上传日期</b>:${uploadDate.text().split(':')[1]} | ||
</li> | ||
<li> | ||
<b>上传者</b>: ${uploader.text()} | ||
</li> | ||
<li> | ||
<b>类型</b>: ${item.author} | ||
</li> | ||
${metaInfos.map((info) => `<li><b>${info.key}</b>: ${info.value}</li>`).join('')} | ||
<li> | ||
<b>下载链接</b>: | ||
<ul>${downloadLinks.map((link) => `<li><a href="${link.href}">${link.text}</a></li>`).join('')}</ul> | ||
</li> | ||
<li> | ||
<b>标签</b>: | ||
<ul>${tags.map((tag) => `<li><a href="https://www.nicesss.com/archives/tag/${tag}">${tag}</a></li>`).join('')}</ul> | ||
</li> | ||
</ul> | ||
<div> | ||
${imgs.map((img) => `<img src="${img.src}" alt="${img.alt}" /><br>`).join('')} | ||
</div>`; | ||
|
||
return item; | ||
}) | ||
) | ||
); | ||
return items; | ||
}, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the common parameter
limit
fromctx.query.limit
.docs: https://docs.rsshub.app/parameter#limit-entries