Skip to content

Commit

Permalink
Fix ManhwaClub => Become ManhwaHentai (#7019)
Browse files Browse the repository at this point in the history
* Fix ManhwaClub => Become ManhwaHentai

Fixes #6863
Fixes #6115

* Add files via upload
  • Loading branch information
MikeZeDev authored May 4, 2024
1 parent 185636f commit ffca80f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 43 deletions.
Binary file modified src/web/img/connectors/manhwaclub
Binary file not shown.
76 changes: 33 additions & 43 deletions src/web/mjs/connectors/ManhwaClub.mjs
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);
}
}

0 comments on commit ffca80f

Please sign in to comment.