-
Notifications
You must be signed in to change notification settings - Fork 482
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ManhwaClub => Become ManhwaHentai (#7019)
- Loading branch information
Showing
2 changed files
with
33 additions
and
43 deletions.
There are no files selected for viewing
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,58 +1,48 @@ | ||
import Connector from '../engine/Connector.mjs'; | ||
import Manga from '../engine/Manga.mjs'; | ||
import WordPressMadara from './templates/WordPressMadara.mjs'; | ||
|
||
export default class ManhwaClub extends Connector { | ||
export default class ManhwaClub extends WordPressMadara { | ||
|
||
constructor() { | ||
super(); | ||
super.id = 'manhwaclub'; | ||
super.label = 'ManhwaClub'; | ||
super.label = 'ManhwaHentai'; | ||
this.tags = [ 'webtoon', 'hentai', 'multi-lingual' ]; | ||
this.url = 'https://manhwa.club'; | ||
this.apiURL='/api/comics'; | ||
} | ||
async _getMangaFromURI(uri) { | ||
let id = uri.pathname.split('/'); | ||
id = id[id.length-1]; | ||
uri = new URL(this.apiURL + '/' + id, this.url); | ||
const request = new Request(uri, this.requestOptions); | ||
const data = await this.fetchJSON(request); | ||
return new Manga(this, id, data.title.trim()); | ||
} | ||
async _getMangas() { | ||
let mangaList = []; | ||
for (let page = 1, run = true; run; page++) { | ||
let mangas = await this._getMangasFromPage(page); | ||
mangas.length > 0 ? mangaList.push(...mangas) : run = false; | ||
} | ||
return mangaList; | ||
} | ||
async _getMangasFromPage(page) { | ||
const uri = new URL(this.apiURL + '?page=' + page, this.url); | ||
const request = new Request(uri, this.requestOptions); | ||
const data = await this.fetchJSON(request); | ||
return data.data.map(element => { | ||
return { | ||
id: element.slug, | ||
title: element.title.trim() | ||
}; | ||
}); | ||
this.url = 'https://manhwahentai.to'; | ||
this.queryMangas = 'div.post_title a'; | ||
this.queryTitleForURI = 'div.post-summary div.post-title'; | ||
} | ||
|
||
async _getChapters(manga) { | ||
const uri = new URL(this.apiURL + '/' + manga.id+'/chapters', this.url); | ||
const request = new Request(uri, this.requestOptions); | ||
const data = await this.fetchJSON(request); | ||
return data.map(element => { | ||
const request = new Request(new URL(manga.id, this.url)); | ||
const script = ` | ||
new Promise((resolve) => { | ||
setTimeout(() => { | ||
resolve(manga.manga_id); | ||
}, 1500); | ||
}); | ||
`; | ||
const mangaid = await Engine.Request.fetchUI(request, script); | ||
const url = new URL(`/wp-admin/admin-ajax.php?action=get-all-chapters-list&post_id=${mangaid}&chapters_per_page=9999&offset=0`, this.url); | ||
const { data } = await this.fetchJSON(new Request(url)); | ||
const dom = new DOMParser().parseFromString(data, 'text/html'); | ||
const links = [...dom.querySelectorAll('li a')]; | ||
return links.map(chapter => { | ||
return { | ||
id: element.slug, | ||
title: element.name.trim(), | ||
id: `${mangaid.slug}${chapter.pathname.split('/').pop()}`, | ||
title: chapter.querySelector('p.truncate').textContent.trim() | ||
}; | ||
}); | ||
} | ||
|
||
async _getPages(chapter) { | ||
const uri = new URL(this.apiURL + '/' + chapter.manga.id+'/'+ chapter.id+'/images', this.url); | ||
const request = new Request(uri, this.requestOptions); | ||
const data = await this.fetchJSON(request); | ||
return data.images.map(element => element.source_url); | ||
const request = new Request(new URL(chapter.id, this.url)); | ||
const script = ` | ||
new Promise((resolve) => { | ||
setTimeout(() => { | ||
resolve(chapter_preloaded_images.map(image => image.src.replace('http://', 'https://'))); | ||
}, 1500); | ||
}); | ||
`; | ||
return Engine.Request.fetchUI(request, script); | ||
} | ||
} |