diff --git a/lib/routes-deprecated/furaffinity/browse.js b/lib/routes-deprecated/furaffinity/browse.js deleted file mode 100644 index 446498b8c..000000000 --- a/lib/routes-deprecated/furaffinity/browse.js +++ /dev/null @@ -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: ``, - // 链接 - link: item.link, - // 作者 - author: item.name, - // 由于源API未提供日期,故无pubDate - })), - }; -}; diff --git a/lib/routes-deprecated/furaffinity/commissions.js b/lib/routes-deprecated/furaffinity/commissions.js deleted file mode 100644 index c2a21eecc..000000000 --- a/lib/routes-deprecated/furaffinity/commissions.js +++ /dev/null @@ -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}
`, - // 链接 - link: item.submission.link, - // 作者 - author: username, - // 由于源API未提供日期,故无pubDate - })), - }; -}; diff --git a/lib/routes-deprecated/furaffinity/favorites.js b/lib/routes-deprecated/furaffinity/favorites.js deleted file mode 100644 index 0219886e5..000000000 --- a/lib/routes-deprecated/furaffinity/favorites.js +++ /dev/null @@ -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(), - }; -}; diff --git a/lib/routes-deprecated/furaffinity/gallery.js b/lib/routes-deprecated/furaffinity/gallery.js deleted file mode 100644 index 57cc86f2d..000000000 --- a/lib/routes-deprecated/furaffinity/gallery.js +++ /dev/null @@ -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(), - }; -}; diff --git a/lib/routes-deprecated/furaffinity/home.js b/lib/routes-deprecated/furaffinity/home.js deleted file mode 100644 index 86745240b..000000000 --- a/lib/routes-deprecated/furaffinity/home.js +++ /dev/null @@ -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: ``, - // 链接 - link: item.link, - // 作者 - author: item.name, - // 由于源API未提供日期,故无pubDate - })), - }; -}; diff --git a/lib/routes-deprecated/furaffinity/journal-comments.js b/lib/routes-deprecated/furaffinity/journal-comments.js deleted file mode 100644 index 3a86d239e..000000000 --- a/lib/routes-deprecated/furaffinity/journal-comments.js +++ /dev/null @@ -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: `
${item.name}: ${item.text}`, - // 链接 - link: `https://www.furaffinity.net/journal/${id}/`, - // 作者 - author: item.name, - // 日期 - pubDate: new Date(item.posted_at).toUTCString(), - })), - }; -}; diff --git a/lib/routes-deprecated/furaffinity/journals.js b/lib/routes-deprecated/furaffinity/journals.js deleted file mode 100644 index 74862de0f..000000000 --- a/lib/routes-deprecated/furaffinity/journals.js +++ /dev/null @@ -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(), - }; -}; diff --git a/lib/routes-deprecated/furaffinity/scraps.js b/lib/routes-deprecated/furaffinity/scraps.js deleted file mode 100644 index 0acb53fcd..000000000 --- a/lib/routes-deprecated/furaffinity/scraps.js +++ /dev/null @@ -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(), - }; -}; diff --git a/lib/routes-deprecated/furaffinity/search.js b/lib/routes-deprecated/furaffinity/search.js deleted file mode 100644 index 90066bd32..000000000 --- a/lib/routes-deprecated/furaffinity/search.js +++ /dev/null @@ -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(), - }; -}; diff --git a/lib/routes-deprecated/furaffinity/shouts.js b/lib/routes-deprecated/furaffinity/shouts.js deleted file mode 100644 index ca3685c02..000000000 --- a/lib/routes-deprecated/furaffinity/shouts.js +++ /dev/null @@ -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: `
${item.name}: ${item.text} `, - // 链接 - link: `https://www.furaffinity.net/user/${username}/`, - // 作者 - author: item.name, - // 日期 - pubDate: new Date(item.posted_at).toUTCString(), - })), - }; -}; diff --git a/lib/routes-deprecated/furaffinity/status.js b/lib/routes-deprecated/furaffinity/status.js deleted file mode 100644 index 6b0d772e2..000000000 --- a/lib/routes-deprecated/furaffinity/status.js +++ /dev/null @@ -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]}
Guests: ${status.guests}
Registered: ${status.registered}
Other: ${status.other}
Total: ${status.total}
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, - }; -}; diff --git a/lib/routes-deprecated/furaffinity/submission-comments.js b/lib/routes-deprecated/furaffinity/submission-comments.js deleted file mode 100644 index e08c5ba26..000000000 --- a/lib/routes-deprecated/furaffinity/submission-comments.js +++ /dev/null @@ -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: `
${item.name}: ${item.text}`, - // 链接 - link: `https://www.furaffinity.net/view/${id}/`, - // 作者 - author: item.name, - // 日期 - pubDate: new Date(item.posted_at).toUTCString(), - })), - }; -}; diff --git a/lib/routes-deprecated/furaffinity/watchers.js b/lib/routes-deprecated/furaffinity/watchers.js deleted file mode 100644 index a02a2befe..000000000 --- a/lib/routes-deprecated/furaffinity/watchers.js +++ /dev/null @@ -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}
Totall: ${data2.watchers.count} `, - // 链接 - link: `https://www.furaffinity.net/user/${item}/`, - // 由于源API未提供日期,故无pubDate - })), - }; -}; diff --git a/lib/routes-deprecated/furaffinity/watching.js b/lib/routes-deprecated/furaffinity/watching.js deleted file mode 100644 index 9532320b4..000000000 --- a/lib/routes-deprecated/furaffinity/watching.js +++ /dev/null @@ -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}
Totall: ${data2.watching.count}`, - // 链接 - link: `https://www.furaffinity.net/user/${item}/`, - // 由于源API未提供日期,故无pubDate - })), - }; -}; diff --git a/lib/routes/furaffinity/art.ts b/lib/routes/furaffinity/art.ts new file mode 100644 index 000000000..c160bdee7 --- /dev/null +++ b/lib/routes/furaffinity/art.ts @@ -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: ``, + // 由于源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, + }; +} diff --git a/lib/routes/furaffinity/browse.ts b/lib/routes/furaffinity/browse.ts new file mode 100644 index 000000000..eb423cbf4 --- /dev/null +++ b/lib/routes/furaffinity/browse.ts @@ -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: ``, + // 由于源API未提供日期,故无pubDate + author: item.name, + })); + + return { + title: 'Fur Affinity | Browse', + link: 'https://www.furaffinity.net/browse/', + description: `Fur Affinity Browsing Artwork`, + item: items, + }; +} diff --git a/lib/routes/furaffinity/commissions.ts b/lib/routes/furaffinity/commissions.ts new file mode 100644 index 000000000..740265da7 --- /dev/null +++ b/lib/routes/furaffinity/commissions.ts @@ -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}
`, + 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, + }; +} diff --git a/lib/routes/furaffinity/home.ts b/lib/routes/furaffinity/home.ts new file mode 100644 index 000000000..383b79e92 --- /dev/null +++ b/lib/routes/furaffinity/home.ts @@ -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: ``, + // 由于源API未提供日期,故无pubDate + author: item.name, + })); + + return { + title: 'Fur Affinity | Home', + link: 'https://www.furaffinity.net/', + description: `Fur Affinity Index`, + item: items, + }; +} diff --git a/lib/routes/furaffinity/journal-comments.ts b/lib/routes/furaffinity/journal-comments.ts new file mode 100644 index 000000000..19935b967 --- /dev/null +++ b/lib/routes/furaffinity/journal-comments.ts @@ -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: `
${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, + }; +} diff --git a/lib/routes/furaffinity/journals.ts b/lib/routes/furaffinity/journals.ts new file mode 100644 index 000000000..df13b8262 --- /dev/null +++ b/lib/routes/furaffinity/journals.ts @@ -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, + }; +} diff --git a/lib/routes/furaffinity/namespace.ts b/lib/routes/furaffinity/namespace.ts new file mode 100644 index 000000000..186165cb4 --- /dev/null +++ b/lib/routes/furaffinity/namespace.ts @@ -0,0 +1,7 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: 'Furaffinity', + url: 'furaffinity.net', + lang: 'en', +}; diff --git a/lib/routes/furaffinity/search.ts b/lib/routes/furaffinity/search.ts new file mode 100644 index 000000000..1f9d9eda2 --- /dev/null +++ b/lib/routes/furaffinity/search.ts @@ -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: ``, + // 由于源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, + }; +} diff --git a/lib/routes/furaffinity/shouts.ts b/lib/routes/furaffinity/shouts.ts new file mode 100644 index 000000000..94e5c071a --- /dev/null +++ b/lib/routes/furaffinity/shouts.ts @@ -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: `
${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, + }; +} diff --git a/lib/routes/furaffinity/status.ts b/lib/routes/furaffinity/status.ts new file mode 100644 index 000000000..5c4201558 --- /dev/null +++ b/lib/routes/furaffinity/status.ts @@ -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
Guests: ${data.online.guests}
Registered: ${data.online.registered}
Other: ${data.online.other}
Total: ${data.online.total}
FA Server Time: ${data.fa_server_time}
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, + }; +} diff --git a/lib/routes/furaffinity/submission-comments.ts b/lib/routes/furaffinity/submission-comments.ts new file mode 100644 index 000000000..7bb1009b0 --- /dev/null +++ b/lib/routes/furaffinity/submission-comments.ts @@ -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: `
${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, + }; +} diff --git a/lib/routes-deprecated/furaffinity/user.js b/lib/routes/furaffinity/user.ts similarity index 64% rename from lib/routes-deprecated/furaffinity/user.js rename to lib/routes/furaffinity/user.ts index 79ad79ecd..a2b47e116 100644 --- a/lib/routes-deprecated/furaffinity/user.js +++ b/lib/routes/furaffinity/user.ts @@ -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

'; - // 对一个或多个用户联系方式进行遍历 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]}
`; - + contact_result += `Title: ${element[x]}
`; break; - case 'name': - contact_result += `Name: ${element[j]}
`; - + contact_result += `Name: ${element[x]}
`; break; - case 'link': - contact_result += `Link: ${element[j]}
`; - + contact_result += `Link: ${element[x]}
`; break; - default: - throw new Error(`Unknown type: ${j}`); + throw new Error(`Unknown type: ${x}`); } } contact_result += `
`; } } - const description = `Name: ${name}
Profile: ${profile}
Account Type: ${account_type}
+ const description = `Name: ${name}
Profile: ${profile}
Account Type: ${account_type}
Avatar: ${avatar}
Full Name: ${full_name}
Artist Type: ${artist_type}
User Title: ${user_title}
Registered Since: ${registered_since}
Current Mood: ${current_mood}

Artist Profile:
${artist_profile}

Pageviews: ${pageviews}
Submissions: ${submissions}
Comments_Received: ${comments_received}
Comments Given: ${comments_given}
@@ -88,21 +103,18 @@ module.exports = async (ctx) => { Favorite Animal: ${favorites_animal}
Favorite Website: ${favorites_website}
Favorite Food: ${favorites_food}

Contact Information:
${contact_result} Watchers Count: ${watchers_count}
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, }; -}; +} diff --git a/lib/routes/furaffinity/watchers.ts b/lib/routes/furaffinity/watchers.ts new file mode 100644 index 000000000..b278ed608 --- /dev/null +++ b/lib/routes/furaffinity/watchers.ts @@ -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}
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, + }; +} diff --git a/lib/routes/furaffinity/watching.ts b/lib/routes/furaffinity/watching.ts new file mode 100644 index 000000000..394f62021 --- /dev/null +++ b/lib/routes/furaffinity/watching.ts @@ -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}
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, + }; +}