Skip to content

Commit

Permalink
Add NHentai.Com (#5559)
Browse files Browse the repository at this point in the history
* Add NHentai.Com

Fixes #2308

* Add files via upload
  • Loading branch information
MikeZeDev authored and Sheepux committed Mar 26, 2023
1 parent eed8611 commit 860a640
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
Binary file added src/web/img/connectors/nhentaicom
Binary file not shown.
38 changes: 38 additions & 0 deletions src/web/mjs/connectors/NHentaiCom.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import Connector from '../engine/Connector.mjs';
import Manga from '../engine/Manga.mjs';

export default class NHentaiCom extends Connector {

constructor() {
super();
super.id = 'nhentaicom';
super.label = 'NHentai.Com';
this.tags = [ 'hentai' ];
this.url = 'https://nhentai.com';
}

async _getMangas() {
let msg = 'This website provides a manga list that is to large to scrape, please copy and paste the URL containing the images directly from your browser into HakuNeko.';
throw new Error(msg);
}

async _getChapters(manga) {
return [ Object.assign({language: '' }, manga) ];
}

async _getPages(chapter) {
const uri = new URL(`/api/comics/${chapter.id}/images`, this.url);
const request = new Request(uri, this.requestOptions);
const data = await this.fetchJSON(request);
return data.images.map(el => {
return el.source_url;
});
}

async _getMangaFromURI(uri) {
const slug = uri.pathname.split('/').pop();
const request = new Request(new URL(`/api/comics/${slug}`, this.url), this.requestOptions);
const data = await this.fetchJSON(request);
return new Manga(this, data.slug, data.title);
}
}

0 comments on commit 860a640

Please sign in to comment.