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 48 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 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
543da01
Merge branch 'master' into MHKX
MikeZeDev Dec 15, 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
93 changes: 93 additions & 0 deletions web/src/engine/websites/KanMan.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { Tags } from '../Tags';
import icon from './KanMan.webp';
import * as Common from './decorators/Common';
import { FetchCSS, FetchJSON } from '../platform/FetchProvider';
import { Chapter, DecoratableMangaScraper, Manga, Page, type MangaPlugin } from '../providers/MangaPlugin';
import { Choice } from '../SettingsManager';
import { EngineResourceKey as E, WebsiteResourceKey as W } from '../../i18n/ILocale';

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[]
}

@Common.ImageAjax(true)
export default class extends DecoratableMangaScraper {
private readonly apiUrl = 'https://www.kanman.com/api/';
private readonly product = {
id: '1',
name: 'kmh',
platform: 'pc'
};
public constructor() {
super('kanman', `看漫画 (KanMan)`, 'https://www.kanman.com', Tags.Media.Manhua, Tags.Language.Chinese, Tags.Source.Official);

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 get Icon() {
return icon;
}

public override async FetchManga(provider: MangaPlugin, url: string): Promise<Manga> {
const [data] = await FetchCSS(new Request(url), 'h1.title');
return new Manga(this, provider, url.match(/(\d+)\/$/)[1], data.textContent.trim());
}
public override ValidateMangaURL(url: string): boolean {
return new RegExp(`^${this.URI.origin}/[^/]+/$`).test(url);
}

public override async FetchMangas(provider: MangaPlugin): Promise<Manga[]> {
const { data } = await FetchJSON<APIResult<APIManga[]>>(new Request(new URL('getComicList', this.apiUrl)));
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 = new URL(`getComicInfoBody?comic_id=${manga.Identifier}`, this.apiUrl);
const { data: { comic_chapter } } = await FetchJSON<APIResult<APIManga>>(new Request(uri));
return 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 = new URL('getchapterinfov2', this.apiUrl);
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: { current_chapter: { chapter_img_list } } } = await FetchJSON<APIResult<APIManga>>(new Request(uri));
return chapter_img_list.map(page => new Page(this, chapter, new URL(page)));
}
}
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/17745/',
id: '17745',
title: '凤逆天下'
},
child: {
id: '1004',
title: '第1话 神秘的黑玉1'
},
entry: {
index: 3,
size: 246_994,
type: 'image/webp'
}
};

new TestFixture(config).AssertWebsite();
5 changes: 1 addition & 4 deletions web/src/engine/websites/_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,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 @@ -749,7 +750,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 All @@ -774,7 +774,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 MoreNovel } from './legacy/MoreNovel';
export { default as MuchoHentai } from './legacy/MuchoHentai';
Expand Down Expand Up @@ -804,10 +803,8 @@ export { default as PlotTwistNoFansub } from './legacy/PlotTwistNoFansub';
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
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.

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

This file was deleted.

Binary file removed web/src/engine/websites/legacy/TaoManhua.webp
Binary file not shown.
7 changes: 6 additions & 1 deletion web/src/i18n/ILocale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export enum FrontendResourceKey {
Frontend_Setting = 'Frontend_Setting',
Frontend_Settings = 'Frontend_Settings',
Frontend_Help = 'Frontend_Help',
Frontend_About= 'Frontend_About',
Frontend_About = 'Frontend_About',
Frontend_Plugin = 'Frontend_Plugin',
Frontend_Plugins = 'Frontend_Plugins',
Frontend_Plugin_List = 'Frontend_Plugin_List',
Expand Down Expand Up @@ -324,6 +324,11 @@ export enum WebsiteResourceKey {
Plugin_Settings_UrlOverrideInfo = 'Plugin_Settings_UrlOverrideInfo',
Plugin_Settings_ImageFormat = 'Plugin_Settings_ImageFormat',
Plugin_Settings_ImageFormatInfo = 'Plugin_Settings_ImageFormatInfo',
Plugin_Settings_ImageQuality = 'Plugin_Settings_ImageQuality',
Plugin_Settings_ImageQualityInfo = 'Plugin_Settings_ImageQualityInfo',
Plugin_Settings_ImageQuality_High = 'Plugin_Settings_ImageQuality_High',
Plugin_Settings_ImageQuality_Medium = 'Plugin_Settings_ImageQuality_Medium',
Plugin_Settings_ImageQuality_Low = 'Plugin_Settings_ImageQuality_Low',
Plugin_Common_MangaIndex_NotSupported = 'Plugin_Common_MangaIndex_NotSupported',
Plugin_Common_Chapter_InvalidError = 'Plugin_Common_Chapter_InvalidError',
Plugin_Common_Chapter_UnavailableError = 'Plugin_Common_Chapter_UnavailableError',
Expand Down
6 changes: 6 additions & 0 deletions web/src/i18n/locales/en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,12 @@ const translations: VariantResource = {
Plugin_Settings_ImageFormat: 'Preferred Image Format',
Plugin_Settings_ImageFormatInfo: 'Download pictures using this file format if possible',

Plugin_Settings_ImageQuality: 'Image quality',
Plugin_Settings_ImageQualityInfo: 'Download pictures using this quality if possible',
Plugin_Settings_ImageQuality_High: 'High',
Plugin_Settings_ImageQuality_Medium: 'Medium',
Plugin_Settings_ImageQuality_Low: 'Low',

Plugin_Common_MangaIndex_NotSupported: 'Unable to create the content index for this website. Use the Copy & Paste feature to directly access the content of a specific URL!',
Plugin_Common_Chapter_UnavailableError: 'The chapter is not available (not purchased/unlocked/public)!',
Plugin_Common_Chapter_InvalidError: 'Failed to extract the pages from the chapter content!',
Expand Down
Loading