mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 22:19:40 +08:00
* feat(route): add nyaa and sukebei.nyaa user route new route: - `/nyaa/user/Tsundere-Raws` - `/nyaa/sukebei/user/Tarakara168` * fix(nyaa): add nyaa/sukebei.nyaa USER maintainer add user route infomation in nyaa/maintainer.js fix typo (change subekei to sukebei)
58 lines
1.8 KiB
JavaScript
58 lines
1.8 KiB
JavaScript
const config = require('@/config').value;
|
|
const Parser = require('rss-parser');
|
|
|
|
module.exports = async (ctx) => {
|
|
const parser = new Parser({
|
|
customFields: {
|
|
item: ['magnet', ['nyaa:infoHash', 'infoHash']],
|
|
},
|
|
headers: {
|
|
'User-Agent': config.ua,
|
|
},
|
|
});
|
|
|
|
let currentURL;
|
|
let currentLink;
|
|
|
|
if (ctx.routerPath.split('/')[1] === 'sukebei') {
|
|
const rootURL = 'https://sukebei.nyaa.si';
|
|
const { username = 'ohys' } = ctx.params;
|
|
const { query = '' } = ctx.params;
|
|
if (ctx.routerPath.split('/')[2] === 'user') {
|
|
currentURL = `${rootURL}/?page=rss&u=${username}`;
|
|
currentLink = `${rootURL}/user/${username}`;
|
|
} else {
|
|
currentURL = `${rootURL}/?page=rss&c=0_0&f=0&q=${encodeURI(query)}`;
|
|
currentLink = `${rootURL}/?f=0&c=0_0&q=${query}`;
|
|
}
|
|
} else {
|
|
const rootURL = 'https://nyaa.si';
|
|
const { username = 'Tarakara168' } = ctx.params;
|
|
const { query = '' } = ctx.params;
|
|
if (ctx.routerPath.split('/')[1] === 'user') {
|
|
currentURL = `${rootURL}/?page=rss&u=${username}`;
|
|
currentLink = `${rootURL}/user/${username}`;
|
|
} else {
|
|
currentURL = `${rootURL}/?page=rss&c=0_0&f=0&q=${encodeURI(query)}`;
|
|
currentLink = `${rootURL}/?f=0&c=0_0&q=${query}`;
|
|
}
|
|
}
|
|
|
|
const feed = await parser.parseURL(currentURL);
|
|
|
|
feed.items.map((item) => {
|
|
item.link = item.guid;
|
|
item.description = item.content;
|
|
item.enclosure_url = `magnet:?xt=urn:btih:${item.infoHash}`;
|
|
item.enclosure_type = 'application/x-bittorrent';
|
|
return item;
|
|
});
|
|
|
|
ctx.state.data = {
|
|
title: feed.title,
|
|
link: currentLink,
|
|
description: feed.description,
|
|
item: feed.items,
|
|
};
|
|
};
|