Files
RSSHub/lib/routes/furaffinity/browse.js
T
Sukka d82847f541 style/chore(eslint): enforce new rules (#8040)
* style: prefer object shorthand syntax
* refactor: prefer Array#map over Array#forEach
* style: prefer arrow callback
* chore(eslint): update rules
* style: auto fix by eslint
2021-08-17 22:23:23 +08:00

45 lines
1.1 KiB
JavaScript

const got = require('@/utils/got');
module.exports = async (ctx) => {
// 传入参数
const nsfw = String(ctx.params.nsfw);
// 判断传入的参数nsfw
let url = 'https://faexport.spangle.org.uk/browse.json?sfw=1';
if (nsfw === '1') {
url = 'https://faexport.spangle.org.uk/browse.json';
}
// 发起 HTTP GET 请求
const response = await got({
method: 'get',
url,
headers: {
Referer: `https://faexport.spangle.org.uk/`,
},
});
const data = response.data;
ctx.state.data = {
// 源标题
title: `Fur Affinity Browse`,
// 源链接
link: `https://www.furaffinity.net/browse/`,
// 源说明
description: `Fur Affinity Browse`,
// 遍历此前获取的数据
item: data.map((item) => ({
// 标题
title: item.title,
// 正文
description: `<img src="${item.thumbnail}">`,
// 链接
link: item.link,
// 作者
author: item.name,
// 由于源API未提供日期,故无pubDate
})),
};
};