fix: support two formats of hopi worker id

This commit is contained in:
pseudoyu 2024-09-25 14:29:56 +08:00
parent f9e891b360
commit dddc5cc2fa
No known key found for this signature in database
1 changed files with 36 additions and 3 deletions

View File

@ -12,6 +12,10 @@ const MAPs = {
url: `${host}/hobby/all?order={order}&r18=-1&works={id}`,
title: '作品周边',
},
overview: {
url: `${host}/works/{id}`,
title: '周边总览',
},
all: {
url: `${host}/hobby/all?order={order}&r18=-1`,
title: '全部周边',
@ -19,15 +23,44 @@ const MAPs = {
};
const ProcessFeed = async (type, id, order) => {
const link = MAPs[type].url.replace(/{id}/, id).replace(/{order}/, order || 'add');
const response = await got({
let link = MAPs[type].url.replace(/{id}/, id).replace(/{order}/, order || 'add');
let response = await got({
method: 'get',
url: link,
headers: {
Referer: host,
},
});
const $ = load(response.data);
let $ = load(response.data);
if (type === 'work') {
const overviewLink = MAPs.overview.url.replace(/{id}/, id);
const overviewResponse = await got({
method: 'get',
url: overviewLink,
headers: {
Referer: host,
},
});
const $overview = load(overviewResponse.data);
const moreLink = $overview('.company-ibox a.hpoi-btn-border.hpoi-btn-more').attr('href');
if (moreLink) {
const worksId = moreLink.match(/modal\/taobao\/more\/(\d+)/)?.[1];
if (worksId) {
link = `${host}/hobby/all?order=${order || 'add'}&r18=-1&works=${worksId}`;
response = await got({
method: 'get',
url: link,
headers: {
Referer: host,
},
});
$ = load(response.data);
}
}
}
return {
title: `Hpoi 手办维基 - ${MAPs[type].title}${id ? ` ${id}` : ''}`,
link,