Skip to content

Commit

Permalink
feat(route): add Asian to lick (#8156)
Browse files Browse the repository at this point in the history
Co-authored-by: SettingDust <[email protected]>
Co-authored-by: DIYgod <[email protected]>
  • Loading branch information
3 people authored Nov 27, 2021
1 parent 1e6c0cf commit b0bd4ba
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/en/picture.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions docs/picture.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

### 分类
Expand Down
3 changes: 3 additions & 0 deletions lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
64 changes: 64 additions & 0 deletions lib/routes/asiantolick/index.js
Original file line number Diff line number Diff line change
@@ -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,
};
};

1 comment on commit b0bd4ba

@vercel
Copy link

@vercel vercel bot commented on b0bd4ba Nov 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.