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

add manmanapp #2587

Merged
merged 4 commits into from
Nov 6, 2020
Merged
Show file tree
Hide file tree
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
Binary file added src/web/img/connectors/manmanapp
Binary file not shown.
78 changes: 78 additions & 0 deletions src/web/mjs/connectors/manmanapp.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import Connector from '../engine/Connector.mjs';
import Manga from '../engine/Manga.mjs';

export default class ManmanApp extends Connector {

constructor() {
super();
super.id = 'manmanapp';
super.label = 'Manman Comic 漫漫漫画';
this.tags = [ 'manga', 'webtoon', 'chineses' ];
this.url = 'https://www.manmanapp.com';
}

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

async _getMangas() {
let mangaList = [];
const request = new Request(new URL('/comic/category_1.html', this.url), this.requestOptions);
const data = await this.fetchDOM(request, 'div.paging li:last-of-type > a');
const pageCount = parseInt(data[0].href.match(/(\d+).html/)[1]);
for(let page = 1; page <= pageCount; page++) {
let mangas = await this._getMangasFromPage(page);
mangaList.push(...mangas);
}
return mangaList;
}

async _getMangasFromPage(page) {
const request = new Request(new URL(`/comic/category_${page}.html`, this.url), this.requestOptions);
const data = await this.fetchDOM(request, 'li.title > a');
return data.map(element => {
return {
id: this.getRootRelativeOrAbsoluteLink(element, this.url),
title: element.text.trim()
};
});
}

async _getChapters(manga) {
let chaptersList = [];
const id = manga.id.match(/(\d+).html/)[1];
for(let page = 1, run = true; run; page++) {
let chapters = await this._getChaptersFromPage(page, id);
chapters.length > 0 ? chaptersList.push(...chapters) : run = false;
}
return chaptersList;
}

async _getChaptersFromPage(page, id) {
const request = new Request(new URL('/works/comic-list-ajax.html', this.url), {
method: 'POST',
body: new URLSearchParams({
id: id,
sort: 0,
page: page
})
Robonau marked this conversation as resolved.
Show resolved Hide resolved
});
const datt = await this.fetchJSON(request);
return datt.code == 1 ? datt.data.map(element => {
return {
id: '/comic/detail-'+element.id+'.html',
title: element.title
};
}): [];
}

async _getPages(chapter) {
const request = new Request(new URL(chapter.id, this.url), this.requestOptions);
const data = await this.fetchDOM(request, 'source.man_img');
return data.map(ele => this.getAbsolutePath(ele, request.url));
}
}