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

FIX ManhwasMen: no more Madara #5978

Merged
merged 1 commit into from
Jul 8, 2023
Merged
Changes from all commits
Commits
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
40 changes: 33 additions & 7 deletions src/web/mjs/connectors/ManhwasMen.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import WordPressMadara from './templates/WordPressMadara.mjs';
import Connector from '../engine/Connector.mjs';
import Manga from '../engine/Manga.mjs';

export default class ManhwasMen extends WordPressMadara {
export default class ManhwasMen extends Connector {

constructor() {
super();
Expand All @@ -9,15 +10,22 @@ export default class ManhwasMen extends WordPressMadara {
this.tags = [ 'webtoon', 'hentai', 'korean', 'english' ];
this.url = 'https://manhwas.men';
this.path = '/manga-list';
this.queryMangas = 'div.series-box a';
this.queryChapters = 'li.wp-manga-chapter a';
this.queryChaptersTitleBloat = 'span';
this.queryMangas = 'article.anime a';
this.queryChapters = 'ul.episodes-list li a';
this.queryPages = 'div#chapter_imgs source';

}

async _getMangaFromURI(uri) {
const request = new Request(uri, this.requestOptions);
const data = await this.fetchDOM(request, 'h1.title');
const id = uri.pathname;
const title = data[0].textContent.trim();
return new Manga(this, id, title);
}

async _getMangas() {
let mangaList = [];
const mangaList = [];
for(let page = 1, run = true; run; page++) {
let mangas = await this._getMangasFromPage(page);
mangas.length > 0 ? mangaList.push(...mangas) : run = false;
Expand All @@ -32,9 +40,27 @@ export default class ManhwasMen extends WordPressMadara {
return data.map(element => {
return {
id: this.getRootRelativeOrAbsoluteLink(element, request.url),
title: element.querySelector('h5.series-title').textContent.trim()
title: element.querySelector('.title').textContent.trim()
};
});
}

async _getChapters(manga) {
let uri = new URL(manga.id, this.url);
let request = new Request(uri, this.requestOptions);
let data = await this.fetchDOM(request, this.queryChapters);
return data.map(element => {
return {
id: this.getRootRelativeOrAbsoluteLink(element, request.url),
title: element.querySelector('p span').textContent.replace(manga.title, '').trim()
};
});
}

async _getPages(chapter) {
let uri = new URL(chapter.id, this.url);
let request = new Request(uri, this.requestOptions);
let data = await this.fetchDOM(request, this.queryPages);
return data.filter(element => !element.src.includes('discord.jpg')).map(element => this.getRootRelativeOrAbsoluteLink(element, request.url));
}
}