Skip to content

Commit

Permalink
feat: hpoi
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Dec 20, 2023
1 parent fe6117a commit 2c9df1e
Show file tree
Hide file tree
Showing 14 changed files with 206 additions and 95 deletions.
5 changes: 0 additions & 5 deletions lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

Expand Down
47 changes: 0 additions & 47 deletions lib/routes/hpoi/index.js

This file was deleted.

37 changes: 0 additions & 37 deletions lib/routes/hpoi/user.js

This file was deleted.

3 changes: 3 additions & 0 deletions lib/v2/hpoi/all.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { ProcessFeed } = require('./utils');

module.exports = async (ctx) => (ctx.state.data = await ProcessFeed('all', 0, ctx.params.order));
26 changes: 26 additions & 0 deletions lib/v2/hpoi/bannerItem.js
Original file line number Diff line number Diff line change
@@ -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 changes: 3 additions & 0 deletions lib/v2/hpoi/character.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { ProcessFeed } = require('./utils');

module.exports = async (ctx) => (ctx.state.data = await ProcessFeed('character', ctx.params.id, ctx.params.order));
File renamed without changes.
8 changes: 8 additions & 0 deletions lib/v2/hpoi/maintainer.js
Original file line number Diff line number Diff line change
@@ -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 changes: 37 additions & 0 deletions lib/v2/hpoi/radar.js
Original file line number Diff line number Diff line change
@@ -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 changes: 8 additions & 0 deletions lib/v2/hpoi/router.js
Original file line number Diff line number Diff line change
@@ -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 changes: 43 additions & 0 deletions lib/v2/hpoi/user.js
Original file line number Diff line number Diff line change
@@ -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 changes: 49 additions & 0 deletions lib/v2/hpoi/utils.js
Original file line number Diff line number Diff line change
@@ -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 changes: 3 additions & 0 deletions lib/v2/hpoi/work.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { ProcessFeed } = require('./utils');

module.exports = async (ctx) => (ctx.state.data = await ProcessFeed('work', ctx.params.id, ctx.params.order));
32 changes: 26 additions & 6 deletions website/docs/routes/anime.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 2c9df1e

Please sign in to comment.