feat(route): add Asian to lick (#8156)

Co-authored-by: SettingDust <settingdust@gmail.com>
Co-authored-by: DIYgod <diy.d.god@gmail.com>
This commit is contained in:
Ethan Shen 2021-11-27 15:46:21 +08:00 committed by GitHub
parent 1e6c0cf282
commit b0bd4baf40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 103 additions and 0 deletions

View File

@ -38,6 +38,24 @@ pageClass: routes
</RouteEn>
## Asian to lick
### Home
<RouteEn author="nczitzk" example="/asiantolick" path="/asiantolick"/>
### Category
<RouteEn author="nczitzk" example="/asiantolick/category/90" path="/asiantolick/category/:category?" :paramsDesc="['Category, the id can be found in URL, homepage by default']"/>
### Tag
<RouteEn author="nczitzk" example="/asiantolick/tag/1045" path="/asiantolick/tag/:tag?" :paramsDesc="['Tag, the id can be found in URL, homepage by default']"/>
### Search
<RouteEn author="nczitzk" example="/asiantolick/search/lolita" path="/asiantolick/search/:keyword?" :paramsDesc="['Keyword, empty by default']"/>
## BabeHub
### Category

View File

@ -48,6 +48,24 @@ pageClass: routes
<Route author="KotoriK" example="/8kcos/cat/8kasianidol" path="/8kcos/cat/:cat*" :paramsDesc="['默认值为8kasianidol将目录页面url中 /category/ 后面的部分填入。如https://www.8kcosplay.com/category/8kchineseidol/%e9%a3%8e%e4%b9%8b%e9%a2%86%e5%9f%9f/ 对应的RSS页面为/8kcos/cat/8kchineseidol/%e9%a3%8e%e4%b9%8b%e9%a2%86%e5%9f%9f/。']"/>
## Asian to lick
### 首页
<Route author="nczitzk" example="/asiantolick" path="/asiantolick"/>
### 分类
<Route author="nczitzk" example="/asiantolick/category/90" path="/asiantolick/category/:category?" :paramsDesc="['分类,可在对应分类页 URL 中找到分类编号,默认为首页']"/>
### 标签
<Route author="nczitzk" example="/asiantolick/tag/90" path="/asiantolick/tag/:tag?" :paramsDesc="['标签,可在对应标签页 URL 中找到标签编号,默认为首页']"/>
### 搜索
<Route author="nczitzk" example="/asiantolick/search/lolita" path="/asiantolick/search/:keyword?" :paramsDesc="['关键词,默认为空']"/>
## BabeHub
### 分类

View File

@ -4227,6 +4227,9 @@ router.get('/now/news/rank', lazyloadRouteHandler('./routes/now/rank'));
// s-hentai
router.get('/s-hentai/:id?', lazyloadRouteHandler('./routes/s-hentai'));
// Asian to lick
router.get('/asiantolick/:category?/:keyword?', lazyloadRouteHandler('./routes/asiantolick'));
// Deprecated: DO NOT ADD ROUTE HERE
// Research Gate

View File

@ -0,0 +1,64 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const category = ctx.params.category ?? '';
const keyword = ctx.params.keyword ?? '';
const rootUrl = 'https://asiantolick.com';
const currentUrl = `${rootUrl}${category === 'category' ? `/category-${keyword}` : ''}${category === 'tag' ? `/tag-${keyword}` : ''}${category === 'search' ? `/search/${keyword}` : ''}`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
const list = $('.miniatura')
.map((_, item) => {
item = $(item);
return {
link: item.attr('href'),
title: item.find('.titulo_video').text(),
};
})
.get();
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
});
const downloadResponse = await got({
method: 'get',
url: `${rootUrl}/ajax/download_post.php?ver=1&dir=/down/3_750&post_id=${item.link.match(/post-\d+\//)[1]}&post_name=${item.title}`,
});
const content = cheerio.load(detailResponse.data);
item.enclosure_url = `${rootUrl}/temp_dl/${downloadResponse.data}`;
item.description = `<p>${content('meta[name="description"]').attr('content')}</p><a href=${item.enclosure_url}>Download ZIP</a>`;
content('.gallery_img').each(function () {
item.description += `<div><img src="${content(this).attr('data-src')}"></div>`;
});
item.pubDate = parseDate(detailResponse.data.match(/"pubDate": "(.*)",/)[1]);
return item;
})
)
);
ctx.state.data = {
title: $('title').text(),
link: currentUrl,
item: items,
};
};