Skip to content

Commit

Permalink
feat(route): add Asian to lick News (#13517)
Browse files Browse the repository at this point in the history
* feat(route): add Asian to lick News

* fix: add null checks
  • Loading branch information
nczitzk authored Oct 13, 2023
1 parent e9f407a commit 2efaaa7
Show file tree
Hide file tree
Showing 6 changed files with 191 additions and 52 deletions.
100 changes: 73 additions & 27 deletions lib/v2/asiantolick/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,63 +5,109 @@ const { art } = require('@/utils/render');
const path = require('path');

module.exports = async (ctx) => {
const category = ctx.params.category ?? '';
const keyword = ctx.params.keyword ?? '';

const urls = {
'': '',
category: `/category-${keyword}`,
tag: `/tag-${keyword}`,
search: `/search/${keyword}`,
};
const { category } = ctx.params;
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 24;

const rootUrl = 'https://asiantolick.com';
const currentUrl = `${rootUrl}${urls[category]}`;
const apiUrl = new URL('ajax/buscar_posts.php', rootUrl).href;
const currentUrl = new URL(category?.replace(/^(tag|category)?\/(\d+)/, '$1-$2') ?? '', rootUrl).href;

const searchParams = {};
const matches = category?.match(/^(tag|category|search|page)?(?:-|\/)?(\w+)/) ?? undefined;

if (matches) {
const key = matches[1] === 'category' ? 'cat' : matches[1];
const value = matches[2];
searchParams[key] = value;
} else if (category) {
searchParams.page = 'news';
}

const response = await got({
method: 'get',
url: currentUrl,
const { data: response } = await got(apiUrl, {
searchParams,
});

const $ = cheerio.load(response.data);
let $ = cheerio.load(response);

let items = $('.miniatura')
let items = $('a.miniatura')
.slice(0, limit)
.toArray()
.map((item) => {
item = $(item);

const image = item.find('div.background_miniatura img');

return {
link: item.attr('href'),
title: item.find('.titulo_video').text(),
title: item.find('div.base_tt').text(),
link: item.prop('href'),
description: art(path.join(__dirname, 'templates/description.art'), {
images: image
? [
{
src: image.prop('data-src').split(/\?/)[0],
alt: image.prop('alt'),
},
]
: undefined,
}),
author: item.find('.author').text(),
category: item
.find('.category')
.toArray()
.map((c) => $(c).text()),
guid: image ? image.prop('post-id') : item.link.match(/\/(\d+)/)[1],
};
});

items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
});
const { data: detailResponse } = await got(item.link);

const content = cheerio.load(detailResponse.data);
const content = cheerio.load(detailResponse);

item.title = content('h1').first().text();
item.description = art(path.join(__dirname, 'templates/description.art'), {
images: content('.gallery_img')
description: content('#metadata_qrcode').html(),
images: content('div.miniatura')
.toArray()
.map((i) => content(i).attr('data-src')),
.map((i) => ({
src: content(i).prop('data-src'),
alt: content(i).find('img').prop('alt'),
})),
});
item.author = content('.author').text();
item.category = content('#categoria_tags_post a')
.toArray()
.map((c) => content(c).text().trim().replace(/^#/, ''));
item.pubDate = parseDate(detailResponse.match(/"pubDate":\s"((?!http)[^"]*)"/)[1]);
item.updated = parseDate(detailResponse.match(/"upDate":\s"((?!http)[^"]*)"/)[1]);
item.enclosure_url = new URL(`ajax/download_post.php?ver=3&dir=/down/new_${item.guid}&post_id=${item.guid}&post_name=${detailResponse.match(/"title":\s"((?!http)[^"]*)"/)[1]}`, rootUrl).href;

item.pubDate = parseDate(detailResponse.data.match(/"pubDate": "(.*)",/)[1]);
item.guid = `asiantolick-${item.guid}`;

return item;
})
)
);

const { data: currentResponse } = await got(currentUrl);

$ = cheerio.load(currentResponse);

const title = $('title').text().split(/-/)[0].trim();
const icon = $('link[rel="icon"]').first().prop('href');

ctx.state.data = {
title: $('title').text(),
link: currentUrl,
item: items,
title: title === 'Asian To Lick' ? title : `Asian To Lick - ${title}`,
link: currentUrl,
description: $('meta[property="og:description"]').prop('content'),
language: $('html').prop('lang'),
image: $('meta[name="msapplication-TileImage"]').prop('content'),
icon,
logo: icon,
subtitle: title,
allowEmpty: true,
};
};
8 changes: 5 additions & 3 deletions lib/v2/asiantolick/maintainer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module.exports = {
'/': ['nczitzk'],
'/category/:id?': ['nczitzk'],
'/tag/:id?': ['nczitzk'],
'/search/:id?': ['nczitzk'],
'/category/:id': ['nczitzk'],
'/page/news': ['nczitzk'],
'/page/:id': ['nczitzk'],
'/search/:keyword': ['nczitzk'],
'/tag/:id': ['nczitzk'],
};
46 changes: 34 additions & 12 deletions lib/v2/asiantolick/radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,50 @@ module.exports = {
_name: 'Asian to lick',
'.': [
{
title: '首页',
docs: 'https://docs.rsshub.app/routes/picture#asian-to-lick-shou-ye',
title: 'Top rated',
docs: 'https://docs.rsshub.app/routes/picture#asian-to-lick-top-rated',
source: ['/'],
target: '/asiantolick',
},
{
title: '分类',
docs: 'https://docs.rsshub.app/routes/picture#asian-to-lick-fen-lei',
title: 'News',
docs: 'https://docs.rsshub.app/routes/picture#asian-to-lick-news',
source: ['/page/news'],
target: '/asiantolick/page/news',
},
{
title: 'Category',
docs: 'https://docs.rsshub.app/routes/picture#asian-to-lick-category',
source: ['/'],
target: (params, url) => `/asiantolick/category/${new URL(url).toString().split('-').pop()}`,
target: (params, url) => {
url = new URL(url);
const id = url.href.match(/\/category\/(\w+)/)[1];

return `/asiantolick${id ? `/category/${id}` : ''}`;
},
},
{
title: '标签',
docs: 'https://docs.rsshub.app/routes/picture#asian-to-lick-biao-qian',
title: 'Tag',
docs: 'https://docs.rsshub.app/routes/picture#asian-to-lick-tag',
source: ['/'],
target: (params, url) => `/asiantolick/tag/${new URL(url).toString().split('-').pop()}`,
target: (params, url) => {
url = new URL(url);
const id = url.href.match(/\/tag\/(\w+)/)[1];

return `/asiantolick${id ? `/tag/${id}` : ''}`;
},
},
{
title: 'Search',
docs: 'https://docs.rsshub.app/routes/picture#asian-to-lick-search',
source: ['/search/:keyword'],
target: '/asiantolick/search/:keyword',
},
{
title: '搜索',
docs: 'https://docs.rsshub.app/routes/picture#asian-to-lick-sou-suo',
source: ['/search/:keyword', '/'],
target: '/asiantolick/search/:keyword?',
title: 'Page',
docs: 'https://docs.rsshub.app/routes/picture#asian-to-lick-page',
source: ['/page/:id'],
target: '/asiantolick/page/:id',
},
],
},
Expand Down
4 changes: 2 additions & 2 deletions lib/v2/asiantolick/router.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = function (router) {
router.get('/:category?/:keyword?', require('./index'));
module.exports = (router) => {
router.get('/:category*', require('./'));
};
12 changes: 9 additions & 3 deletions lib/v2/asiantolick/templates/description.art
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
{{ each images image }}
<img src="{{ image }}">
{{ /each }}
{{@ description }}

{{ if images }}
{{ each images image }}
<figure>
<img src="{{ image.src }}" alt="{{ image.alt }}">
</figure>
{{ /each }}
{{ /if }}
73 changes: 68 additions & 5 deletions website/docs/routes/picture.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,84 @@

## Asian to lick {#asian-to-lick}

### Home {#asian-to-lick-home}
### Top rated {#asian-to-lick-top-rated}

<Route author="nczitzk" example="/asiantolick" path="/asiantolick"/>
<Route author="nczitzk" example="/asiantolick" path="/asiantolick" radar="1" rssbud="1"/>

### News {#asian-to-lick-news}

<Route author="nczitzk" example="/asiantolick/page/news" path="/asiantolick/page/news" radar="1" rssbud="1"/>

### Category {#asian-to-lick-category}

<Route author="nczitzk" example="/asiantolick/category/90" path="/asiantolick/category/:category?" paramsDesc={['Category, the id can be found in URL, homepage by default']}/>
<Route author="nczitzk" example="/asiantolick/category/90" path="/asiantolick/category/:id" paramsDesc={['Category id, can be found in URL']} radar="1" rssbud="1">

| Category | id |
| ---------- | ---- |
| Lolita | 90 |
| Hot Sister | 91 |
| Cosplay | 1030 |
| Sexy | 93 |
| Others | 94 |
| Thailand | 99 |
| Magazine | 100 |
| Hard Sexy | 103 |

</Route>

### Tag {#asian-to-lick-tag}

<Route author="nczitzk" example="/asiantolick/tag/1045" path="/asiantolick/tag/:tag?" paramsDesc={['Tag, the id can be found in URL, homepage by default']}/>
<Route author="nczitzk" example="/asiantolick/tag/1045" path="/asiantolick/tag/:id" paramsDesc={['Tag id, can be found in URL']} radar="1" rssbud="1">

| Aidol | Anal | Babe | Big Boobs | Big Pussy |
| ------------ | ------------ | ------------ | ------------ | ------------ |
| 2310 | 2233 | 1385 | 1106 | 1722 |
|
| Bikini | Blonde | blowjob | Close Up | Creamy Pussy |
| ------------ | ------------ | ------------ | ------------ | ------------ |
| 1206 | 2244 | 2167 | 2267 | 1117 |
|
| cum | Cute Girl | Dildo | Ebony | Feet |
| ------------ | ------------ | ------------ | ------------ | ------------ |
| 2163 | 1090 | 1082 | 2245 | 1323 |
|
| fetish | fingers | Fox Tail | Glasses | Hairy Pussy |
| ------------ | ------------ | ------------ | ------------ | ------------ |
| 2219 | 2197 | 1540 | 1268 | 1099 |
|
| Interracial | Lesbian | licked | Loli | Maid |
| ------------ | ------------ | ------------ | ------------ | ------------ |
| 2284 | 1080 | 2208 | 1045 | 1072 |
|
| Masturbate | Milf | non-nude | Nude | Nurse |
| ------------ | ------------ | ------------ | ------------ | ------------ |
| 1081 | 1705 | 2307 | 1393 | 1552 |
|
| Office | oiled | Outdoor | Pink Pussy | Pink Tits |
| ------------ | ------------ | ------------ | ------------ | ------------ |
| 1724 | 2176 | 2250 | 1161 | 1498 |
|
| Public | School Girl | Short Hair | skirt | Small Girl |
| ------------ | ------------ | ------------ | ------------ | ------------ |
| 1277 | 1046 | 1160 | 2159 | 1103 |
|
| Socks | sucking | Tattoo | Teen | Tiny Tits |
| ------------ | ------------ | ------------ | ------------ | ------------ |
| 2256 | 2199 | 1593 | 1036 | 2251 |
|
| Underwear | Uniform | wet | Young |
| ------------ | ------------ | ------------ | ------------ |
| 1324 | 1084 | 2179 | 1098 |

</Route>

### Search {#asian-to-lick-search}

<Route author="nczitzk" example="/asiantolick/search/lolita" path="/asiantolick/search/:keyword?" paramsDesc={['Keyword, empty by default']}/>
<Route author="nczitzk" example="/asiantolick/search/lolita" path="/asiantolick/search/:keyword" paramsDesc={['Keyword']} radar="1" rssbud="1"/>

### Page {#asian-to-lick-page}

<Route author="nczitzk" example="/asiantolick/page/news" path="/asiantolick/page/:id" paramsDesc={['Page id']} radar="1" rssbud="1"/>

## BabeHub {#babehub}

Expand Down

0 comments on commit 2efaaa7

Please sign in to comment.