fix(route): Wallpaperhub (#9837)

* fix(route): Wallpaperhub

Signed-off-by: Jim Ma <majinjing3@gmail.com>

* refactor: migrate to v2
This commit is contained in:
Jim Ma
2022-05-27 20:20:22 +08:00
committed by GitHub
parent 5146d11295
commit 473c2f4ea0
9 changed files with 60 additions and 26 deletions
+6
View File
@@ -285,6 +285,12 @@ The text after `?` is `q=id%3A711&sorting=random&ref=fp&seed=8g0dgd` for [Wallpa
</RouteEn>
## WallpaperHub
### Wallpapers
<RouteEn author="nczitzk" example="/wallpaperhub" path="/wallpaperhub" radar="1" rssbud="1"/>
## yande.re
::: tip
+4 -2
View File
@@ -431,9 +431,11 @@ R18 显示
</Route>
## Wallpaperhub
## WallpaperHub
<Route author="nczitzk" example="/wallpaperhub" path="/wallpaperhub" />
### 壁纸
<Route author="nczitzk" example="/wallpaperhub" path="/wallpaperhub" radar="1" rssbud="1"/>
## yande.re
+2 -2
View File
@@ -3080,8 +3080,8 @@ router.get('/kotaku/story/:type', lazyloadRouteHandler('./routes/kotaku/story'))
// 梅斯医学
router.get('/medsci/recommend', lazyloadRouteHandler('./routes/medsci/recommend'));
// Wallpaperhub
router.get('/wallpaperhub', lazyloadRouteHandler('./routes/wallpaperhub/index'));
// Wallpaperhub migrated to v2
// router.get('/wallpaperhub', lazyloadRouteHandler('./routes/wallpaperhub/index'));
// 悟空问答
router.get('/wukong/user/:id/:type?', lazyloadRouteHandler('./routes/wukong/user'));
-22
View File
@@ -1,22 +0,0 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
const link = `https://wallpaperhub-fn.azurewebsites.net/api/wallpapers`;
const response = await got({
method: 'get',
url: link,
});
const list = response.data.wallpapers.slice(0, 20).map((item) => ({
title: item.title,
description: `<p>${item.description}</p><img src="${item.thumbnail}">`,
pubDate: new Date(item.publishedDate).toUTCString(),
link: `https://wallpaperhub.app/wallpapers/${item.id}`,
}));
ctx.state.data = {
title: `Wallpaperhub`,
link: 'https://wallpaperhub.app/wallpapers',
item: list,
};
};
+28
View File
@@ -0,0 +1,28 @@
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
const { art } = require('@/utils/render');
const path = require('path');
module.exports = async (ctx) => {
const link = 'https://wallpaperhub.app/api/v1/wallpapers/?limit=20&page=&query=&width=&height=&tags=';
const response = await got({
method: 'get',
url: link,
});
const list = response.data.entities.map((item) => ({
title: item.entity.title,
description: art(path.join(__dirname, 'templates/description.art'), {
description: item.entity.description,
img: item.entity.variations[0].resolutions[0].url || item.entity.thumbnail,
}),
pubDate: parseDate(item.entity.created),
link: `https://wallpaperhub.app/wallpapers/${item.entity.id}`,
}));
ctx.state.data = {
title: 'WallpaperHub',
link: 'https://wallpaperhub.app/wallpapers',
item: list,
};
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/': ['nczitzk'],
};
+13
View File
@@ -0,0 +1,13 @@
module.exports = {
'wallpaperhub.app': {
_name: 'WallpaperHub',
'.': [
{
title: '壁纸',
docs: 'https://docs.rsshub.app/picture.html#wallpaperhub',
source: ['/wallpaperhub', '/'],
target: '/wallpaperhub',
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/', require('./index'));
};
@@ -0,0 +1 @@
<p>{{ description }}</p><img src="{{ img }}">