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 HentaiHand : rewrite website #7130

Closed
wants to merge 1 commit into from
Closed
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
49 changes: 14 additions & 35 deletions src/web/mjs/connectors/HentaiHand.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,27 @@ export default class HentaiHand extends Connector {
super.label = 'HentaiHand';
this.tags = [ 'hentai', 'multi-lingual' ];
this.url = 'https://hentaihand.com';
this.requestOptions.headers.set('x-referer', this.url);
}

async _getMangaFromURI(uri) {
let request = new Request(uri, this.requestOptions);
let data = await this.fetchDOM(request, 'div#info-block div#info h1');
let id = uri.pathname + uri.search;
let title = data[0].innerText.trim();
return new Manga(this, id, title);
const slug = uri.href.split('/').pop();
const apiUrl = new URL('/api/comics/' + slug, this.url);
const data = await this.fetchJSON( new Request(apiUrl));
return new Manga(this, data.slug, data.title.trim());
}

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

async _getChapterList(manga, callback) {
try {
callback(null, [ Object.assign({ language: '' }, manga) ]);
} 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#thumbnail-container a.gallerythumb source');
let pageList = data.map(element => {
let path = element.dataset['src'].split('/');
let file = path.pop();
path.push('full', file.replace('t.', '.'));
return path.join('/');
});
callback(null, pageList);
} catch(error) {
console.error( error, chapter );
callback( error, undefined );
}
async _getPages(chapter) {
const apiUrl = new URL(`/api/comics/${chapter.id}/images`, this.url);
const data = await this.fetchJSON( new Request(apiUrl));
return data.images.map(page => this.createConnectorURI(page.source_url));
}
}
}
Loading