mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-11 15:47:48 +08:00
fix(route): 1X Gallery (#7923)
This commit is contained in:
@@ -8,11 +8,13 @@ pageClass: routes
|
|||||||
|
|
||||||
### Photos
|
### Photos
|
||||||
|
|
||||||
<RouteEn author="nczitzk" example="/1x/latest/all" path="/1x/:type?/:caty?" :paramsDesc="['sort type, `latest` by default, or `popular` or `curators-choice`', 'picture category, `all` by default, see below']">
|
<RouteEn author="nczitzk" example="/1x" path="/1x/:category?" :paramsDesc="['Category, Latest awarded by default, see below']">
|
||||||
|
|
||||||
| Picture Category | Code |
|
| Category | Title |
|
||||||
| ---------------- | ------------- |
|
| ---------------- | ------------- |
|
||||||
| All categories | all |
|
| Latest awarded | latest |
|
||||||
|
| Popular | popular |
|
||||||
|
| Latest published | published |
|
||||||
| Abstract | abstract |
|
| Abstract | abstract |
|
||||||
| Action | action |
|
| Action | action |
|
||||||
| Animals | animals |
|
| Animals | animals |
|
||||||
|
|||||||
@@ -8,31 +8,33 @@ pageClass: routes
|
|||||||
|
|
||||||
### Photos
|
### Photos
|
||||||
|
|
||||||
<Route author="nczitzk" example="/1x/latest/all" path="/1x/:type?/:caty?" :paramsDesc="['排序类型,默认为 `latest`,亦可选 `popular` 或 `curators-choice`', '图片类别,默认为 `all`,见下表']">
|
<Route author="nczitzk" example="/1x" path="/1x/:category?" :paramsDesc="['类别,默认为 Latest awarded,见下表']">
|
||||||
|
|
||||||
| 图片类别 | 代码 |
|
| Category | Title |
|
||||||
| -------------- | ------------- |
|
| ---------------- | ------------- |
|
||||||
| All categories | all |
|
| Latest awarded | latest |
|
||||||
| Abstract | abstract |
|
| Popular | popular |
|
||||||
| Action | action |
|
| Latest published | published |
|
||||||
| Animals | animals |
|
| Abstract | abstract |
|
||||||
| Architecture | architecture |
|
| Action | action |
|
||||||
| Conceptual | conceptual |
|
| Animals | animals |
|
||||||
| Creative edit | creative-edit |
|
| Architecture | architecture |
|
||||||
| Documentary | documentary |
|
| Conceptual | conceptual |
|
||||||
| Everyday | everyday |
|
| Creative edit | creative-edit |
|
||||||
| Fine Art Nude | fine-art-nude |
|
| Documentary | documentary |
|
||||||
| Humour | humour |
|
| Everyday | everyday |
|
||||||
| Landscape | landscape |
|
| Fine Art Nude | fine-art-nude |
|
||||||
| Macro | macro |
|
| Humour | humour |
|
||||||
| Mood | mood |
|
| Landscape | landscape |
|
||||||
| Night | night |
|
| Macro | macro |
|
||||||
| Performance | performance |
|
| Mood | mood |
|
||||||
| Portrait | portrait |
|
| Night | night |
|
||||||
| Still life | still-life |
|
| Performance | performance |
|
||||||
| Street | street |
|
| Portrait | portrait |
|
||||||
| Underwater | underwater |
|
| Still life | still-life |
|
||||||
| Wildlife | wildlife |
|
| Street | street |
|
||||||
|
| Underwater | underwater |
|
||||||
|
| Wildlife | wildlife |
|
||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
|||||||
@@ -3386,7 +3386,7 @@ router.get('/chaping/news/:caty?', require('./routes/chaping/news'));
|
|||||||
router.get('/feixuew/:id?', require('./routes/feixuew/index'));
|
router.get('/feixuew/:id?', require('./routes/feixuew/index'));
|
||||||
|
|
||||||
// 1X
|
// 1X
|
||||||
router.get('/1x/:type?/:caty?', require('./routes/1x/index'));
|
router.get('/1x/:category?', require('./routes/1x/index'));
|
||||||
|
|
||||||
// 剑网3
|
// 剑网3
|
||||||
router.get('/jx3/:caty?', require('./routes/jx3/news'));
|
router.get('/jx3/:caty?', require('./routes/jx3/news'));
|
||||||
|
|||||||
@@ -1,36 +1,69 @@
|
|||||||
const got = require('@/utils/got');
|
const got = require('@/utils/got');
|
||||||
const cheerio = require('cheerio');
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
|
const categories = {
|
||||||
|
latest: 'latest',
|
||||||
|
popular: 'popular',
|
||||||
|
published: 'published',
|
||||||
|
abstract: 'latest:15:',
|
||||||
|
action: 'latest:1:',
|
||||||
|
animals: 'latest:21:',
|
||||||
|
architecture: 'latest:11:',
|
||||||
|
conceptual: 'latest:17:',
|
||||||
|
'creative-edit': 'latest:10:',
|
||||||
|
documentary: 'latest:8:',
|
||||||
|
everyday: 'latest:14:',
|
||||||
|
'fine-art-nude': 'latest:12:',
|
||||||
|
humour: 'latest:3:',
|
||||||
|
landscape: 'latest:6:',
|
||||||
|
macro: 'latest:2:',
|
||||||
|
mood: 'latest:4:',
|
||||||
|
night: 'latest:9:',
|
||||||
|
performance: 'latest:19:',
|
||||||
|
portrait: 'latest:13:',
|
||||||
|
'still-life': 'latest:18:',
|
||||||
|
street: 'latest:7:',
|
||||||
|
underwater: 'latest:20:',
|
||||||
|
wildlife: 'latest:5:',
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
ctx.params.type = ctx.params.type || 'latest';
|
const category = ctx.params.category || 'latest';
|
||||||
ctx.params.caty = ctx.params.caty || 'all';
|
|
||||||
|
|
||||||
const rootUrl = `https://1x.com`;
|
const rootUrl = `https://1x.com`;
|
||||||
const currentUrl = `${rootUrl}/photos/${ctx.params.type}/${ctx.params.caty}`;
|
const currentUrl = `${rootUrl}/gallery/${category}`;
|
||||||
|
const apiUrl = `${rootUrl}/backend/lm.php?style=normal&mode=${categories[category]}&from=0&autoload=`;
|
||||||
const response = await got({
|
const response = await got({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url: currentUrl,
|
url: apiUrl,
|
||||||
});
|
});
|
||||||
|
|
||||||
const $ = cheerio.load(response.data);
|
const $ = cheerio.load(response.data);
|
||||||
|
|
||||||
const list = $('#photos_target')
|
const items = $('root data')
|
||||||
.find('td a img')
|
.html()
|
||||||
.slice(0, 30)
|
.split('\n')
|
||||||
.map((_, item) => {
|
.slice(0, -1)
|
||||||
|
.map((item) => {
|
||||||
item = $(item);
|
item = $(item);
|
||||||
|
|
||||||
|
const id = item
|
||||||
|
.find('.photos-feed-image')
|
||||||
|
.attr('id')
|
||||||
|
.match(/img-(\d+)/)[1];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: item.attr('title'),
|
guid: id,
|
||||||
link: `${rootUrl}/${item.parent().attr('href')}`,
|
link: `${rootUrl}/photo/${id}`,
|
||||||
description: `<img src="${item.attr('src')}">`,
|
author: item.find('.photos-feed-data-name').eq(0).text(),
|
||||||
author: item.attr('title'),
|
title: item.find('.photos-feed-data-title').text() || 'Untitled',
|
||||||
|
description: `<img src="${item.find('.photos-feed-image').attr('src')}">`,
|
||||||
};
|
};
|
||||||
})
|
});
|
||||||
.get();
|
|
||||||
|
|
||||||
ctx.state.data = {
|
ctx.state.data = {
|
||||||
title: `${$('title').text()} - ${ctx.params.caty}`,
|
title: `${category} - 1X`,
|
||||||
link: currentUrl,
|
link: currentUrl,
|
||||||
item: list,
|
item: items,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user