feat(route): gettr (#11937)
This commit is contained in:
@@ -138,6 +138,12 @@ Type
|
||||
|
||||
<RouteEn author="zphw" example="/gab/popular/hot" path="/gab/popular/:sort?" :paramsDesc="['Sort by, `hot` to be Hot Posts and `top` to be Top Posts. Default: hot']" />
|
||||
|
||||
## GETTR
|
||||
|
||||
### User timeline
|
||||
|
||||
<RouteEn author="TonyRL" example="/gettr/user/jasonmillerindc" path="/gettr/user/:id" :paramsDesc="['User id']" radar="1" rssbud="1"/>
|
||||
|
||||
## Instagram
|
||||
|
||||
::: warning
|
||||
|
||||
@@ -472,6 +472,12 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性
|
||||
|
||||
<Route author="zphw" example="/gab/popular/hot" path="/gab/popular/:sort?" :paramsDesc="['排序方式, `hot` 為 Hot Posts, `top` 為 Top Posts。默認為 hot']" />
|
||||
|
||||
## GETTR
|
||||
|
||||
### 个人时间线
|
||||
|
||||
<Route author="TonyRL" example="/gettr/user/jasonmillerindc" path="/gettr/user/:id" :paramsDesc="['用户 id']" radar="1" rssbud="1"/>
|
||||
|
||||
## iCity
|
||||
|
||||
### 用户动态
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/user/:id': ['TonyRL'],
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'gettr.com': {
|
||||
_name: 'GETTR',
|
||||
'.': [
|
||||
{
|
||||
title: '个人时间线',
|
||||
docs: 'https://docs.rsshub.app/social-media.html#gettr',
|
||||
source: ['/user/:id'],
|
||||
target: '/gettr/user/:id',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/user/:id', require('./user'));
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
{{ if post.txt }}{{@ post.txt.replace(/\n/g, '<br>') }}<br>{{ /if }}
|
||||
|
||||
{{ if post.previmg }}<img src="{{ post.previmg }}"><br>{{ /if }}
|
||||
|
||||
{{ if post.ttl && post.prevsrc }}<b><a href="{{ post.prevsrc }}">{{ post.ttl }}</a></b><br>{{ /if }}
|
||||
|
||||
{{ if post.dsc && post.prevsrc }}<a href="{{ post.prevsrc }}">{{ post.dsc }}</a><br>{{ /if }}
|
||||
|
||||
{{ if post.imgs }}
|
||||
{{ each post.imgs i }}
|
||||
<img src="{{ mediaHost }}/{{ i }}">
|
||||
{{ /each }}
|
||||
{{ /if }}
|
||||
@@ -0,0 +1,56 @@
|
||||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
|
||||
const actionMap = {
|
||||
pub_pst: 'Published a post: ',
|
||||
shares_cm: 'Shared a comment: ',
|
||||
shares_pst: 'Shared a post: ',
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const baseUrl = 'https://gettr.com';
|
||||
const apiHost = 'https://api.gettr.com';
|
||||
const mediaHost = 'https://media.gettr.com';
|
||||
const { id } = ctx.params;
|
||||
|
||||
const { data: posts } = await got(`${apiHost}/u/user/${id}/posts`, {
|
||||
// headers: {
|
||||
// version: '2.7.0',
|
||||
// 'x-app-auth': '{"user": null, "token": null}',
|
||||
// },
|
||||
searchParams: {
|
||||
offset: 0,
|
||||
max: 20,
|
||||
dir: 'fwd',
|
||||
incl: 'posts|stats|userinfo|shared|liked|pvotes',
|
||||
fp: 'f_uo',
|
||||
},
|
||||
});
|
||||
const userInfo = posts.result.aux.uinf[id];
|
||||
|
||||
const items = posts.result.data.list.map((post) => {
|
||||
const title = posts.result.aux.post[post.activity.pstid].txt;
|
||||
const description = art(path.join(__dirname, 'templates/post.art'), {
|
||||
post: posts.result.aux.post[post.activity.pstid],
|
||||
mediaHost,
|
||||
});
|
||||
return {
|
||||
title: `${actionMap[post.action]} ${title}`,
|
||||
description,
|
||||
pubDate: parseDate(post.cdate),
|
||||
updated: parseDate(post.udate),
|
||||
link: `${baseUrl}/post/${post.activity.pstid}`,
|
||||
};
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${userInfo.nickname} on Gettr`,
|
||||
description: userInfo.dsc,
|
||||
link: `${baseUrl}/user/${id}`,
|
||||
image: `${mediaHost}/${userInfo.ico}`,
|
||||
language: 'en',
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user