diff --git a/docs/en/picture.md b/docs/en/picture.md index ab164cdc9..cbeb535b1 100644 --- a/docs/en/picture.md +++ b/docs/en/picture.md @@ -285,6 +285,12 @@ The text after `?` is `q=id%3A711&sorting=random&ref=fp&seed=8g0dgd` for [Wallpa +## WallpaperHub + +### Wallpapers + + + ## yande.re ::: tip diff --git a/docs/picture.md b/docs/picture.md index 3f9cc6333..97ae0c7df 100644 --- a/docs/picture.md +++ b/docs/picture.md @@ -431,9 +431,11 @@ R18 显示 -## Wallpaperhub +## WallpaperHub - +### 壁纸 + + ## yande.re diff --git a/lib/router.js b/lib/router.js index ad712a0e2..7ac0c38db 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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')); diff --git a/lib/routes/wallpaperhub/index.js b/lib/routes/wallpaperhub/index.js deleted file mode 100644 index e4fac1b01..000000000 --- a/lib/routes/wallpaperhub/index.js +++ /dev/null @@ -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: `

${item.description}

`, - 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, - }; -}; diff --git a/lib/v2/wallpaperhub/index.js b/lib/v2/wallpaperhub/index.js new file mode 100644 index 000000000..ea46a597a --- /dev/null +++ b/lib/v2/wallpaperhub/index.js @@ -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, + }; +}; diff --git a/lib/v2/wallpaperhub/maintainer.js b/lib/v2/wallpaperhub/maintainer.js new file mode 100644 index 000000000..ca7cf1eb1 --- /dev/null +++ b/lib/v2/wallpaperhub/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/': ['nczitzk'], +}; diff --git a/lib/v2/wallpaperhub/radar.js b/lib/v2/wallpaperhub/radar.js new file mode 100644 index 000000000..25a35d8f6 --- /dev/null +++ b/lib/v2/wallpaperhub/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'wallpaperhub.app': { + _name: 'WallpaperHub', + '.': [ + { + title: '壁纸', + docs: 'https://docs.rsshub.app/picture.html#wallpaperhub', + source: ['/wallpaperhub', '/'], + target: '/wallpaperhub', + }, + ], + }, +}; diff --git a/lib/v2/wallpaperhub/router.js b/lib/v2/wallpaperhub/router.js new file mode 100644 index 000000000..7e427447c --- /dev/null +++ b/lib/v2/wallpaperhub/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/', require('./index')); +}; diff --git a/lib/v2/wallpaperhub/templates/description.art b/lib/v2/wallpaperhub/templates/description.art new file mode 100644 index 000000000..8afb4dab3 --- /dev/null +++ b/lib/v2/wallpaperhub/templates/description.art @@ -0,0 +1 @@ +

{{ description }}