mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 23:00:48 +08:00
feat: mastodon federated timeline; cw warn; media block fix (#5436)
This commit is contained in:
@@ -48,10 +48,14 @@ These feed do not include boosts (a.k.a. reblogs). RSSHub provides a feed for us
|
||||
|
||||
<RouteEn author="notofoe" example="/mastodon/acct/CatWhitney@mastodon.social/statuses" path="/mastodon/acct/:acct/statuses/:only_media?" :paramsDesc="['Webfinger account URI', 'whether only display media content, default to false, any value to true']"/>
|
||||
|
||||
### Timeline
|
||||
### Instance timeline (local)
|
||||
|
||||
<RouteEn author="hoilc" example="/mastodon/timeline/pawoo.net/true" path="/mastodon/timeline/:site/:only_media?" :paramsDesc="['instance address, only domain, no `http://` or `https://` protocol header', 'whether only display media content, default to false, any value to true']"/>
|
||||
|
||||
### Instance timeline (federated)
|
||||
|
||||
<RouteEn author="hoilc" example="/mastodon/remote/pawoo.net/true" path="/mastodon/remote/:site/:only_media?" :paramsDesc="['instance address, only domain, no `http://` or `https://` protocol header', 'whether only display media content, default to false, any value to true']"/>
|
||||
|
||||
### User timeline (backup)
|
||||
|
||||
<RouteEn author="notofoe" example="/mastodon/account_id/mastodon.social/23634/statuses/only_media" path="/mastodon/account/:site/:account_id/statuses/:only_media?" :paramsDesc="['instance address, only domain, no `http://` or `https://` protocol header', 'account id. login your instance, then search for the user profile; the account id is in the url', 'whether only display media content, default to false, any value to true']"/>
|
||||
|
||||
@@ -337,10 +337,14 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性
|
||||
|
||||
<Route author="notofoe" example="/mastodon/acct/CatWhitney@mastodon.social/statuses" path="/mastodon/acct/:acct/statuses/:only_media?" :paramsDesc="['Webfinger account URI, 形如 `user@host`', '是否只显示包含媒体(图片或视频)的推文, 默认置空为否, 任意值为是']"/>
|
||||
|
||||
### 实例公共时间线
|
||||
### 实例公共时间线(本站)
|
||||
|
||||
<Route author="hoilc" example="/mastodon/timeline/pawoo.net/true" path="/mastodon/timeline/:site/:only_media?" :paramsDesc="['实例地址, 仅域名, 不包括`http://`或`https://`协议头', '是否只显示包含媒体(图片或视频)的推文, 默认置空为否, 任意值为是']"/>
|
||||
|
||||
### 实例公共时间线(跨站)
|
||||
|
||||
<Route author="hoilc" example="/mastodon/remote/pawoo.net/true" path="/mastodon/remote/:site/:only_media?" :paramsDesc="['实例地址, 仅域名, 不包括`http://`或`https://`协议头', '是否只显示包含媒体(图片或视频)的推文, 默认置空为否, 任意值为是']"/>
|
||||
|
||||
### 用户公共时间线(备用)
|
||||
|
||||
<Route author="notofoe" example="/mastodon/account_id/mastodon.social/23634/statuses/only_media" path="/mastodon/account/:site/:account_id/statuses/:only_media?" :paramsDesc="['实例地址, 仅域名, 不包括`http://`或`https://`协议头', '用户 ID. 登录实例后, 搜索用户并进入用户页, 在地址中可以找到这串数字', '是否只显示包含媒体(图片或视频)的推文, 默认置空为否, 任意值为是']"/>
|
||||
|
||||
@@ -2297,7 +2297,8 @@ router.get('/ikea/uk/new', require('./routes/ikea/uk/new'));
|
||||
router.get('/ikea/uk/offer', require('./routes/ikea/uk/offer'));
|
||||
|
||||
// Mastodon
|
||||
router.get('/mastodon/timeline/:site/:only_media?', require('./routes/mastodon/timeline'));
|
||||
router.get('/mastodon/timeline/:site/:only_media?', require('./routes/mastodon/timeline_local'));
|
||||
router.get('/mastodon/remote/:site/:only_media?', require('./routes/mastodon/timeline_remote'));
|
||||
router.get('/mastodon/account_id/:site/:account_id/statuses/:only_media?', require('./routes/mastodon/account_id'));
|
||||
router.get('/mastodon/acct/:acct/statuses/:only_media?', require('./routes/mastodon/acct'));
|
||||
|
||||
|
||||
18
lib/routes/mastodon/timeline_remote.js
Normal file
18
lib/routes/mastodon/timeline_remote.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const got = require('@/utils/got');
|
||||
const utils = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const site = ctx.params.site;
|
||||
const only_media = ctx.params.only_media ? 'true' : 'false';
|
||||
|
||||
const url = `http://${site}/api/v1/timelines/public?remote=true&only_media=${only_media}`;
|
||||
|
||||
const response = await got.get(url);
|
||||
const list = response.data;
|
||||
|
||||
ctx.state.data = {
|
||||
title: `Federated Public${ctx.params.only_media ? ' Media' : ''} Timeline on ${site}`,
|
||||
link: `http://${site}`,
|
||||
item: utils.parseStatuses(list),
|
||||
};
|
||||
};
|
||||
@@ -10,13 +10,16 @@ const parseStatuses = (data) =>
|
||||
.map((item) => {
|
||||
switch (item.type) {
|
||||
case 'gifv':
|
||||
return `<br><video src="${item.url}" autoplay loop>GIF</video>`;
|
||||
return `<br><video src="${item.remote_url}" autoplay loop>GIF</video>`;
|
||||
case 'video':
|
||||
return `<br><video src="${item.url}" controls loop>Video</video>`;
|
||||
return `<br><video src="${item.remote_url}" controls loop>Video</video>`;
|
||||
case 'image':
|
||||
return `<br><img src="${item.url}">`;
|
||||
return `<br><img src="${item.remote_url}">`;
|
||||
case 'audio':
|
||||
return `<br><audio controls src="${item.remote_url}"/>`;
|
||||
case 'unknown':
|
||||
default:
|
||||
return '';
|
||||
return `<br><a href=${item.remote_url}>${item.remote_url}</a>`;
|
||||
}
|
||||
})
|
||||
.join('');
|
||||
@@ -33,7 +36,7 @@ const parseStatuses = (data) =>
|
||||
titleAuthor = `@${item.account.username}`;
|
||||
media = mediaParse(item.media_attachments);
|
||||
}
|
||||
const titleText = item.sentitive === true ? `(CW) ${item.spoiler_text}` : contentRemovedHtml;
|
||||
const titleText = item.sensitive === true ? `(CW) ${item.spoiler_text}` : contentRemovedHtml;
|
||||
|
||||
return {
|
||||
title: `${titleAuthor}: "${titleText}"`,
|
||||
|
||||
Reference in New Issue
Block a user