feat: hpoi

This commit is contained in:
DIYgod
2023-12-21 04:45:27 +08:00
parent fe6117a421
commit 2c9df1ede4
14 changed files with 206 additions and 95 deletions
-5
View File
@@ -775,11 +775,6 @@ router.get('/paidai/news', lazyloadRouteHandler('./routes/paidai/news'));
// 漫画db
router.get('/manhuadb/comics/:id', lazyloadRouteHandler('./routes/manhuadb/comics'));
// Hpoi 手办维基
router.get('/hpoi/info/:type?', lazyloadRouteHandler('./routes/hpoi/info'));
router.get('/hpoi/:category/:words', lazyloadRouteHandler('./routes/hpoi'));
router.get('/hpoi/user/:user_id/:caty', lazyloadRouteHandler('./routes/hpoi/user'));
// 通用CurseForge
router.get('/curseforge/:gameid/:catagoryid/:projectid/files', lazyloadRouteHandler('./routes/curseforge/generalfiles'));
-47
View File
@@ -1,47 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const host = 'https://www.hpoi.net';
const MAPs = {
charactar: {
url: `${host}/hobby/all?charactar={words}&order=release`,
title: '角色手办',
},
works: {
url: `${host}/hobby/all?works={words}&order=release`,
title: '作品手办',
},
};
module.exports = async (ctx) => {
const category = ctx.params && ctx.params.category;
const words = ctx.params && ctx.params.words;
const link = MAPs[category].url.replace(/{words}/, words);
const response = await got({
method: 'get',
url: link,
headers: {
Referer: host,
},
});
const $ = cheerio.load(response.data);
ctx.state.data = {
title: 'Hpoi 手办维基' + ' - ' + $(`#${category}`).text().trim(),
link,
item: $('.bs-glyphicons-list .detail-grid')
.map((_index, _item) => {
_item = $(_item);
return {
title: _item.find('.detail-grid-title').text(),
link: host + '/' + _item.find('.detail-grid-title a').attr('href'),
description: `<img src="${_item.find('.thumbnail img').attr('src')}">${_item.find('.detail-grid-info span').eq(0).text()}<br>${_item.find('.detail-grid-info span').eq(1).text()}<br>${_item
.find('.detail-grid-info span')
.eq(2)
.text()}`,
};
})
.get()
.reverse(),
};
};
-37
View File
@@ -1,37 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const root_url = 'https://www.hpoi.net';
module.exports = async (ctx) => {
const { user_id, caty } = ctx.params;
const url = `${root_url}/user/${user_id}/hobby?order=actionDate&favState=${caty}&view=5&category=100&sortType=2`;
const response = await got({
method: 'get',
url,
});
const $ = cheerio.load(response.data);
const list = $('#content > div.action-box div.action-detail')
.map((_, item) => {
item = $(item);
const img = item.find('div.list-5-left > a > img').attr('src');
const a = item.find('div.list-5-right > a.action-title');
return {
title: a.text(),
link: 'https://www.hpoi.net/' + a.attr('href'),
description: `<img src="${img}"><br>制作:${item.find('.badge').eq(0).text()}<br>发售:${item.find('.badge').eq(1).text()}`,
};
})
.get();
const title = $('div.col-md-15.col-sm-15 > div:nth-child(2)').text() + $('.navbar-nav .active').eq(0).text() + '的手办';
ctx.state.data = {
title,
link: url,
item: list,
allowEmpty: true,
};
};
+3
View File
@@ -0,0 +1,3 @@
const { ProcessFeed } = require('./utils');
module.exports = async (ctx) => (ctx.state.data = await ProcessFeed('all', 0, ctx.params.order));
+26
View File
@@ -0,0 +1,26 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const link = 'https://www.hpoi.net/bannerItem/list?categoryId=0&bannerItemType=0&subType=0&page=1';
const response = await got({
method: 'get',
url: link,
});
const $ = cheerio.load(response.data);
ctx.state.data = {
title: `Hpoi 手办维基 - 热门推荐`,
link,
item: $('#content .item')
.map((_index, _item) => {
_item = $(_item);
return {
title: _item.find('.title').text(),
link: 'https://www.hpoi.net/' + _item.find('a').attr('href'),
description: `<img src="${_item.find('img').attr('src')}">`,
pubDate: new Date(_item.find('.time').text().replace('发布时间:', '')).toUTCString(),
};
})
.get(),
};
};
+3
View File
@@ -0,0 +1,3 @@
const { ProcessFeed } = require('./utils');
module.exports = async (ctx) => (ctx.state.data = await ProcessFeed('character', ctx.params.id, ctx.params.order));
+8
View File
@@ -0,0 +1,8 @@
module.exports = {
'/info/:type?': ['sanmmm DIYgod'],
'/items/all/:order?': ['DIYgod'],
'/items/character/:id/:order?': ['DIYgod'],
'/items/work/:id/:order?': ['DIYgod'],
'/user/:user_id/:caty': ['DIYgod', 'luyuhuang'],
'/bannerItem': ['DIYgod'],
};
+37
View File
@@ -0,0 +1,37 @@
module.exports = {
'hpoi.net': {
_name: 'Hpoi手办维基',
www: [
{
title: '情报',
docs: 'https://docs.rsshub.app/routes/anime#hpoi-shou-ban-wei-ji',
source: ['/user/home'],
target: '/hpoi/info/all',
},
{
title: '所有周边',
docs: 'https://docs.rsshub.app/routes/anime#hpoi-shou-ban-wei-ji',
source: ['/hobby/all'],
target: '/hpoi/items/all',
},
{
title: '角色周边',
docs: 'https://docs.rsshub.app/routes/anime#hpoi-shou-ban-wei-ji',
},
{
title: '作品周边',
docs: 'https://docs.rsshub.app/routes/anime#hpoi-shou-ban-wei-ji',
},
{
title: '用户动态',
docs: 'https://docs.rsshub.app/routes/anime#hpoi-shou-ban-wei-ji',
},
{
title: '热门推荐',
docs: 'https://docs.rsshub.app/routes/anime#hpoi-shou-ban-wei-ji',
source: ['/bannerItem/list'],
target: '/hpoi/bannerItem',
},
],
},
};
+8
View File
@@ -0,0 +1,8 @@
module.exports = function (router) {
router.get('/info/:type?', require('./info'));
router.get('/items/all/:order?', require('./all'));
router.get('/items/character/:id/:order?', require('./character'));
router.get('/items/work/:id/:order?', require('./work'));
router.get('/user/:user_id/:caty', require('./user'));
router.get('/bannerItem', require('./bannerItem'));
};
+43
View File
@@ -0,0 +1,43 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const root_url = 'https://www.hpoi.net';
const titleMap = {
want: '想买',
preorder: '预定',
buy: '已入',
care: '关注',
resell: '有过',
};
module.exports = async (ctx) => {
const { user_id, caty } = ctx.params;
const url = `${root_url}/user/${user_id}/hobby?order=actionDate&view=2&favState=${caty}`;
const response = await got({
method: 'get',
url,
});
const $ = cheerio.load(response.data);
const list = $('.collect-hobby-list-small')
.map((_, item) => {
item = $(item);
return {
title: titleMap[caty] + ': ' + item.find('.name').text(),
link: 'https://www.hpoi.net/' + item.find('.name').attr('href'),
description: `<img src="${item.find('img').attr('src').replace('/s/', '/n/')}"><br>${item.find('.pay').text()}<br>${item.find('.score').text()}`,
};
})
.get();
const title = $('.hpoi-collect-head .info p').eq(0).text() + '的手办 - ' + titleMap[caty];
ctx.state.data = {
title,
link: url,
item: list,
allowEmpty: true,
};
};
+49
View File
@@ -0,0 +1,49 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const host = 'https://www.hpoi.net';
const MAPs = {
character: {
url: `${host}/hobby/all?order={order}&r18=-1&charactar={id}`,
title: '角色周边',
},
work: {
url: `${host}/hobby/all?order={order}&r18=-1&works={id}`,
title: '作品周边',
},
all: {
url: `${host}/hobby/all?order={order}&r18=-1`,
title: '全部周边',
},
};
const ProcessFeed = async (type, id, order) => {
const link = MAPs[type].url.replace(/{id}/, id).replace(/{order}/, order || 'add');
const response = await got({
method: 'get',
url: link,
headers: {
Referer: host,
},
});
const $ = cheerio.load(response.data);
return {
title: `Hpoi 手办维基 - ${MAPs[type].title}${id ? ` ${id}` : ''}`,
link,
item: $('.hpoi-glyphicons-list li')
.map((_index, _item) => {
_item = $(_item);
return {
title: _item.find('.hpoi-detail-grid-title a').text(),
link: host + '/' + _item.find('a').attr('href'),
description: `<img src="${_item.find('img').attr('src').replace('/s/', '/n/')}">${_item.find('.hpoi-detail-grid-info').html().replace(/span>/g, 'p>')}`,
};
})
.get(),
};
};
module.exports = {
ProcessFeed,
};
+3
View File
@@ -0,0 +1,3 @@
const { ProcessFeed } = require('./utils');
module.exports = async (ctx) => (ctx.state.data = await ProcessFeed('work', ctx.params.id, ctx.params.order));
+26 -6
View File
@@ -279,22 +279,42 @@
| all | hobby | model |
</Route>
### 浏览周边 {#hpoi-shou-ban-wei-ji-liu-lan-zhou-bian}
### 所有周边 {#hpoi-shou-ban-wei-ji-suo-you-zhou-bian}
<Route author="howel52 DIYgod" path="/hpoi/:category/:words" example="/hpoi/charactar/1246512" paramsDesc={['分类, 见下表', '角色/作品 ID']} notOperational="1">
| 角色手办 | 作品手办 |
| --------- | -------- |
| charactar | works |
<Route author="DIYgod" path="/hpoi/items/all/:order?" example="/hpoi/items/all" paramsDesc={['排序, 见下表,默认为 add']}>
| 发售 | 入库 | 总热度 | 一周热度 | 一天热度 | 评价 |
| ------- | ---- | ------ | -------- | -------- | ------ |
| release | add | hits | hits7Day | hitsDay | rating |
</Route>
### 角色周边 {#hpoi-shou-ban-wei-ji-jue-se-zhou-bian}
<Route author="DIYgod" path="/hpoi/items/character/:id/:order?" example="/hpoi/items/character/1035374" paramsDesc={['角色 ID', '排序, 见下表,默认为 add']}>
| 发售 | 入库 | 总热度 | 一周热度 | 一天热度 | 评价 |
| ------- | ---- | ------ | -------- | -------- | ------ |
| release | add | hits | hits7Day | hitsDay | rating |
</Route>
### 作品周边 {#hpoi-shou-ban-wei-ji-zuo-pin-zhou-bian}
<Route author="DIYgod" path="/hpoi/items/work/:id/:order?" example="/hpoi/items/work/4117491" paramsDesc={['作品 ID', '排序, 见下表,默认为 add']}>
| 发售 | 入库 | 总热度 | 一周热度 | 一天热度 | 评价 |
| ------- | ---- | ------ | -------- | -------- | ------ |
| release | add | hits | hits7Day | hitsDay | rating |
</Route>
### 用户动态 {#hpoi-shou-ban-wei-ji-yong-hu-dong-tai}
<Route author="luyuhuang DIYgod" path="/hpoi/user/:user_id/:caty" example="/hpoi/user/116297/buy" paramsDesc={['用户ID', '类别, 见下表']}>
<Route author="DIYgod luyuhuang" path="/hpoi/user/:user_id/:caty" example="/hpoi/user/116297/buy" paramsDesc={['用户ID', '类别, 见下表']}>
| 想买 | 预定 | 已入 | 关注 | 有过 |
| ---- | -------- | ---- | ---- | ------ |
| want | preorder | buy | care | resell |
</Route>
### 热门推荐 {#hpoi-shou-ban-wei-ji-re-men-tui-jian}
<Route author="DIYgod" path="/hpoi/bannerItem" example="/hpoi/bannerItem" />
## IDOLY PRIDE 偶像荣耀 {#idoly-pride-ou-xiang-rong-yao}
### News {#idoly-pride-ou-xiang-rong-yao-news}