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 YoungChampion & ComicMedu : more strict chapter CSS #6356

Merged
merged 3 commits into from
Oct 26, 2023
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
77 changes: 6 additions & 71 deletions src/web/mjs/connectors/COMICMeDu.mjs
Original file line number Diff line number Diff line change
@@ -1,80 +1,15 @@
import Connector from '../engine/Connector.mjs';
import Manga from '../engine/Manga.mjs';
import YoungChampion from './YoungChampion.mjs';

export default class COMICMeDu extends Connector {
export default class COMICMeDu extends YoungChampion {

constructor() {
super();
super.id = 'comicmedu';
super.label = 'COMIC MeDu (こみっくめづ)';
this.tags = [ 'manga', 'japanese' ];
this.url = 'http://comic-medu.com';

this.path = [ '/wk' ];
this.queryMangaListCount = 'article div#conMain div.conDoc ul.pagination li';
this.queryManga = 'article div#conMain div.conDoc div#listB div.listM';
this.queryMangaLink = 'a';
this.queryMangaTitle = 'h3.listTtl';

this.queryChapters = 'article div#conMain div.conDoc ul.episode li a';
this.queryShortChapter = 'article div#conMain div.conDoc div.btDetail a.btDetailR';

this.queryPages = 'article div.swiper-container div.swiper-wrapper div.swiper-slide source[class*="storyImg"]';
}

async _getMangaFromURI(uri) {
let request = new Request(uri, this.requestOptions);
let data = await this.fetchDOM(request, 'head title');
let id = uri.pathname;
let title = data[0].text.split('|')[0].trim();
return new Manga(this, id, title);
}

async _mapMangas(mangas) {
return mangas.map(series => {
return {
id: this.getRootRelativeOrAbsoluteLink(series.querySelector(this.queryMangaLink), this.url),
title: series.querySelector(this.queryMangaTitle).textContent
};
});
}

async _getMangas() {
let uri = new URL(this.url + this.path[0]);
let request = new Request(uri, this.requestOptions);
let seriesPages = await this.fetchDOM(request, this.queryMangaListCount);
let totalPages = seriesPages.length;
let mangas = await this.fetchDOM(request, this.queryManga);
let mangaList = await this._mapMangas(mangas);
for(let page = 2; page <= totalPages; page++) {
uri.searchParams.set('page', page);
request = new Request(uri, this.requestOptions);
mangas = await this._mapMangas(await this.fetchDOM(request, this.queryManga));
mangaList.push(...mangas);
}
return mangaList;
}

async _getChapters(manga) {
let uri = new URL(this.url + manga.id);
let request = new Request(uri, this.requestOptions);
let data = await this.fetchDOM(request, this.queryChapters);
if(data.length == 0) { // series is a short story; only one chapter
data = await this.fetchDOM(request, this.queryShortChapter);
data[0].textContent = manga.title;
}
return data.map(element => {
return {
id: this.getRootRelativeOrAbsoluteLink(element, request.url),
title: element.textContent
};
});
}

async _getPages(chapter) {
let uri = new URL(this.url + chapter.id);
let request = new Request(uri, this.requestOptions);
let data = await this.fetchDOM(request, this.queryPages);
return data.map(element => this.getAbsolutePath(element, request.url));
this.url = 'https://comic-medu.com';
this.links = {
login: 'https://comic-medu.com/signin'
};
}
}
2 changes: 1 addition & 1 deletion src/web/mjs/connectors/YoungChampion.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class YoungChampion extends Connector {
this.queryMangaTitleURI = 'h1.series-h-title span:not([class])';
this.queryManga = 'div.series-box-vertical a';
this.queryMangaTitle = 'h2.title-text';
this.queryChapter = 'div.series-ep-list a';
this.queryChapter = 'div.series-ep-list a#null-false';
MikeZeDev marked this conversation as resolved.
Show resolved Hide resolved
this.queryChapterTitle = 'span.series-ep-list-item-h-text';
}

Expand Down
Loading