Skip to content

Commit

Permalink
Add Weeb Central connector/website (#7720)
Browse files Browse the repository at this point in the history
* Add Weeb Central connector

* Add weebcentral icon

* Update WeebCentral.mjs based on review

* Update WeebCentral.mjs, change "_getMangaFromURL"
  • Loading branch information
kiseki999 authored Feb 3, 2025
1 parent ff1cc17 commit f35fa38
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
Binary file added src/web/img/connectors/weebcentral
Binary file not shown.
77 changes: 77 additions & 0 deletions src/web/mjs/connectors/WeebCentral.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import Connector from '../engine/Connector.mjs';
import Manga from '../engine/Manga.mjs';

export default class WeebCentral extends Connector {

constructor() {
super();
super.id = 'weebcentral';
super.label = 'Weeb Central';
this.tags = [ 'manga', 'manhua', 'manhwa', 'english' ];
this.url = 'https://weebcentral.com';
}

async _getMangaFromURI(uri) {
const request = new Request(uri, this.requestOptions);
const [ title ] = await this.fetchDOM(request, 'meta[property="og:title"]');
return new Manga(this, uri.pathname, title.content.split('|').shift().trim());
}

async _getMangas() {
const mangaList = [];
for (let page = 0, run = true; run; page++) {
const mangas = await this._getMangasFromPage(page);
mangas.length > 0 ? mangaList.push(...mangas) : run = false;
}
return mangaList;
}

async _getMangasFromPage(page) {
const limit = 32;
let offset = page * limit;

const uri = new URL(`/search/data?display_mode=Minimal+Display&limit=${limit}&offset=${offset}`, this.url);
const request = new Request(uri, this.requestOptions);
const data = await this.fetchDOM(request, 'article > a.link');
return data.map(element => {
return {
id: this.getRootRelativeOrAbsoluteLink(element, this.url),
title: element.text.trim()
};
});
}

async _getChapters(manga) {
const serieId = manga.id.match(/(\/series\/[^/]+)\//)[1];
const uri = new URL(`${serieId}/full-chapter-list`, this.url);
const request = new Request(uri, this.requestOptions);
const data = await this.fetchDOM(request, 'a[href*="/chapters/"]');
return data.map(element => {
return {
id: this.getRootRelativeOrAbsoluteLink(element, this.url),
title: element.querySelector('span.grow span').textContent.trim(),
language: ''
};
});
}

async _getPages(chapter) {
const uri = new URL(chapter.id, this.url);
const request = new Request(uri, this.requestOptions);

const pageScript = `
new Promise((resolve, reject) => {
setTimeout(() => {
try {
resolve([...document.querySelectorAll('main section img[alt*="Page"]:not([x-show])')].map(img => img.src));
} catch(error) {
reject(error);
}
}, 2500);
});
`;

const data = await Engine.Request.fetchUI(request, pageScript);
return data.map(element => this.getAbsolutePath(element, request.url));
}
}

0 comments on commit f35fa38

Please sign in to comment.