fix(route): Asian to Lick (#9891)

This commit is contained in:
Ethan Shen 2022-06-04 12:29:14 +08:00 committed by GitHub
parent 78165d77b2
commit e31a851333
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 64 additions and 18 deletions

View File

@ -4034,7 +4034,7 @@ router.get('/netflix/newsroom/:category?/:region?', lazyloadRouteHandler('./rout
router.get('/sbs/chinese/:category?/:id?/:dialect?/:language?', lazyloadRouteHandler('./routes/sbs/chinese'));
// Asian to lick
router.get('/asiantolick/:category?/:keyword?', lazyloadRouteHandler('./routes/asiantolick'));
// router.get('/asiantolick/:category?/:keyword?', lazyloadRouteHandler('./routes/asiantolick'));
// Research Gate
router.get('/researchgate/publications/:id', lazyloadRouteHandler('./routes/researchgate/publications'));

View File

@ -1,13 +1,22 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
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 rootUrl = 'https://asiantolick.com';
const currentUrl = `${rootUrl}${category === 'category' ? `/category-${keyword}` : ''}${category === 'tag' ? `/tag-${keyword}` : ''}${category === 'search' ? `/search/${keyword}` : ''}`;
const currentUrl = `${rootUrl}${urls[category]}`;
const response = await got({
method: 'get',
@ -16,37 +25,31 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('.miniatura')
.map((_, item) => {
let items = $('.miniatura')
.toArray()
.map((item) => {
item = $(item);
return {
link: item.attr('href'),
title: item.find('.titulo_video').text(),
};
})
.get();
});
const items = await Promise.all(
list.map((item) =>
items = await Promise.all(
items.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.description = art(path.join(__dirname, 'templates/description.art'), {
images: content('.gallery_img')
.toArray()
.map((i) => content(i).attr('data-src')),
});
item.pubDate = parseDate(detailResponse.data.match(/"pubDate": "(.*)",/)[1]);

View File

@ -0,0 +1,6 @@
module.exports = {
'/': ['nczitzk'],
'/category/:id?': ['nczitzk'],
'/tag/:id?': ['nczitzk'],
'/search/:id?': ['nczitzk'],
};

View File

@ -0,0 +1,31 @@
module.exports = {
'asiantolick.com': {
_name: 'Asian to lick',
'.': [
{
title: '首页',
docs: 'https://docs.rsshub.app/picture.html#asian-to-lick-shou-ye',
source: ['/'],
target: '/asiantolick',
},
{
title: '分类',
docs: 'https://docs.rsshub.app/picture.html#asian-to-lick-fen-lei',
source: ['/'],
target: (params, url) => `/asiantolick/category/${new URL(url).toString().split('-').pop()}`,
},
{
title: '标签',
docs: 'https://docs.rsshub.app/picture.html#asian-to-lick-biao-qian',
source: ['/'],
target: (params, url) => `/asiantolick/tag/${new URL(url).toString().split('-').pop()}`,
},
{
title: '搜索',
docs: 'https://docs.rsshub.app/picture.html#asian-to-lick-sou-suo',
source: ['/search/:keyword', '/'],
target: '/asiantolick/search/:keyword?',
},
],
},
};

View File

@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/:category?/:keyword?', require('./index'));
};

View File

@ -0,0 +1,3 @@
{{ each images image }}
<img src="{{ image }}">
{{ /each }}