Skip to content

Commit

Permalink
[ehentai] fixed image link extraction (#993)
Browse files Browse the repository at this point in the history
fixed pagination for gallery
  • Loading branch information
ronny1982 authored Jan 26, 2020
1 parent e75b478 commit e7d2402
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions src/web/mjs/connectors/EHentai.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,32 @@ export default class EHentai extends Connector {
return new Manga(this, id, title);
}

async _getMangaList(callback) {
async _getMangas() {
let msg = 'This website does not provide a manga list, please copy and paste the URL containing the images directly from your browser into HakuNeko.';
callback(new Error(msg), undefined);
throw new Error(msg);
}

async _getChapterList(manga, callback) {
try {
let chapterList = [ Object.assign({ language: '' }, manga) ];
callback(null, chapterList);
} catch(error) {
console.error(error, manga);
callback(error, undefined);
}
async _getChapters(manga) {
return [ Object.assign({ language: '' }, manga) ];
}

async _getPageList(manga, chapter, callback) {
try {
let request = new Request(this.url + chapter.id, this.requestOptions);
let data = await this.fetchDOM(request, 'div#gdt a');
let pageList = data.map(element => this.createConnectorURI(this.getAbsolutePath(element, request.url)));
callback(null, pageList);
} catch(error) {
console.error(error, chapter);
callback(error, undefined);
async _getPages(chapter) {
let pageLinks = [];
let request = new Request(new URL(chapter.id, this.url), this.requestOptions);
let data = await this.fetchDOM(request, 'div.gtb table.ptt td:not(:first-child):not(:last-child) a');
for(let element of data) {
let uri = this.getAbsolutePath(element, request.url);
data = await this.fetchDOM(new Request(uri, this.requestOptions), 'div#gdt a');
let pages = data.map(element => this.createConnectorURI(this.getAbsolutePath(element, request.url)));
pageLinks.push(...pages);
}
return pageLinks;
}

async _handleConnectorURI(payload) {
let request = new Request(payload, this.requestOptions);
let data = await this.fetchDOM(request, 'source#img, a[href*="fullimg.php"]');
let response = await fetch(this.getAbsolutePath(data[1], request.url), this.requestOptions);
let response = await fetch(this.getAbsolutePath(data[0], request.url), this.requestOptions);
if(!response.headers.get('content-type').startsWith('image/')) {
response = await fetch(this.getAbsolutePath(data[0], request.url), this.requestOptions);
//console.log('Download Optimized:', response.url);
Expand Down

0 comments on commit e7d2402

Please sign in to comment.