-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flatmanga] revise isolation of shared behavior
- Loading branch information
Ronny
committed
Feb 15, 2025
1 parent
2dda748
commit 7da5792
Showing
27 changed files
with
314 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,69 @@ | ||
import { Tags } from '../Tags'; | ||
import icon from './KLManga.webp'; | ||
import { DecoratableMangaScraper, type Manga, type Chapter, type Page } from '../providers/MangaPlugin'; | ||
import * as FlatManga from './templates/FlatManga'; | ||
import * as Common from './decorators/Common'; | ||
import { ChapterScript, FlatManga, MangaExtractor, PageScript, pathSinglePageManga } from './templates/FlatManga'; | ||
|
||
@Common.MangasSinglePagesCSS([pathSinglePageManga], 'span[data-toggle="mangapop"] a', MangaExtractor) | ||
@Common.ChaptersSinglePageJS(ChapterScript('a.chapter:not([href="#"])'), 1500) | ||
@Common.PagesSinglePageJS(PageScript(), 1500) | ||
export default class extends FlatManga { | ||
function RandomString(length: number) { | ||
return Array.from({ length }, () => Math.random().toString(36).at(-1)).join(''); | ||
} | ||
|
||
@Common.MangaCSS(FlatManga.pathManga, FlatManga.queryMangaTitle) | ||
@Common.MangasSinglePagesCSS([ FlatManga.pathMangasSinglePage ], 'span[data-toggle="mangapop"] a') | ||
@Common.ImageAjax() | ||
export default class extends DecoratableMangaScraper { | ||
|
||
public constructor() { | ||
super('klmanga', 'KLManga', 'https://klz9.com', Tags.Media.Manga, Tags.Language.Japanese, Tags.Source.Aggregator); | ||
} | ||
|
||
public override get Icon() { | ||
return icon; | ||
} | ||
|
||
public override async FetchChapters(manga: Manga): Promise<Chapter[]> { | ||
return FlatManga.FetchChaptersAJAX.call(this, manga, `/${RandomString(25)}.lstc?slug={manga}`, 'table td a.chapter'); | ||
} | ||
|
||
public override async FetchPages(chapter: Chapter): Promise<Page[]> { | ||
return FlatManga.FetchPagesAJAX.call( | ||
this, | ||
chapter, | ||
/load_image\s*\(\s*(\d+)\s*,\s*'list-imga'\s*\)/g, | ||
`/${RandomString(30)}.iog?cid={chapter}`, | ||
'img.chapter-img:not([src*="olimposcan"]):not([src$=".gif"])', | ||
img => img.src); | ||
} | ||
} | ||
|
||
/* | ||
type APIChapters = { | ||
id: string, | ||
chapter: string, | ||
name: string, | ||
}[]; | ||
@Common.MangaCSS(/^{origin}\/[^/]+\.html$/, queryMangaTitle) | ||
@Common.MangasSinglePagesCSS([ pathMangasSinglePage ], 'span[data-toggle="mangapop"] a') | ||
@Common.PagesSinglePageCSS('img.chapter-img:not([src*="olimposcan"]):not([src$=".gif"])') | ||
@Common.ImageAjax() | ||
export default class extends DecoratableMangaScraper { | ||
public constructor() { | ||
super('klmanga', 'KLManga', 'https://klz9.com', Tags.Language.Japanese, Tags.Media.Manga, Tags.Source.Aggregator); | ||
super('klmanga', 'KLManga', 'https://klz9.com', Tags.Media.Manga, Tags.Language.Japanese, Tags.Source.Aggregator); | ||
} | ||
public override get Icon() { | ||
return icon; | ||
} | ||
} | ||
public override async FetchChapters(manga: Manga): Promise<Chapter[]> { | ||
const uri = new URL(`/${RandomString(20)}.lst?manga=` + ExtractMangaSlug(manga), this.URI); | ||
const chapters = await FetchJSON<APIChapters>(new Request(uri)); | ||
return chapters.map(chapter => { | ||
const title = [ 'Chapter ' + chapter.chapter, chapter.name ].filter(segment => segment).join(' - ').trim(); | ||
return new Chapter(this, manga, `/${RandomString(30)}.iog?cid=${chapter.id}`, title); | ||
}); | ||
} | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
import { TestFixture, type Config } from '../../../test/WebsitesFixture'; | ||
/* NW.js crash on website initialize => CloudFlare | ||
import { TestFixture } from '../../../test/WebsitesFixture'; | ||
const config: Config = { | ||
new TestFixture({ | ||
plugin: { | ||
id: 'manhwa18', | ||
title: 'Manhwa 18 (.com)' | ||
title: 'Manhwa 18 (.com)', | ||
}, | ||
container: { | ||
url: 'https://manhwa18.com/manga/may-i-help-you', | ||
id: '/manga/may-i-help-you', | ||
title: 'May I Help You?' | ||
title: 'May I Help You?', | ||
}, | ||
child: { | ||
id: '/manga/may-i-help-you/chap-01-678', | ||
title: 'chap 01' | ||
title: 'chap 01', | ||
}, | ||
entry: { | ||
index: 0, | ||
size: 476_512, | ||
type: 'image/jpeg' | ||
type: 'image/jpeg', | ||
} | ||
}; | ||
|
||
new TestFixture(config).AssertWebsite(); | ||
}).AssertWebsite(); | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.