Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Kanman #462

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
898e332
Add MHKX decorator and websites
MikeZeDev Jan 12, 2024
88cf440
Update _index.ts
MikeZeDev Jan 12, 2024
8d54832
fix plugin icons
MikeZeDev Jan 12, 2024
b56aa3b
add tests
MikeZeDev Jan 12, 2024
91d7471
Update zu_ZA.ts
MikeZeDev Jan 12, 2024
e87c02d
Update zu_ZA.ts
MikeZeDev Jan 12, 2024
5bdabe3
Merge branch 'master' into MHKX
MikeZeDev Jan 16, 2024
5a8a576
improve platform abstraction
MikeZeDev Jan 16, 2024
1c52b9e
Merge branch 'master' into MHKX
MikeZeDev Feb 3, 2024
5351bb8
Update _index.ts
MikeZeDev Feb 3, 2024
7c5a62a
Merge branch 'master' into MHKX
MikeZeDev Feb 5, 2024
f9d1782
Update _index.ts
MikeZeDev Feb 5, 2024
80de5f4
Merge branch 'master' into MHKX
MikeZeDev Mar 23, 2024
210db4d
Merge branch 'master' into MHKX
MikeZeDev Apr 26, 2024
0a9a20d
Merge branch 'master' into MHKX
MikeZeDev Apr 27, 2024
f66e2e6
Update _index.ts
MikeZeDev Apr 27, 2024
3615237
fix case
MikeZeDev Apr 27, 2024
6c35bd9
add some settings translation
MikeZeDev Apr 27, 2024
abe6a47
Merge branch 'master' into MHKX
MikeZeDev May 7, 2024
3617c3b
update tests to use vitest
MikeZeDev May 7, 2024
df71121
MHKX -> MHXK
MikeZeDev May 9, 2024
2e66c1f
Update zu_ZA.ts
MikeZeDev May 9, 2024
2d50b02
update decorator for new request implementation
MikeZeDev May 9, 2024
4c516c3
Merge branch 'master' into MHKX
MikeZeDev Jun 7, 2024
307f7b9
Merge branch 'master' into MHKX
MikeZeDev Jun 30, 2024
24cf8b6
Merge branch 'master' into MHKX
MikeZeDev Jul 15, 2024
1cea85a
Merge branch 'master' into MHKX
MikeZeDev Jul 28, 2024
7c5fffb
Update _index.ts
MikeZeDev Jul 28, 2024
4d45b08
Merge branch 'master' into MHKX
MikeZeDev Aug 14, 2024
beae5f6
Update _index.ts
MikeZeDev Aug 14, 2024
3d84d54
Merge branch 'master' into MHKX
MikeZeDev Aug 16, 2024
75df803
Remove TaoManhua and Manhuatai
MikeZeDev Aug 16, 2024
60ddace
Merge branch 'master' into MHKX
MikeZeDev Sep 8, 2024
4bce8f3
Update _index.ts
MikeZeDev Sep 8, 2024
2afacb7
Update zu_ZA.ts
MikeZeDev Sep 8, 2024
c04aa3d
Merge branch 'master' into MHKX
MikeZeDev Sep 10, 2024
29ed8db
Merge branch 'master' into MHKX
MikeZeDev Oct 7, 2024
1c849df
Merge branch 'master' into MHKX
MikeZeDev Oct 13, 2024
6c41b6e
Merge branch 'master' into MHKX
MikeZeDev Oct 27, 2024
dfdc70b
update tests
MikeZeDev Oct 27, 2024
d4003e7
Merge branch 'master' into MHKX
MikeZeDev Nov 2, 2024
f1a07db
remove soudongman and only add Kanman
MikeZeDev Nov 2, 2024
ccf5c47
Update KanMan.ts
MikeZeDev Nov 7, 2024
84aee49
Merge branch 'master' into MHKX
MikeZeDev Nov 19, 2024
074b30c
Merge branch 'master' into MHKX
MikeZeDev Nov 26, 2024
6d58ba1
Merge branch 'master' into MHKX
MikeZeDev Dec 9, 2024
d666128
Update KanMan.ts
MikeZeDev Dec 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions web/src/engine/websites/KanMan.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Tags } from '../Tags';
import icon from './KanMan.webp';
import MHKX, { type MhxkInfos } from './decorators/MHXK';
import * as Common from './decorators/Common';
import { FetchCSS } from '../platform/FetchProvider';
import { Manga, type MangaPlugin } from '../providers/MangaPlugin';

@Common.ImageAjax(true)
export default class extends MHKX {
public constructor() {
const product: MhxkInfos = {
id: '1',
name: 'kmh',
platform: 'pc'
};

super('kanman', `看漫画 (KanMan)`, 'https://www.kanman.com', product, Tags.Media.Manhua, Tags.Language.Chinese, Tags.Source.Official);
}
public override get Icon() {
return icon;
}

public override async FetchManga(provider: MangaPlugin, url: string): Promise<Manga> {
const [data] = await FetchCSS(new Request(url), 'h1.title');
const id: string = url.match(/(\d+)\/$/)[1];
const title = data.textContent.trim();
return new Manga(this, provider, id, title);
}
}
24 changes: 24 additions & 0 deletions web/src/engine/websites/KanMan_e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { TestFixture } from '../../../test/WebsitesFixture';

const config = {
plugin: {
id: 'kanman',
title: '看漫画 (KanMan)'
},
container: {
url: 'https://www.kanman.com/108632/',
id: '108632',
title: '龙腾战尊'
},
child: {
id: 'yugao-1624325650020',
title: '预告'
},
entry: {
index: 0,
size: 185_594,
type: 'image/webp'
}
};

new TestFixture(config).AssertWebsite();
21 changes: 21 additions & 0 deletions web/src/engine/websites/SouDongMan.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Tags } from '../Tags';
import icon from './SouDongMan.webp';
import MHKX, { type MhxkInfos } from './decorators/MHXK';
import * as Common from './decorators/Common';

@Common.ImageAjax(true)
export default class extends MHKX {
public constructor() {
const product: MhxkInfos = {
id: '9',
name: 'soudm',
platform: 'pc'
};

super('soudongman', `斗罗大陆 (SouDongMan)`, 'https://www.soudongman.com', product, Tags.Media.Manhua, Tags.Language.Chinese, Tags.Source.Official);
}

public override get Icon() {
return icon;
}
}
24 changes: 24 additions & 0 deletions web/src/engine/websites/SouDongMan_e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { TestFixture } from '../../../test/WebsitesFixture';

const config = {
plugin: {
id: 'soudongman',
title: '斗罗大陆 (SouDongMan)'
},
container: {
url: 'https://www.soudongman.com/108224/',
id: '108224',
title: '无敌学霸系统'
},
child: {
id: 'di303hua-1694658870',
title: '第303话 我要当圣使'
},
entry: {
index: 0,
size: 238_698,
type: 'image/webp'
}
};

new TestFixture(config).AssertWebsite();
6 changes: 2 additions & 4 deletions web/src/engine/websites/_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ export { default as KadoComi } from './KadoComi';
export { default as Kakaopage } from './Kakaopage';
export { default as KaliScan } from './KaliScan';
export { default as Kanjiku } from './Kanjiku';
export { default as KanMan } from './KanMan';
export { default as Kanzenin } from './Kanzenin';
export { default as Katakomik } from './Katakomik';
export { default as KingOfManga } from './KingOfManga';
Expand Down Expand Up @@ -602,6 +603,7 @@ export { default as SixParkbbsWeb } from './SixParkbbsWeb';
export { default as SkyManga } from './SkyManga';
export { default as SkyMangas } from './SkyMangas';
export { default as SoftKomik } from './SoftKomik';
export { default as SouDongMan } from './SouDongMan';
export { default as SoulScans } from './SoulScans';
export { default as SpiderScans } from './SpiderScans';
export { default as SpoilerPlus } from './SpoilerPlus';
Expand Down Expand Up @@ -749,7 +751,6 @@ export { default as GammaPlus } from './legacy/GammaPlus';
export { default as Guoman8 } from './legacy/Guoman8';
export { default as HeavenManga } from './legacy/HeavenManga';
export { default as HolyManga } from './legacy/HolyManga';
export { default as KanMan } from './legacy/KanMan';
export { default as KissAway } from './legacy/KissAway';
export { default as kuman5 } from './legacy/kuman5';
export { default as LectorManga } from './legacy/LectorManga';
Expand Down Expand Up @@ -782,7 +783,6 @@ export { default as MangaToonTH } from './legacy/MangaToonTH';
export { default as MangaToonVI } from './legacy/MangaToonVI';
export { default as MangaTR } from './legacy/MangaTR';
export { default as MangaZukiRAWS } from './legacy/MangaZukiRAWS';
export { default as ManhuaTai } from './legacy/ManhuaTai';
export { default as MeioNovel } from './legacy/MeioNovel';
export { default as MintManga } from './legacy/MintManga';
export { default as MoreNovel } from './legacy/MoreNovel';
Expand Down Expand Up @@ -815,10 +815,8 @@ export { default as SelfManga } from './legacy/SelfManga';
export { default as ShinobiScans } from './legacy/ShinobiScans';
export { default as SixMH7 } from './legacy/SixMH7';
export { default as SleepyTranslations } from './legacy/SleepyTranslations';
export { default as SouDongMan } from './legacy/SouDongMan';
export { default as StoriaDash } from './legacy/StoriaDash';
export { default as TAADD } from './legacy/TAADD';
export { default as TaoManhua } from './legacy/TaoManhua';
export { default as TencentComic } from './legacy/TencentComic';
export { default as TenManga } from './legacy/TenManga';
export { default as ToomicsDE } from './legacy/ToomicsDE';
Expand Down
100 changes: 100 additions & 0 deletions web/src/engine/websites/decorators/MHXK.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import { type Tag } from '../../Tags';
import { Choice } from '../../SettingsManager';
import { EngineResourceKey as E, WebsiteResourceKey as W } from '../../../i18n/ILocale';
import { Chapter, DecoratableMangaScraper, Manga, Page, type MangaPlugin } from '../../providers/MangaPlugin';
import { FetchCSS, FetchJSON } from '../../platform/FetchProvider';

export type MhxkInfos = {
id: string,
name: string,
platform: string
}

type APIResult<T> = {
data: T,
status: number,
message: string;
}

type APIManga = {
comic_id: number,
comic_name: string
comic_chapter: APIChapter[]
current_chapter: APIChapter
}

type APIChapter = {
chapter_name: string,
chapter_newid: string
chapter_img_list: string[]
}

export default class extends DecoratableMangaScraper {
protected product: MhxkInfos;

public constructor(id: string, title: string, url: string, product: MhxkInfos, ...tags: Tag[]) {
super(id, title, url, ...tags);
this.product = product;

this.Settings.format = new Choice('image.format',
W.Plugin_Settings_ImageFormat,
W.Plugin_Settings_ImageFormatInfo,
'1',
{ key: '0', label: E.Settings_Global_Format_JPEG },
{ key: '1', label: E.Settings_Global_Format_WEBP },
);

this.Settings.quality = new Choice('image.quality',
W.Plugin_Settings_ImageQuality,
W.Plugin_Settings_ImageQualityInfo,
'high',
{ key: 'high', label: W.Plugin_Settings_ImageQuality_High },
{ key: 'middle', label: W.Plugin_Settings_ImageQuality_Medium },
{ key: 'low', label: W.Plugin_Settings_ImageQuality_Low },
);
}

public override ValidateMangaURL(url: string): boolean {
return new RegExp(`^${this.URI.origin}/[^/]+/$`).test(url);
}

public override async FetchManga(provider: MangaPlugin, url: string): Promise<Manga> {
const [data] = await FetchCSS(new Request(url), '[data-comic-id], [data-comic_id]');
const id: string = data.dataset.comicId || data.dataset.comic_id;
const title = data.textContent.trim();
return new Manga(this, provider, id, title);
}

public override async FetchMangas(provider: MangaPlugin): Promise<Manga[]> {
const uri = this.CreateCustomerURI('/getComicList/');
const { data } = await FetchJSON<APIResult<APIManga[]>>(new Request(uri));
return data.map(manga => new Manga(this, provider, manga.comic_id.toString(), manga.comic_name.trim()));
}

public override async FetchChapters(manga: Manga): Promise<Chapter[]> {
const uri = this.CreateCustomerURI('/getComicInfoBody/');
uri.searchParams.set('comic_id', manga.Identifier);
const { data } = await FetchJSON<APIResult<APIManga>>(new Request(uri));
return data.comic_chapter.map(chapter => new Chapter(this, manga, chapter.chapter_newid, chapter.chapter_name.trim()));
}

public override async FetchPages(chapter: Chapter): Promise<Page[]> {
const uri = this.CreateCustomerURI('/getchapterinfov2');
uri.search = new URLSearchParams({
product_id: this.product.id,
productname: this.product.name,
platformname: this.product.platform,
comic_id: chapter.Parent.Identifier,
chapter_newid: chapter.Identifier,
isWebp: this.Settings.format.Value as string,
quality: this.Settings.quality.Value as string
}).toString();
const { data } = await FetchJSON<APIResult<APIManga>>(new Request(uri));
return data.current_chapter.chapter_img_list.map(page => new Page(this, chapter, new URL(page)));
}

private CreateCustomerURI(endpoint: string) {
return new URL('/api' + endpoint, this.URI);
}

}
37 changes: 0 additions & 37 deletions web/src/engine/websites/legacy/KanMan.ts

This file was deleted.

39 changes: 0 additions & 39 deletions web/src/engine/websites/legacy/ManhuaTai.ts

This file was deleted.

Binary file removed web/src/engine/websites/legacy/ManhuaTai.webp
Binary file not shown.
39 changes: 0 additions & 39 deletions web/src/engine/websites/legacy/SouDongMan.ts

This file was deleted.

Loading