parent
c227142051
commit
ae3bccdf2a
|
|
@ -64,6 +64,16 @@ pageClass: routes
|
|||
|
||||
<Route author="nczitzk" example="/35photo/author/mariuszsix" path="/35photo/author/:id" :paramsDesc="['id,可在对应作者页 URL 中找到']"/>
|
||||
|
||||
## 500px 摄影社区
|
||||
|
||||
### 部落影集
|
||||
|
||||
<Route author="TonyRL" example="/500px/tribe/set/f5de0b8aa6d54ec486f5e79616418001" path="/500px/tribe/set/:id" :paramsDesc="['部落 ID']" radar="1"/>
|
||||
|
||||
### 摄影师作品
|
||||
|
||||
<Route author="TonyRL" example="/500px/user/works/hujunli" path="/500px/user/works/:id" :paramsDesc="['摄影师 ID']" radar="1"/>
|
||||
|
||||
## 8KCosplay
|
||||
|
||||
### 最新
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = {
|
||||
'/tribe/set/:id': ['TonyRL'],
|
||||
'/user/works/:id': ['TonyRL'],
|
||||
};
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
module.exports = {
|
||||
'500px.com.cn': {
|
||||
_name: '500px 摄影社区',
|
||||
'.': [
|
||||
{
|
||||
title: '部落影集',
|
||||
docs: 'https://docs.rsshub.app/picture.html#_500px-she-ying-she-qu',
|
||||
source: ['/page/tribe/detail'],
|
||||
target: (_, url) => `/500px/tribe/set/${url.searchParams.get('tribeId')}`,
|
||||
},
|
||||
{
|
||||
title: '摄影师作品',
|
||||
docs: 'https://docs.rsshub.app/picture.html#_500px-she-ying-she-qu',
|
||||
source: ['/:id', '/community/user-details/:id', '/community/user-details/:id/*'],
|
||||
target: '/500px/user/works/:id',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/tribe/set/:id', require('./tribeSet'));
|
||||
router.get('/user/works/:id', require('./user'));
|
||||
};
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{{ if item.description }}<p>{{ item.description }}</p>{{ /if }}
|
||||
{{ if item.photos }}
|
||||
{{ each item.photos p }}
|
||||
<img src="{{ p.url.baseUrl }}!p5">
|
||||
{{ /each }}
|
||||
{{ /if }}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{{ if item.url }}
|
||||
<img src="{{ item.url.baseUrl }}!p5">
|
||||
{{ /if }}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
|
||||
const { baseUrl, getTribeDetail, getTribeSets } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { id } = ctx.params;
|
||||
const limit = parseInt(ctx.query.limit) || 100;
|
||||
|
||||
const { tribe } = await getTribeDetail(id, ctx.cache.tryGet);
|
||||
const tribeSets = await getTribeSets(id, limit, ctx.cache.tryGet);
|
||||
|
||||
const items = tribeSets.map((item) => ({
|
||||
title: item.title,
|
||||
description: art(path.join(__dirname, 'templates/tribeSet.art'), { item }),
|
||||
author: item.uploaderInfo.nickName,
|
||||
pubDate: parseDate(item.createdTime, 'x'),
|
||||
link: `${baseUrl}/community/set/${item.id}/details`,
|
||||
}));
|
||||
|
||||
ctx.state.data = {
|
||||
title: tribe.name,
|
||||
description: `${tribe.watchword} - ${tribe.introduce}`,
|
||||
link: `${baseUrl}/page/tribe/detail?tribeId=${id}&pagev=set`,
|
||||
image: tribe.avatar.a1,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
const { art } = require('@/utils/render');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const path = require('path');
|
||||
const { baseUrl, getUserInfoFromUsername, getUserInfoFromId, getUserWorks } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
let { id } = ctx.params;
|
||||
const limit = parseInt(ctx.query.limit) || 100;
|
||||
|
||||
if (id.length !== 33) {
|
||||
id = (await getUserInfoFromUsername(id, ctx.cache.tryGet)).id;
|
||||
}
|
||||
|
||||
const userInfo = await getUserInfoFromId(id, ctx.cache.tryGet);
|
||||
const userWorks = await getUserWorks(id, limit, ctx.cache.tryGet);
|
||||
|
||||
const items = userWorks.map((item) => ({
|
||||
title: item.title || '无题',
|
||||
description: art(path.join(__dirname, 'templates/user.art'), { item }),
|
||||
author: item.uploaderInfo.nickName,
|
||||
pubDate: parseDate(item.createdTime, 'x'),
|
||||
link: `${baseUrl}/community/photo-details/${item.id}`,
|
||||
}));
|
||||
|
||||
ctx.state.data = {
|
||||
title: userInfo.nickName,
|
||||
description: userInfo.about,
|
||||
image: userInfo.avatar.a1,
|
||||
link: `${baseUrl}/${id}`,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const config = require('@/config').value;
|
||||
|
||||
const baseUrl = 'https://500px.com.cn';
|
||||
|
||||
/*
|
||||
ty_rum.server = {
|
||||
id: 'Fm3hXcTiLT8',
|
||||
ignore_err: true,
|
||||
beacon: 'beacon.tingyun.com',
|
||||
beacon_err: 'beacon-err.tingyun.com',
|
||||
key: 'M1laN7-zRM0',
|
||||
trace_threshold: 7000,
|
||||
custom_urls: [],
|
||||
sr: 1.0,
|
||||
};
|
||||
v && v.id && this._ty_rum && y(this._ty_rum.url) && (this._ty_rum.r = (new Date).getTime() % 1e8,
|
||||
this.setRequestHeader && this.setRequestHeader("X-Tingyun-Id", v.id + ";r=" + this._ty_rum.r))
|
||||
*/
|
||||
const headers = {
|
||||
// {"anonymousId":"","latitude":null,"longitude":null,"manufacturer":"","province":"","area":"","city":""}
|
||||
'x-500px-client-info': 'eyJhbm9ueW1vdXNJZCI6IiIsImxhdGl0dWRlIjpudWxsLCJsb25naXR1ZGUiOm51bGwsIm1hbnVmYWN0dXJlciI6IiIsInByb3ZpbmNlIjoiIiwiYXJlYSI6IiIsImNpdHkiOiIifQ==',
|
||||
'X-Tingyun-Id': `Fm3hXcTiLT8;r=${new Date().getTime() % 1e8}`,
|
||||
};
|
||||
|
||||
const getUserInfoFromUsername = (username, tryGet) =>
|
||||
tryGet(`500px:user:${username}`, async () => {
|
||||
const { data } = await got(`${baseUrl}/${username}`);
|
||||
const $ = cheerio.load(data);
|
||||
return JSON.parse(
|
||||
$('script[type="text/javascript"]')
|
||||
.text()
|
||||
.match(/var cur_user = new Object\((.*?)\);/)[1]
|
||||
);
|
||||
});
|
||||
|
||||
const getUserInfoFromId = (id, tryGet) =>
|
||||
tryGet(`500px:user:indexInfo:${id}`, async () => {
|
||||
const { data } = await got(`${baseUrl}/community/v2/user/indexInfo`, {
|
||||
headers: {
|
||||
...headers,
|
||||
},
|
||||
searchParams: {
|
||||
queriedUserId: id,
|
||||
},
|
||||
});
|
||||
return data.data;
|
||||
});
|
||||
|
||||
const getUserWorks = (id, limit, tryGet) =>
|
||||
tryGet(
|
||||
`500px:user:profile:${id}`,
|
||||
async () => {
|
||||
const { data } = await got(`${baseUrl}/community/v2/user/profile`, {
|
||||
headers: {
|
||||
...headers,
|
||||
},
|
||||
searchParams: {
|
||||
resourceType: '0,2,4',
|
||||
imgsize: 'p1,p2,p3,p4',
|
||||
queriedUserId: id,
|
||||
startTime: '',
|
||||
page: 1,
|
||||
size: limit,
|
||||
type: 'json',
|
||||
},
|
||||
});
|
||||
return data.data;
|
||||
},
|
||||
config.cache.routeExpire,
|
||||
false
|
||||
);
|
||||
|
||||
const getTribeDetail = (id, tryGet) =>
|
||||
tryGet(
|
||||
`500px:tribeDetail:${id}`,
|
||||
async () => {
|
||||
const { data } = await got(`${baseUrl}/community/tribe/tribeDetail`, {
|
||||
headers: {
|
||||
...headers,
|
||||
},
|
||||
searchParams: {
|
||||
tribeId: id,
|
||||
},
|
||||
});
|
||||
return data.data;
|
||||
},
|
||||
config.cache.routeExpire,
|
||||
false
|
||||
);
|
||||
|
||||
const getTribeSets = (id, limit, tryGet) =>
|
||||
tryGet(
|
||||
`500px:tribeSets:${id}`,
|
||||
async () => {
|
||||
const { data } = await got(`${baseUrl}/community/tribe/getTribeSetsV2`, {
|
||||
headers: {
|
||||
...headers,
|
||||
},
|
||||
searchParams: {
|
||||
tribeId: id,
|
||||
privacy: 1,
|
||||
page: 1,
|
||||
size: limit,
|
||||
type: 'json',
|
||||
},
|
||||
});
|
||||
return data.data;
|
||||
},
|
||||
config.cache.routeExpire,
|
||||
false
|
||||
);
|
||||
|
||||
module.exports = {
|
||||
baseUrl,
|
||||
getUserInfoFromUsername,
|
||||
getUserInfoFromId,
|
||||
getUserWorks,
|
||||
getTribeDetail,
|
||||
getTribeSets,
|
||||
};
|
||||
Loading…
Reference in New Issue