-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add WeebCentral manga-download/hakuneko#7407 * requested changes
- Loading branch information
Showing
4 changed files
with
85 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { Tags } from '../Tags'; | ||
import icon from './WeebCentral.webp'; | ||
import { Chapter, DecoratableMangaScraper, Manga, type MangaPlugin } from '../providers/MangaPlugin'; | ||
import * as Common from './decorators/Common'; | ||
import { FetchCSS } from '../platform/FetchProvider'; | ||
|
||
@Common.MangaCSS(/^{origin}\/series\/[^/]+\/[^/]+$/, 'section > section > h1.text-center') | ||
@Common.PagesSinglePageCSS('main#chapter-main section img') | ||
@Common.ImageAjax() | ||
export default class extends DecoratableMangaScraper { | ||
|
||
public constructor() { | ||
super('weebcentral', 'WeebCentral', 'https://weebcentral.com', Tags.Media.Manhwa, Tags.Media.Manhua, Tags.Media.Manga, Tags.Language.English, Tags.Source.Aggregator); | ||
} | ||
|
||
public override get Icon() { | ||
return icon; | ||
} | ||
|
||
public override async FetchMangas(provider: MangaPlugin): Promise<Manga[]> { | ||
const mangaList : Manga[] = []; | ||
for (let page = 0, run = true; run; page++) { | ||
const mangas = await this.GetMangasFromPage(page, provider); | ||
mangas.length > 0 ? mangaList.push(...mangas) : run = false; | ||
} | ||
return mangaList; | ||
} | ||
|
||
private async GetMangasFromPage(page: number, provider: MangaPlugin): Promise<Manga[]> { | ||
const mangasperPage = 24; | ||
const searchURL = new URL('/search', this.URI).href; | ||
const data = await FetchCSS<HTMLAnchorElement>(new Request(new URL(`/search?limit=${mangasperPage}&offset=${page * mangasperPage}`, this.URI), { | ||
headers: { | ||
'HX-Request': 'true', | ||
'HX-Current-URL': searchURL, | ||
'HX-Target': 'search-more-container', | ||
Referer: searchURL | ||
|
||
} | ||
}), 'a.link.link-hover[href*="/series/"]'); | ||
return data.map(manga => new Manga(this, provider, manga.pathname, manga.textContent.trim())); | ||
} | ||
|
||
public override async FetchChapters(manga: Manga): Promise<Chapter[]> { | ||
const serieId = manga.Identifier.match(/(\/series\/[^/]+)\//)[1]; | ||
const chapterUrl = new URL(manga.Identifier, this.URI).href; | ||
const data = await FetchCSS<HTMLAnchorElement>(new Request(new URL(`${serieId}/full-chapter-list`, this.URI), { | ||
headers: { | ||
'HX-Request': 'true', | ||
'HX-Current-URL': chapterUrl, | ||
'HX-Target': 'chapter-list', | ||
Referer: chapterUrl | ||
} | ||
}), 'a'); | ||
return data.map(chapter => new Chapter(this, manga, chapter.pathname, chapter.querySelector('span.grow').textContent.trim())); | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { describe } from 'vitest'; | ||
import { TestFixture } from '../../../test/WebsitesFixture'; | ||
|
||
const config = { | ||
plugin: { | ||
id: 'weebcentral', | ||
title: 'WeebCentral' | ||
}, | ||
container: { | ||
url: 'https://weebcentral.com/series/01J76XY7E5E1C5Y9J0M2FCVQ8H/Fairy-Tail', | ||
id: '/series/01J76XY7E5E1C5Y9J0M2FCVQ8H/Fairy-Tail', | ||
title: 'Fairy Tail' | ||
}, | ||
child: { | ||
id: '/chapters/01J76XZ8VTT3V8J44VAX442FRN', | ||
title: 'Chapter 545.5' | ||
}, | ||
entry: { | ||
index: 0, | ||
size: 258_254, | ||
type: 'image/png' | ||
} | ||
}; | ||
|
||
const fixture = new TestFixture(config); | ||
describe(fixture.Name, async () => (await fixture.Connect()).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