feat(comic-fuz.com): add new routes (#21193)

* comicfuz pr

* fix lint

* fix lint error

* ofetch support

* 1

* fix some question

* fix some question

* using TonyRL‘s suggetion version 1

* ver 2

* fix some question

* ver 3

* 非必要的修改 最后的版本

* fix: missing rename

* fix: remove duplicated name

---------
This commit is contained in:
YuruShiMaShiMaRin 2026-02-23 09:27:19 +08:00 committed by GitHub
parent 27e743f37a
commit ff4ae56a20
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 210 additions and 0 deletions

View File

@ -0,0 +1,97 @@
import { load } from 'cheerio';
import type { Route } from '@/types';
import ofetch from '@/utils/ofetch';
import { parseDate } from '@/utils/parse-date';
export const route: Route = {
path: '/magazine/:id',
categories: ['anime'],
example: '/comic-fuz/magazine/27860',
parameters: { id: 'ComicFuz中对应的杂志id' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['comic-fuz.com/magazine/:id'],
target: '/magazine/:id',
},
],
name: '杂志详情',
maintainers: ['xiaobailoves'],
handler: async (ctx) => {
const { id } = ctx.req.param();
const baseUrl = 'https://comic-fuz.com';
const openUrl = `${baseUrl}/magazine/${id}`;
const imgUrl = `https://img.comic-fuz.com`;
const response = await ofetch(openUrl, {
headers: {
Referer: 'https://comic-fuz.com/',
'Accept-Language': 'ja,en-US;q=0.9,en;q=0.8',
},
});
const $ = load(response);
const nextDataText = $('#__NEXT_DATA__').text();
if (!nextDataText) {
throw new Error('无法解析页面数据,请检查杂志 ID 是否正确或页面结构是否变动');
}
const nextData = JSON.parse(nextDataText);
const pageProps = nextData.props?.pageProps;
if (!pageProps) {
throw new Error('无法解析页面 Props 数据');
}
const magazineTitle = pageProps.magazineName || '';
const magazineDescription = pageProps.pickupMagazineIssue?.longDescription || '';
const issues = pageProps.magazineIssues || [];
const items = issues.map((item: any) => {
const amount = item.paidPoint || 0;
const statusText = amount > 0 ? '付费' : '无料';
let thumb = item.thumbnailUrl;
if (thumb && thumb.startsWith('/')) {
thumb = `${imgUrl}${thumb}`;
}
const rawDate = item.updatedDate ? item.updatedDate.replace(/\s*発売/, '').trim() : '';
return {
title: `${magazineTitle} - ${item.magazineIssueName}`,
link: `${baseUrl}/magazine/viewer/${item.magazineIssueId}`,
description: `
${thumb ? `<img src="${thumb}" style="max-width: 100%;"><br>` : ''}
<p>价格: ${amount} /</p>
<p>发售日期: ${item.updatedDate}</p>
<p>截止日期: ${item.endDate || '无'}</p>
${item.longDescription ? `<p>${item.longDescription}</p>` : ''}
`,
pubDate: rawDate ? parseDate(rawDate, 'YYYY/MM/DD') : undefined,
guid: `comicfuz-magazine-id-${item.magazineIssueId}`,
category: [statusText],
};
});
return {
title: `COMIC FUZ - ${magazineTitle}`,
link: openUrl,
description: magazineDescription,
item: items,
language: 'ja',
};
},
};

View File

@ -0,0 +1,106 @@
import { load } from 'cheerio';
import type { Route } from '@/types';
import ofetch from '@/utils/ofetch';
import { parseDate } from '@/utils/parse-date';
export const route: Route = {
path: '/manga/:id',
categories: ['anime'],
example: '/comic-fuz/manga/218',
parameters: { id: 'ComicFuz中对应的漫画id' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['comic-fuz.com/manga/:id'],
target: '/manga/:id',
},
],
name: '漫画详情',
maintainers: ['xiaobailoves'],
handler: async (ctx) => {
const { id } = ctx.req.param();
const baseUrl = 'https://comic-fuz.com';
const openUrl = `${baseUrl}/manga/${id}`;
const imgUrl = `https://img.comic-fuz.com`;
const response = await ofetch(openUrl, {
headers: {
Referer: 'https://comic-fuz.com/',
'Accept-Language': 'ja,en-US;q=0.9,en;q=0.8',
},
});
const $ = load(response);
const nextDataText = $('#__NEXT_DATA__').text();
if (!nextDataText) {
throw new Error('无法解析页面数据,请检查漫画 ID 是否正确或页面结构是否变动');
}
const nextData = JSON.parse(nextDataText);
const pageProps = nextData.props?.pageProps;
if (!pageProps) {
throw new Error('无法解析页面 Props 数据');
}
const mangaTitle = $('title').text().trim();
const mangaAuthor = pageProps.authorships?.map((item: any) => item.author?.authorName).join(', ') || '';
const mangaDescription = pageProps.manga?.longDescription || '';
const chapterGroups = pageProps.chapters || [];
const allChapters = chapterGroups.flatMap((group: any) => group.chapters || []);
const items = allChapters.map((chapter: any) => {
const pointInfo = chapter.pointConsumption;
const amount = pointInfo?.amount || 0;
let statusText = '';
if (pointInfo && Object.keys(pointInfo).length === 0) {
statusText = '无料';
} else if (amount > 0) {
statusText = '付费';
}
let thumb = chapter.thumbnailUrl;
if (thumb && thumb.startsWith('/')) {
thumb = `${imgUrl}${thumb}`;
}
const fullTitle = `${chapter.chapterMainName}${chapter.chapterSubName ? ` - ${chapter.chapterSubName}` : ''}`;
return {
title: fullTitle,
link: `${baseUrl}/manga/viewer/${chapter.chapterId}`,
description: `
${thumb ? `<img src="${thumb}" style="max-width: 100%;"><br>` : ''}
${amount > 0 ? `<p>价格: ${amount} 金币/铜币</p>` : ''}
`,
guid: `comicfuz-comic-id-${chapter.chapterId}`,
category: statusText,
author: mangaAuthor,
pubDate: chapter.updatedDate ? parseDate(chapter.updatedDate, 'YYYY/MM/DD') : undefined,
upvotes: chapter.numberOfLikes || 0,
comments: chapter.numberOfComments || 0,
};
});
return {
title: `COMIC FUZ - ${mangaTitle}`,
link: openUrl,
description: mangaDescription,
item: items,
language: 'ja',
};
},
};

View File

@ -0,0 +1,7 @@
import type { Namespace } from '@/types';
export const namespace: Namespace = {
name: 'COMIC FUZ',
url: 'comic-fuz.com',
lang: 'ja',
};