feat(route/furaffinity): Add routes for furaffinity as a substitute for deprecated routes (#17314)

* feat(route): Init furaffinity namespace, add status route

* feat(route): Add browse, home, search, user routes for FA

* fix(route): fix wrong url in search route

* feat(route): Add gallery, scraps, favorites as art route for furaffinity

* style: fix example url of art route

* feat(route): Add watcher,watching route

* feat(route): Add shouts, journals, commissions route

* fix(route): Allow empty gallery and search result

* style: Follow eslint rules

* style: Fix UNUSED_VAR_ASSIGN

* Fixes issues based on review feedback

* Remove deprecated furaffinity routes

* Update lib/routes/furaffinity/commissions.ts

* Update lib/routes/furaffinity/namespace.ts

---------
This commit is contained in:
SkyNetX007
2024-11-12 01:53:21 +08:00
committed by GitHub
parent 60b3078482
commit 72d9c0ec91
28 changed files with 832 additions and 741 deletions
@@ -1,44 +0,0 @@
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
})),
};
};
@@ -1,39 +0,0 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
// 传入参数
const username = String(ctx.params.username);
// 发起 HTTP GET 请求
const response = await got({
method: 'get',
url: `https://faexport.spangle.org.uk/user/${username}/commissions.json`,
headers: {
Referer: `https://faexport.spangle.org.uk/`,
},
});
const data = response.data;
ctx.state.data = {
// 源标题
title: `${username}'s Commissions`,
// 源链接
link: `https://www.furaffinity.net/commissions/${username}/`,
// 源说明
description: `Fur Affinity ${username}'s Commissions`,
// 遍历此前获取的数据
item: data.map((item) => ({
// 标题
title: item.title,
// 正文
description: `${item.description} <br> <img src="${item.submission.thumbnail}"> `,
// 链接
link: item.submission.link,
// 作者
author: username,
// 由于源API未提供日期,故无pubDate
})),
};
};
@@ -1,56 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
// 传入参数
const nsfw = String(ctx.params.nsfw);
const username = String(ctx.params.username);
// 添加参数username以及判断传入的参数nsfw
let url = `https://faexport.spangle.org.uk/user/${username}/favorites.rss?sfw=1`;
if (nsfw === '1') {
url = `https://faexport.spangle.org.uk/user/${username}/favorites.rss`;
}
// 发起 HTTP GET 请求
const response = await got({
method: 'get',
url,
headers: {
Referer: `https://faexport.spangle.org.uk/`,
},
});
// 使用 cheerio 加载返回的 HTML
const data = response.data;
const $ = cheerio.load(data, {
xmlMode: true,
});
const list = $('item');
ctx.state.data = {
// 源标题
title: `${username}'s Favorites`,
// 源链接
link: `https://www.furaffinity.net/favorites/${username}/`,
// 源说明
description: `Fur Affinity ${username}'s Favorites`,
// 遍历此前获取的数据
item:
list &&
list
.map((index, item) => {
item = $(item);
return {
title: item.find('title').text(),
description: item.find('description').text(),
link: item.find('link').text(),
pubDate: new Date(item.find('pubDate').text()).toUTCString(),
};
})
.get(),
};
};
@@ -1,56 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
// 传入参数
const nsfw = String(ctx.params.nsfw);
const username = String(ctx.params.username);
// 添加参数username以及判断传入的参数nsfw
let url = `https://faexport.spangle.org.uk/user/${username}/gallery.rss?sfw=1`;
if (nsfw === '1') {
url = `https://faexport.spangle.org.uk/user/${username}/gallery.rss`;
}
// 发起 HTTP GET 请求
const response = await got({
method: 'get',
url,
headers: {
Referer: `https://faexport.spangle.org.uk/`,
},
});
// 使用 cheerio 加载返回的 HTML
const data = response.data;
const $ = cheerio.load(data, {
xmlMode: true,
});
const list = $('item');
ctx.state.data = {
// 源标题
title: `${username}'s Gallery`,
// 源链接
link: `https://www.furaffinity.net/gallery/${username}/`,
// 源说明
description: `Fur Affinity ${username}'s Gallery`,
// 遍历此前获取的数据
item:
list &&
list
.map((index, item) => {
item = $(item);
return {
title: item.find('title').text(),
description: item.find('description').text(),
link: item.find('link').text(),
pubDate: new Date(item.find('pubDate').text()).toUTCString(),
author: username,
};
})
.get(),
};
};
-72
View File
@@ -1,72 +0,0 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
// 传入参数
const type = String(ctx.params.type);
const nsfw = String(ctx.params.nsfw);
// 判断传入的参数nsfw
let url = 'https://faexport.spangle.org.uk/home.json?sfw=1';
if (nsfw === '1' || type === '1') {
url = 'https://faexport.spangle.org.uk/home.json';
}
// 发起 HTTP GET 请求
const response = await got({
method: 'get',
url,
headers: {
Referer: `https://faexport.spangle.org.uk/`,
},
});
let data = response.data;
// 判断传入的参数type,分别为:artwork、crafts、music、writing
switch (type) {
case 'artwork':
data = data.artwork;
break;
case 'crafts':
data = data.crafts;
break;
case 'music':
data = data.music;
break;
case 'writing':
data = data.writing;
break;
default:
data = data.artwork;
}
ctx.state.data = {
// 源标题
title: `Fur Affinity Home`,
// 源链接
link: `https://www.furaffinity.net/`,
// 源说明
description: `Fur Affinity Home`,
// 遍历此前获取的数据
item: data.map((item) => ({
// 标题
title: item.title,
// 正文
description: `<img src="${item.thumbnail}">`,
// 链接
link: item.link,
// 作者
author: item.name,
// 由于源API未提供日期,故无pubDate
})),
};
};
@@ -1,50 +0,0 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
// 传入参数
const id = String(ctx.params.id);
// 发起 HTTP GET 请求
const response = await got({
method: 'get',
url: `https://faexport.spangle.org.uk/journal/${id}/comments.json`,
headers: {
Referer: `https://faexport.spangle.org.uk/`,
},
});
// 发起第二个 HTTP GET 请求,用于获取该日记的标题
const response2 = await got({
method: 'get',
url: `https://faexport.spangle.org.uk/journal/${id}.json`,
headers: {
Referer: `https://faexport.spangle.org.uk/`,
},
});
const data = response.data;
const data2 = response2.data;
ctx.state.data = {
// 源标题
title: `${data2.title} - Journal Comments`,
// 源链接
link: `https://www.furaffinity.net/journal/${id}/`,
// 源说明
description: `Fur Affinity ${data2.title} - Journal Comments`,
// 遍历此前获取的数据
item: data.map((item) => ({
// 标题
title: item.text,
// 正文
description: `<img src="${item.avatar}"> <br> ${item.name}: ${item.text}`,
// 链接
link: `https://www.furaffinity.net/journal/${id}/`,
// 作者
author: item.name,
// 日期
pubDate: new Date(item.posted_at).toUTCString(),
})),
};
};
@@ -1,49 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
// 传入参数
const username = String(ctx.params.username);
// 添加参数username 和 发起 HTTP GET 请求
const response = await got({
method: 'get',
url: `https://faexport.spangle.org.uk/user/${username}/journals.rss`,
headers: {
Referer: `https://faexport.spangle.org.uk/`,
},
});
// 使用 cheerio 加载返回的 HTML
const data = response.data;
const $ = cheerio.load(data, {
xmlMode: true,
});
const list = $('item');
ctx.state.data = {
// 源标题
title: `${username}'s Journals`,
// 源链接
link: `https://www.furaffinity.net/journals/${username}/`,
// 源说明
description: `Fur Affinity ${username}'s Journals`,
// 遍历此前获取的数据
item:
list &&
list
.map((index, item) => {
item = $(item);
return {
title: item.find('title').text(),
description: item.find('description').text(),
link: item.find('link').text(),
pubDate: new Date(item.find('pubDate').text()).toUTCString(),
author: username,
};
})
.get(),
};
};
@@ -1,56 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
// 传入参数
const nsfw = String(ctx.params.nsfw);
const username = String(ctx.params.username);
// 添加参数username以及判断传入的参数nsfw
let url = `https://faexport.spangle.org.uk/user/${username}/scraps.rss?sfw=1`;
if (nsfw === '1') {
url = `https://faexport.spangle.org.uk/user/${username}/scraps.rss`;
}
// 发起 HTTP GET 请求
const response = await got({
method: 'get',
url,
headers: {
Referer: `https://faexport.spangle.org.uk/`,
},
});
// 使用 cheerio 加载返回的 HTML
const data = response.data;
const $ = cheerio.load(data, {
xmlMode: true,
});
const list = $('item');
ctx.state.data = {
// 源标题
title: `${username}'s Scraps`,
// 源链接
link: `https://www.furaffinity.net/scraps/${username}/`,
// 源说明
description: `Fur Affinity ${username}'s Scraps`,
// 遍历此前获取的数据
item:
list &&
list
.map((index, item) => {
item = $(item);
return {
title: item.find('title').text(),
description: item.find('description').text(),
link: item.find('link').text(),
pubDate: new Date(item.find('pubDate').text()).toUTCString(),
author: username,
};
})
.get(),
};
};
@@ -1,56 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
// 传入参数
const nsfw = String(ctx.params.nsfw);
const keyword = String(ctx.params.keyword);
// 添加参数keyword以及判断传入的参数nsfw
let url = `https://faexport.spangle.org.uk/search.rss?q=${keyword}&sfw=1`;
if (nsfw === '1') {
url = `https://faexport.spangle.org.uk/search.rss?q=${keyword}`;
}
// 发起 HTTP GET 请求
const response = await got({
method: 'get',
url,
headers: {
Referer: `https://faexport.spangle.org.uk/`,
},
});
// 使用 cheerio 加载返回的 HTML
const data = response.data;
const $ = cheerio.load(data, {
xmlMode: true,
});
const list = $('item');
ctx.state.data = {
// 源标题
title: `FA Search for ${keyword}`,
// 源链接
link: `https://www.furaffinity.net/search/?q=${keyword}`,
// 源说明
description: `Fur Affinity Search for ${keyword}`,
// 遍历此前获取的数据
item:
list &&
list
.map((index, item) => {
item = $(item);
return {
title: item.find('title').text(),
description: item.find('description').text(),
link: item.find('link').text(),
pubDate: new Date(item.find('pubDate').text()).toUTCString(),
// 由于源API未提供作者信息,故无author
};
})
.get(),
};
};
@@ -1,40 +0,0 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
// 传入参数
const username = String(ctx.params.username);
// 发起 HTTP GET 请求
const response = await got({
method: 'get',
url: `https://faexport.spangle.org.uk/user/${username}/shouts.json`,
headers: {
Referer: `https://faexport.spangle.org.uk/`,
},
});
const data = response.data;
ctx.state.data = {
// 源标题
title: `${username}'s Shouts`,
// 源链接
link: `https://www.furaffinity.net/user/${username}/`,
// 源说明
description: `Fur Affinity ${username}'s Shouts`,
// 遍历此前获取的数据
item: data.map((item) => ({
// 标题
title: item.text,
// 正文
description: `<img src="${item.avatar}"> <br> ${item.name}: ${item.text} `,
// 链接
link: `https://www.furaffinity.net/user/${username}/`,
// 作者
author: item.name,
// 日期
pubDate: new Date(item.posted_at).toUTCString(),
})),
};
};
@@ -1,38 +0,0 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
// 发起 HTTP GET 请求
const response = await got({
method: 'get',
url: `https://faexport.spangle.org.uk/status.json`,
headers: {
Referer: `https://faexport.spangle.org.uk/`,
},
});
const data = response.data;
const status = data.online;
let description = '';
description =
Object.keys(data)[0] === 'online'
? `Status: ${Object.keys(data)[0]} <br> Guests: ${status.guests} <br>Registered: ${status.registered} <br> Other: ${status.other} <br>Total: ${status.total} <br> Fa Server Time: ${data.fa_server_time}`
: 'offline';
const item = [];
item.push({
title: `Status:${Object.keys(data)[0]}`,
description,
link: `https://www.furaffinity.net/`,
});
ctx.state.data = {
// 源标题
title: `Fur Affinity Status`,
// 源链接
link: `https://www.furaffinity.net/`,
// 源说明
description: `Fur Affinity Status`,
item,
};
};
@@ -1,50 +0,0 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
// 传入参数
const id = String(ctx.params.id);
// 发起 HTTP GET 请求
const response = await got({
method: 'get',
url: `https://faexport.spangle.org.uk/submission/${id}/comments.json`,
headers: {
Referer: `https://faexport.spangle.org.uk/`,
},
});
// 发起第二个 HTTP GET 请求,用于获取该作品的标题
const response2 = await got({
method: 'get',
url: `https://faexport.spangle.org.uk/submission/${id}.json`,
headers: {
Referer: `https://faexport.spangle.org.uk/`,
},
});
const data = response.data;
const data2 = response2.data;
ctx.state.data = {
// 源标题
title: `${data2.title} - Submission Comments`,
// 源链接
link: `https://www.furaffinity.net/view/${id}/`,
// 源说明
description: `Fur Affinity ${data2.title} - Submission Comments`,
// 遍历此前获取的数据
item: data.map((item) => ({
// 标题
title: item.text,
// 正文
description: `<img src="${item.avatar}"> <br> ${item.name}: ${item.text}`,
// 链接
link: `https://www.furaffinity.net/view/${id}/`,
// 作者
author: item.name,
// 日期
pubDate: new Date(item.posted_at).toUTCString(),
})),
};
};
@@ -1,47 +0,0 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
// 传入参数
const username = String(ctx.params.username);
// 添加参数username 和 发起 HTTP GET 请求
const response = await got({
method: 'get',
url: `https://faexport.spangle.org.uk/user/${username}/watchers.json`,
headers: {
Referer: `https://faexport.spangle.org.uk/`,
},
});
// 发起第二个HTTP GET请求,用于获取该用户被关注总数
const response2 = await got({
method: 'get',
url: `https://faexport.spangle.org.uk/user/${username}.json`,
headers: {
Referer: `https://faexport.spangle.org.uk/`,
},
});
const data = response.data;
const data2 = response2.data;
ctx.state.data = {
// 源标题
title: `${username}'s Watcher List`,
// 源链接
link: `https://www.furaffinity.net/watchlist/to/${username}/`,
// 源说明
description: `Fur Affinity ${username}'s Watcher List`,
// 遍历此前获取的数据
item: data.map((item) => ({
// 标题
title: item,
// 正文
description: `${username} was watched by ${item} <br> Totall: ${data2.watchers.count} `,
// 链接
link: `https://www.furaffinity.net/user/${item}/`,
// 由于源API未提供日期,故无pubDate
})),
};
};
@@ -1,47 +0,0 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
// 传入参数
const username = String(ctx.params.username);
// 添加参数username 和 发起 HTTP GET 请求
const response = await got({
method: 'get',
url: `https://faexport.spangle.org.uk/user/${username}/watching.json`,
headers: {
Referer: `https://faexport.spangle.org.uk/`,
},
});
// 发起第二个HTTP GET请求,用于获取该用户关注总数
const response2 = await got({
method: 'get',
url: `https://faexport.spangle.org.uk/user/${username}.json`,
headers: {
Referer: `https://faexport.spangle.org.uk/`,
},
});
const data = response.data;
const data2 = response2.data;
ctx.state.data = {
// 源标题
title: `${username}'s Watching List`,
// 源链接
link: `https://www.furaffinity.net/watchlist/by/${username}/`,
// 源说明
description: `Fur Affinity ${username}}'s Search List`,
// 遍历此前获取的数据
item: data.map((item) => ({
// 标题
title: item,
// 正文
description: `${username} watched ${item} <br> Totall: ${data2.watching.count}`,
// 链接
link: `https://www.furaffinity.net/user/${item}/`,
// 由于源API未提供日期,故无pubDate
})),
};
};
+85
View File
@@ -0,0 +1,85 @@
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
export const route: Route = {
path: '/art/:folder/:username/:mode?',
name: 'Gallery',
url: 'furaffinity.net',
categories: ['social-media'],
example: '/furaffinity/art/gallery/fender/nsfw',
maintainers: ['TigerCubDen', 'SkyNetX007'],
parameters: {
username: 'Username, can find in userpage',
folder: 'Image folders, options are gallery, scraps, favorites',
mode: 'R18 content toggle, default value is sfw, options are sfw, nsfw',
},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['furaffinity.net/gallery/:username'],
target: '/gallery/:username',
},
{
source: ['furaffinity.net/scraps/:username'],
target: '/scraps/:username',
},
{
source: ['furaffinity.net/favorites/:username'],
target: '/favorites/:username',
},
],
handler,
};
async function handler(ctx) {
const { username, folder = 'gallery', mode = 'sfw' } = ctx.req.param();
let url = `https://faexport.spangle.org.uk/user/${username}/${folder}.json?sfw=1&full=1`;
if (mode === 'nsfw') {
url = `https://faexport.spangle.org.uk/user/${username}/${folder}.json?full=1`;
}
const data = await ofetch(url, {
method: 'GET',
headers: {
Referer: 'https://faexport.spangle.org.uk/',
},
});
let folderName;
switch (folder) {
case 'gallery':
folderName = 'Gallery';
break;
case 'scraps':
folderName = 'Scraps';
break;
case 'favorites':
folderName = 'Favorites';
break;
default:
folderName = 'Gallery';
}
const items = data.map((item) => ({
title: item.title,
link: item.link,
guid: item.id,
description: `<img src="${item.thumbnail}">`,
// 由于源API未提供日期,故无pubDate
author: item.name,
}));
return {
allowEmpty: true,
title: `Fur Affinity | ${folderName} of ${username}`,
link: `https://www.furaffinity.net/${folder}/${username}`,
description: `Fur Affinity ${folderName} of ${username}`,
item: items,
};
}
+58
View File
@@ -0,0 +1,58 @@
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
export const route: Route = {
path: '/browse/:mode?',
name: 'Browse',
url: 'furaffinity.net',
categories: ['social-media'],
example: '/furaffinity/browse/nsfw',
maintainers: ['TigerCubDen', 'SkyNetX007'],
parameters: { mode: 'R18 content toggle, default value is sfw, options are sfw, nsfw' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['furaffinity.net'],
target: '/browse',
},
],
handler,
};
async function handler(ctx) {
const { mode = 'sfw' } = ctx.req.param();
let url = 'https://faexport.spangle.org.uk/browse.json?sfw=1';
if (mode === 'nsfw') {
url = 'https://faexport.spangle.org.uk/browse.json';
}
const data = await ofetch(url, {
method: 'GET',
headers: {
Referer: 'https://faexport.spangle.org.uk/',
},
});
const items = data.map((item) => ({
title: item.title,
link: item.link,
guid: item.id,
description: `<img src="${item.thumbnail}">`,
// 由于源API未提供日期,故无pubDate
author: item.name,
}));
return {
title: 'Fur Affinity | Browse',
link: 'https://www.furaffinity.net/browse/',
description: `Fur Affinity Browsing Artwork`,
item: items,
};
}
+55
View File
@@ -0,0 +1,55 @@
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
export const route: Route = {
path: '/commissions/:username',
name: 'Commissions',
url: 'furaffinity.net',
categories: ['social-media'],
example: '/furaffinity/commissions/fender',
maintainers: ['TigerCubDen', 'SkyNetX007'],
parameters: { username: 'Username, can find in userpage' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['furaffinity.net/commissions/:username'],
target: '/commissions/:username',
},
],
handler,
};
async function handler(ctx) {
const { username } = ctx.req.param();
const url = `https://faexport.spangle.org.uk/user/${username}/commissions.json?full=1`;
const data = await ofetch(url, {
method: 'GET',
headers: {
Referer: 'https://faexport.spangle.org.uk/',
},
});
const items = data.map((item) => ({
title: item.title,
link: item.submission.link,
guid: item.submission.id,
description: `${item.description} <br> <img src="${item.submission.thumbnail}">`,
author: username,
}));
return {
allowEmpty: true,
title: `Fur Affinity | ${username}'s Commissions`,
link: `https://www.furaffinity.net/commissions/${username}`,
description: `Fur Affinity ${username}'s Commissions`,
item: items,
};
}
+80
View File
@@ -0,0 +1,80 @@
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
export const route: Route = {
path: '/home/:category/:mode?',
name: 'Home',
url: 'furaffinity.net',
categories: ['social-media'],
example: '/furaffinity/home/nsfw',
maintainers: ['TigerCubDen', 'SkyNetX007'],
parameters: {
category: 'Category, default value is artwork, options are artwork, writing, music, crafts',
mode: 'R18 content toggle, default value is sfw, options are sfw, nsfw',
},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['furaffinity.net'],
target: '/',
},
],
handler,
};
async function handler(ctx) {
const { category = 'artwork', mode = 'sfw' } = ctx.req.param();
let url = 'https://faexport.spangle.org.uk/home.json?sfw=1';
if (mode === 'nsfw') {
url = 'https://faexport.spangle.org.uk/home.json';
}
const data = await ofetch(url, {
method: 'GET',
headers: {
Referer: 'https://faexport.spangle.org.uk/',
},
});
let dataSelect;
switch (category) {
case 'artwork':
dataSelect = data.artwork;
break;
case 'writing':
dataSelect = data.writing;
break;
case 'music':
dataSelect = data.music;
break;
case 'crafts':
dataSelect = data.crafts;
break;
default:
dataSelect = data.artwork;
}
const items = dataSelect.map((item) => ({
title: item.title,
link: item.link,
guid: item.id,
description: `<img src="${item.thumbnail}">`,
// 由于源API未提供日期,故无pubDate
author: item.name,
}));
return {
title: 'Fur Affinity | Home',
link: 'https://www.furaffinity.net/',
description: `Fur Affinity Index`,
item: items,
};
}
@@ -0,0 +1,64 @@
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
export const route: Route = {
path: '/journal-comments/:id',
name: 'Journal Comments',
url: 'furaffinity.net',
categories: ['social-media'],
example: '/furaffinity/journal-comments/10925112',
maintainers: ['TigerCubDen', 'SkyNetX007'],
parameters: { id: 'Journal ID' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['furaffinity.net/journal/:id'],
target: '/journal-comments/:id',
},
],
handler,
};
async function handler(ctx) {
const { id } = ctx.req.param();
const urlJournal = `https://faexport.spangle.org.uk/journal/${id}.json`;
const urlComments = `https://faexport.spangle.org.uk/journal/${id}/comments.json`;
const dataJournal = await ofetch(urlJournal, {
method: 'GET',
headers: {
Referer: 'https://faexport.spangle.org.uk/',
},
});
const dataComments = await ofetch(urlComments, {
method: 'GET',
headers: {
Referer: 'https://faexport.spangle.org.uk/',
},
});
const items = dataComments.map((item) => ({
title: item.text,
link: `https://www.furaffinity.net/journal/${id}`,
guid: item.id,
description: `<img src="${item.avatar}"> <br> ${item.name}: ${item.text}`,
pubDate: new Date(item.posted_at).toUTCString(),
author: item.name,
}));
return {
allowEmpty: true,
title: `${dataJournal.title} - ${dataJournal.name} | Journal Comments`,
link: `https://www.furaffinity.net/journal/${id}`,
description: `Fur Affinity | ${dataJournal.title} by ${dataJournal.name} - Journal Comments`,
item: items,
};
}
+56
View File
@@ -0,0 +1,56 @@
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
export const route: Route = {
path: '/journals/:username',
name: 'Journals',
url: 'furaffinity.net',
categories: ['social-media'],
example: '/furaffinity/journals/fender',
maintainers: ['TigerCubDen', 'SkyNetX007'],
parameters: { username: 'Username, can find in userpage' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['furaffinity.net/journals/:username'],
target: '/journals/:username',
},
],
handler,
};
async function handler(ctx) {
const { username } = ctx.req.param();
const url = `https://faexport.spangle.org.uk/user/${username}/journals.json?full=1`;
const data = await ofetch(url, {
method: 'GET',
headers: {
Referer: 'https://faexport.spangle.org.uk/',
},
});
const items = data.map((item) => ({
title: item.title,
link: item.link,
guid: item.id,
description: item.description,
pubDate: new Date(item.posted_at).toUTCString(),
author: username,
}));
return {
allowEmpty: true,
title: `Fur Affinity | ${username}'s Journals`,
link: `https://www.furaffinity.net/journals/${username}`,
description: `Fur Affinity ${username}'s Journals`,
item: items,
};
}
+7
View File
@@ -0,0 +1,7 @@
import type { Namespace } from '@/types';
export const namespace: Namespace = {
name: 'Furaffinity',
url: 'furaffinity.net',
lang: 'en',
};
+72
View File
@@ -0,0 +1,72 @@
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
export const route: Route = {
path: '/search/:query/:mode?/:routeParams?',
name: 'Search',
url: 'furaffinity.net',
categories: ['social-media'],
example: '/furaffinity/search/protogen/nsfw',
maintainers: ['TigerCubDen', 'SkyNetX007'],
parameters: {
query: 'Query value',
mode: 'R18 content toggle, default value is sfw, options are sfw, nsfw',
routeParams: 'Additional search parameters',
},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['furaffinity.net'],
target: '/search',
},
],
handler,
description: `Additional search parameters
| Parameter | Description | Default | Options |
|-----------------|----------------------|-----------|----------------------------------------------------------------|
| order_by | Sort by | relevancy | relevancy, date, popularity |
| order_direction | Sort order | desc | desc, asc |
| range | Date range | all | all, 1day, 3days, 7days, 30days, 90days, 1year, 3years, 5years |
| pattern | Query match pattern | extended | all, any, extended |
| type | Category of artworks | all | art, flash, photo, music, story, poetry |
`,
};
async function handler(ctx) {
const { query, mode = 'sfw', routeParams = 'order_by=relevancy' } = ctx.req.param();
let url = `https://faexport.spangle.org.uk/search.json?sfw=1&full=1&q=${query}&${routeParams}`;
if (mode === 'nsfw') {
url = `https://faexport.spangle.org.uk/search.json?full=1&q=${query}&${routeParams}`;
}
const data = await ofetch(url, {
method: 'GET',
headers: {
Referer: 'https://faexport.spangle.org.uk/',
},
});
const items = data.map((item) => ({
title: item.title,
link: item.link,
guid: item.id,
description: `<img src="${item.thumbnail}">`,
// 由于源API未提供日期,故无pubDate
author: item.name,
}));
return {
allowEmpty: true,
title: 'Fur Affinity | Search',
link: `https://www.furaffinity.net/Search/?q=${query}`,
description: `Fur Affinity Search`,
item: items,
};
}
+56
View File
@@ -0,0 +1,56 @@
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
export const route: Route = {
path: '/shouts/:username',
name: 'Shouts',
url: 'furaffinity.net',
categories: ['social-media'],
example: '/furaffinity/shouts/fender',
maintainers: ['TigerCubDen', 'SkyNetX007'],
parameters: { username: 'Username, can find in userpage' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['furaffinity.net/user/:username'],
target: '/shouts/:username',
},
],
handler,
};
async function handler(ctx) {
const { username } = ctx.req.param();
const url = `https://faexport.spangle.org.uk/user/${username}/shouts.json?full=1`;
const data = await ofetch(url, {
method: 'GET',
headers: {
Referer: 'https://faexport.spangle.org.uk/',
},
});
const items = data.map((item) => ({
title: `${item.name} shout at ${username}`,
link: `https://www.furaffinity.net/user/${username}`,
guid: item.id,
description: `<img src="${item.avatar}"> <br> ${item.name}: ${item.text}`,
pubDate: new Date(item.posted_at).toUTCString(),
author: username,
}));
return {
allowEmpty: true,
title: `Fur Affinity | ${username}'s Shouts`,
link: `https://www.furaffinity.net/user/${username}`,
description: `Fur Affinity ${username}'s Shouts`,
item: items,
};
}
+58
View File
@@ -0,0 +1,58 @@
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
export const route: Route = {
path: '/status',
name: 'Status',
url: 'furaffinity.net',
categories: ['social-media'],
example: '/furaffinity/status',
maintainers: ['TigerCubDen', 'SkyNetX007'],
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['furaffinity.net'],
target: '/',
},
],
handler,
};
async function handler() {
const url = 'https://faexport.spangle.org.uk/status.json';
const data = await ofetch(url, {
method: 'GET',
headers: {
Referer: 'https://faexport.spangle.org.uk/',
},
});
const description =
Object.keys(data)[0] === 'online'
? `Status: FA Server Online <br> Guests: ${data.online.guests} <br> Registered: ${data.online.registered} <br> Other: ${data.online.other} <br> Total: ${data.online.total} <br> FA Server Time: ${data.fa_server_time} <br> FA Server Time at: ${data.fa_server_time_at}`
: 'FA Server Offline';
const items: { title: string; link: string; description: string }[] = [
{
title: `Status: ${Object.keys(data)[0]}`,
link: 'https://www.furaffinity.net/',
description,
},
];
return {
title: 'Fur Affinity | Status',
link: 'https://www.furaffinity.net/',
description: `Fur Affinity Status`,
item: items,
};
}
@@ -0,0 +1,64 @@
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
export const route: Route = {
path: '/submission-comments/:id',
name: 'Submission Comments',
url: 'furaffinity.net',
categories: ['social-media'],
example: '/furaffinity/submission-comments/24259751',
maintainers: ['TigerCubDen', 'SkyNetX007'],
parameters: { id: 'Submission ID' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['furaffinity.net/view/:id'],
target: '/submission-comments/:id',
},
],
handler,
};
async function handler(ctx) {
const { id } = ctx.req.param();
const urlSubmission = `https://faexport.spangle.org.uk/submission/${id}.json`;
const urlComments = `https://faexport.spangle.org.uk/submission/${id}/comments.json`;
const dataSubmission = await ofetch(urlSubmission, {
method: 'GET',
headers: {
Referer: 'https://faexport.spangle.org.uk/',
},
});
const dataComments = await ofetch(urlComments, {
method: 'GET',
headers: {
Referer: 'https://faexport.spangle.org.uk/',
},
});
const items = dataComments.map((item) => ({
title: item.text,
link: `https://www.furaffinity.net/view/${id}`,
guid: item.id,
description: `<img src="${item.avatar}"> <br> ${item.name}: ${item.text}`,
pubDate: new Date(item.posted_at).toUTCString(),
author: item.name,
}));
return {
allowEmpty: true,
title: `${dataSubmission.title} - ${dataSubmission.name} | Submission Comments`,
link: `https://www.furaffinity.net/view/${id}`,
description: `Fur Affinity | ${dataSubmission.title} by ${dataSubmission.name} - Submission Comments`,
item: items,
};
}
@@ -1,20 +1,42 @@
const got = require('@/utils/got');
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
module.exports = async (ctx) => {
// 传入参数
const username = String(ctx.params.username);
export const route: Route = {
path: '/user/:username',
name: 'Userpage',
url: 'furaffinity.net',
categories: ['social-media'],
example: '/furaffinity/user/fender/nsfw',
maintainers: ['TigerCubDen', 'SkyNetX007'],
parameters: { username: 'Username, can find in userpage' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['furaffinity.net/user/:username'],
target: '/user/:username',
},
],
handler,
};
// 添加参数username 和 发起 HTTP GET 请求
const response = await got({
method: 'get',
url: `https://faexport.spangle.org.uk/user/${username}.json`,
async function handler(ctx) {
const { username } = ctx.req.param();
const url = `https://faexport.spangle.org.uk/user/${username}.json`;
const data = await ofetch(url, {
method: 'GET',
headers: {
Referer: `https://faexport.spangle.org.uk/`,
Referer: 'https://faexport.spangle.org.uk/',
},
});
const data = response.data;
// 收集传入的数据
const name = data.name;
const profile = data.profile;
@@ -49,37 +71,30 @@ module.exports = async (ctx) => {
const contact_information = data.contact_information;
let contact_result = 'none <br> <br> ';
// 对一个或多个用户联系方式进行遍历
if (contact_information) {
contact_result = '';
for (const element of contact_information) {
for (const j in element) {
switch (j) {
for (const x in element) {
switch (x) {
case 'title':
contact_result += `Title: ${element[j]} <br> `;
contact_result += `Title: ${element[x]} <br> `;
break;
case 'name':
contact_result += `Name: ${element[j]} <br> `;
contact_result += `Name: ${element[x]} <br> `;
break;
case 'link':
contact_result += `Link: ${element[j]} <br> `;
contact_result += `Link: ${element[x]} <br> `;
break;
default:
throw new Error(`Unknown type: ${j}`);
throw new Error(`Unknown type: ${x}`);
}
}
contact_result += `<br> `;
}
}
const description = `Name: ${name} <br> Profile: ${profile} <br> Account Type: ${account_type} <br>
const description = `Name: ${name} <br> Profile: ${profile} <br> Account Type: ${account_type} <br>
Avatar: ${avatar} <br> Full Name: ${full_name} <br> Artist Type: ${artist_type} <br> User Title: ${user_title} <br>
Registered Since: ${registered_since} <br> Current Mood: ${current_mood} <br> <br> Artist Profile: <br> ${artist_profile} <br> <br>
Pageviews: ${pageviews} <br> Submissions: ${submissions} <br> Comments_Received: ${comments_received} <br> Comments Given: ${comments_given} <br>
@@ -88,21 +103,18 @@ module.exports = async (ctx) => {
Favorite Animal: ${favorites_animal} <br> Favorite Website: ${favorites_website} <br> Favorite Food: ${favorites_food} <br> <br> Contact Information: <br> ${contact_result}
Watchers Count: ${watchers_count} <br> Watching Count: ${watching_count} `;
const item = [];
item.push({
title: `${data.name}'s Current Profile`,
description,
link: `https://www.furaffinity.net/user/${username}/`,
});
const items: { title: string; link: string; description: string }[] = [
{
title: `${data.name}'s User Profile`,
link: `https://www.furaffinity.net/user/${username}`,
description,
},
];
ctx.state.data = {
// 源标题
title: `Userpage of ${data.name}`,
// 源链接
link: `https://www.furaffinity.net/`,
// 源说明
description: `Fur Affinity Userpage Profile of ${data.name}`,
item,
return {
title: `Fur Affinity | Userpage of ${data.name}`,
link: `https://www.furaffinity.net/user/${username}`,
description: `Fur Affinity User Profile of ${data.name}`,
item: items,
};
};
}
+62
View File
@@ -0,0 +1,62 @@
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
export const route: Route = {
path: '/watchers/:username',
name: `User's Watcher List`,
url: 'furaffinity.net',
categories: ['social-media'],
example: '/furaffinity/watchers/fender',
maintainers: ['TigerCubDen', 'SkyNetX007'],
parameters: { username: 'Username, can find in userpage' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['furaffinity.net/watchlist/to/:username'],
target: '/watchers/:username',
},
],
handler,
};
async function handler(ctx) {
const { username } = ctx.req.param();
const url = `https://faexport.spangle.org.uk/user/${username}/watchers.json`;
const data = await ofetch(url, {
method: 'GET',
headers: {
Referer: 'https://faexport.spangle.org.uk/',
},
});
const urlUserInfo = `https://faexport.spangle.org.uk/user/${username}.json`;
const dataUserInfo = await ofetch(urlUserInfo, {
method: 'GET',
headers: {
Referer: 'https://faexport.spangle.org.uk/',
},
});
const watchersCount = dataUserInfo.watchers.count;
const items = data.map((item) => ({
title: item,
link: `https://www.furaffinity.net/user/${item}`,
guid: item,
description: `${username} was watched by ${item} <br> Total: ${watchersCount}`,
author: item,
}));
return {
title: `Fur Affinity | Watchers of ${username}`,
link: `https://www.furaffinity.net/watchlist/to/${username}/`,
description: `Fur Affinity Watchers of ${username}`,
item: items,
};
}
+62
View File
@@ -0,0 +1,62 @@
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
export const route: Route = {
path: '/watching/:username',
name: `User's Watching List`,
url: 'furaffinity.net',
categories: ['social-media'],
example: '/furaffinity/watching/fender',
maintainers: ['TigerCubDen', 'SkyNetX007'],
parameters: { username: 'Username, can find in userpage' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['furaffinity.net/watchlist/by/:username'],
target: '/watching/:username',
},
],
handler,
};
async function handler(ctx) {
const { username } = ctx.req.param();
const url = `https://faexport.spangle.org.uk/user/${username}/watching.json`;
const data = await ofetch(url, {
method: 'GET',
headers: {
Referer: 'https://faexport.spangle.org.uk/',
},
});
const urlUserInfo = `https://faexport.spangle.org.uk/user/${username}.json`;
const dataUserInfo = await ofetch(urlUserInfo, {
method: 'GET',
headers: {
Referer: 'https://faexport.spangle.org.uk/',
},
});
const watchingCount = dataUserInfo.watching.count;
const items = data.map((item) => ({
title: item,
link: `https://www.furaffinity.net/user/${item}`,
guid: item,
description: `${username} is watching ${item} <br> Total: ${watchingCount}`,
author: item,
}));
return {
title: `Fur Affinity | Users ${username} is watching`,
link: `https://www.furaffinity.net/watchlist/by/${username}/`,
description: `Fur Affinity Users ${username} is watching`,
item: items,
};
}