Skip to content

Commit

Permalink
Add Zhuzhumh (#639)
Browse files Browse the repository at this point in the history
* Add Zhuzhumh

manga-download/hakuneko#7149

* use api to get chapters
  • Loading branch information
MikeZeDev committed Jun 13, 2024
1 parent 1ab328d commit f671795
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
34 changes: 34 additions & 0 deletions web/src/engine/websites/Zhuzhumh.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Tags } from '../Tags';
import icon from './Zhuzhumh.webp';
import { Chapter, DecoratableMangaScraper, type Manga } from '../providers/MangaPlugin';
import * as Common from './decorators/Common';
import { FetchJSON } from '../platform/FetchProvider';

type APIChapter = {
chaptername: string,
chapterurl: string
}

@Common.MangaCSS(/^{origin}\/book\/[^/]+\.html$/, 'div.cy_title h1')
@Common.MangasMultiPageCSS('/sort/1-{page}.html', 'div.cy_list_mh ul li.title a')
@Common.PagesSinglePageJS('newImgs', 1500)
@Common.ImageAjax()
export default class extends DecoratableMangaScraper {

public constructor() {
super('zhuzhumh', `Zhuzhumh`, 'https://www.zhuzhumh.com', Tags.Language.Chinese, Tags.Media.Manga, Tags.Media.Manhua, Tags.Media.Manhwa, Tags.Source.Aggregator);
}

public override get Icon() {
return icon;
}

public override async FetchChapters(manga: Manga): Promise<Chapter[]> {
const chapterslist = await Common.FetchChaptersSinglePageCSS.call(this, manga, 'ul#mh-chapter-list-ol-0 li a');
const mangaid = manga.Identifier.match(/\/book\/([^.]+)\.html$/)[1];
const data = await FetchJSON<APIChapter[]>(new Request(new URL(`/api/bookchapter?id=${mangaid}&id2=1`, this.URI)));
chapterslist.push(...data.map(chapter => new Chapter(this, manga, new URL(chapter.chapterurl).pathname, chapter.chaptername.trim())));
return chapterslist;
}

}
Binary file added web/src/engine/websites/Zhuzhumh.webp
Binary file not shown.
26 changes: 26 additions & 0 deletions web/src/engine/websites/Zhuzhumh_e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { describe } from 'vitest';
import { TestFixture } from '../../../test/WebsitesFixture';

const config = {
plugin: {
id: 'zhuzhumh',
title: 'Zhuzhumh'
},
container: {
url: 'https://www.zhuzhumh.com/book/shisiruguiweijunzi.html',
id: '/book/shisiruguiweijunzi.html',
title: '视死如归魏君子'
},
child: {
id: '/chapter-redirect/shisiruguiweijunzi/1364147.html',
title: '93 四大纨绔之三'
},
entry: {
index: 0,
size: 863_947,
type: 'image/jpeg'
}
};

const fixture = new TestFixture(config);
describe(fixture.Name, async () => (await fixture.Connect()).AssertWebsite());
1 change: 1 addition & 0 deletions web/src/engine/websites/_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,7 @@ export { default as Zebrack } from './Zebrack';
export { default as ZenithScans } from './ZenithScans';
export { default as ZeroScans } from './ZeroScans';
export { default as ZeurelScan } from './ZeurelScan';
export { default as Zhuzhumh } from './Zhuzhumh';
export { default as ZinManga } from './ZinManga';
export { default as ZinMangaNet } from './ZinMangaNet';
export { default as ZuiMH } from './ZuiMH';
Expand Down

0 comments on commit f671795

Please sign in to comment.