rss: add yande.re (#221)
This commit is contained in:
parent
af90cf7192
commit
f971f2b4b2
|
|
@ -124,6 +124,9 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
|
|||
* Konachan.com Anime Wallpapers
|
||||
* posts
|
||||
* Popular Recent Posts
|
||||
* yande.re
|
||||
* posts
|
||||
* Popular Recent Posts
|
||||
|
||||
## 鸣谢
|
||||
|
||||
|
|
|
|||
|
|
@ -949,3 +949,33 @@ key: 产品密钥
|
|||
* 过去一周:[https://rsshub.app/konachan/post/popular_recent/1w](https://rsshub.app/konachan/post/popular_recent/1w)
|
||||
* 过去一月:[https://rsshub.app/konachan/post/popular_recent/1m](https://rsshub.app/konachan/post/popular_recent/1m)
|
||||
* 过去一年:[https://rsshub.app/konachan/post/popular_recent/1y](https://rsshub.app/konachan/post/popular_recent?period=1y)
|
||||
|
||||
## yande.re
|
||||
|
||||
### Posts
|
||||
|
||||
路由:
|
||||
|
||||
* `/yande.re/post`
|
||||
* `/yande.re/post/:tags`
|
||||
|
||||
举例:
|
||||
|
||||
* [https://rsshub.app/yande.re/post](https://rsshub.app/yande.re/post)
|
||||
* [https://rsshub.app/yande.re/post/the_idolm%40ster](https://rsshub.app/yande.re/post/the_idolm%40ster)
|
||||
* [https://rsshub.app/yande.re/post/kantai_collection](https://rsshub.app/yande.re/post/kantai_collection)
|
||||
* [https://rsshub.app/yande.re/post/love_live%21](https://rsshub.app/yande.re/post/love_live%21)
|
||||
|
||||
### Popular Recent Posts
|
||||
|
||||
路由:
|
||||
|
||||
* `/yande.re/post/popular_recent` 默认过去 24 小时
|
||||
* `/yande.re/post/popular_recent/:period`
|
||||
|
||||
举例:
|
||||
|
||||
* 过去 24 小时:[https://rsshub.app/yande.re/post/popular_recent/1d](https://rsshub.app/yande.re/post/popular_recent/1d)
|
||||
* 过去一周:[https://rsshub.app/yande.re/post/popular_recent/1w](https://rsshub.app/yande.re/post/popular_recent/1w)
|
||||
* 过去一月:[https://rsshub.app/yande.re/post/popular_recent/1m](https://rsshub.app/yande.re/post/popular_recent/1m)
|
||||
* 过去一年:[https://rsshub.app/yande.re/post/popular_recent/1y](https://rsshub.app/yande.re/post/popular_recent?period=1y)
|
||||
|
|
|
|||
|
|
@ -249,4 +249,10 @@ router.get('/konachan/post/popular_recent', require('./routes/konachan/post_popu
|
|||
router.get('/konachan/post/:tags', require('./routes/konachan/post'));
|
||||
router.get('/konachan/post/popular_recent/:period', require('./routes/konachan/post_popular_recent'));
|
||||
|
||||
// yande.re
|
||||
router.get('/yande.re/post', require('./routes/yande.re/post'));
|
||||
router.get('/yande.re/post/popular_recent', require('./routes/yande.re/post_popular_recent'));
|
||||
router.get('/yande.re/post/:tags', require('./routes/yande.re/post'));
|
||||
router.get('/yande.re/post/popular_recent/:period', require('./routes/yande.re/post_popular_recent'));
|
||||
|
||||
module.exports = router;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
const axios = require('../../utils/axios');
|
||||
const config = require('../../config');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { tags = '' } = ctx.params;
|
||||
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: `https://yande.re/post.json?tags=${tags}`,
|
||||
headers: {
|
||||
'User-Agent': config.ua,
|
||||
},
|
||||
});
|
||||
|
||||
const posts = response.data;
|
||||
|
||||
let title = 'yande.re';
|
||||
if (tags) {
|
||||
title = decodeURIComponent(tags) + ' - ' + title;
|
||||
}
|
||||
|
||||
ctx.state.data = {
|
||||
title,
|
||||
link: 'https://yande.re/post',
|
||||
item: posts.map((post) => {
|
||||
const content = (url) => {
|
||||
let result = `<img src="${url}" />`;
|
||||
if (post.source) {
|
||||
result += `<a href="${post.source}">source</a>`;
|
||||
}
|
||||
if (post.parent_id) {
|
||||
result += `<a href="https://yande.re/post/show/${post.parent_id}">parent</a>`;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
const created_at = post.created_at * 1e3;
|
||||
|
||||
return {
|
||||
title: post.tags,
|
||||
id: `${ctx.path}#${post.id}`,
|
||||
guid: `${ctx.path}#${post.id}`,
|
||||
link: `https://yande.re/post/show/${post.id}`,
|
||||
author: post.author,
|
||||
published: new Date(created_at).toISOString(),
|
||||
pubDate: new Date(created_at).toUTCString(),
|
||||
description: content(post.sample_url),
|
||||
summary: content(post.sample_url),
|
||||
content: content(post.file_url),
|
||||
image: post.file_url,
|
||||
category: post.tags.split(/\s+/),
|
||||
};
|
||||
}),
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
const axios = require('../../utils/axios');
|
||||
const config = require('../../config');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { period = '1d' } = ctx.params;
|
||||
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: 'https://yande.re/post/popular_recent.json',
|
||||
headers: {
|
||||
'User-Agent': config.ua,
|
||||
},
|
||||
params: {
|
||||
period,
|
||||
},
|
||||
});
|
||||
|
||||
const posts = response.data;
|
||||
|
||||
const titles = {
|
||||
'1d': 'Exploring last 24 hours ',
|
||||
'1w': 'Exploring last week',
|
||||
'1m': 'Exploring last month',
|
||||
'1y': 'Exploring last year',
|
||||
};
|
||||
|
||||
const title = titles[period] || titles['1d'];
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${title} - yande.re`,
|
||||
link: 'https://yande.re/post/popular_recent',
|
||||
item: posts.map((post) => {
|
||||
const content = (url) => {
|
||||
let result = `<img src="${url}" />`;
|
||||
if (post.source) {
|
||||
result += `<a href="${post.source}">source</a>`;
|
||||
}
|
||||
if (post.parent_id) {
|
||||
result += `<a href="https://yande.re/post/show/${post.parent_id}">parent</a>`;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
const created_at = post.created_at * 1e3;
|
||||
|
||||
return {
|
||||
title: post.tags,
|
||||
id: `${ctx.path}#${post.id}`,
|
||||
guid: `${ctx.path}#${post.id}`,
|
||||
link: `https://yande.re/post/show/${post.id}`,
|
||||
author: post.author,
|
||||
published: new Date(created_at).toISOString(),
|
||||
pubDate: new Date(created_at).toUTCString(),
|
||||
description: content(post.sample_url),
|
||||
summary: content(post.sample_url),
|
||||
content: content(post.file_url),
|
||||
image: post.file_url,
|
||||
category: post.tags.split(/\s+/),
|
||||
};
|
||||
}),
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue