Skip to content

Commit

Permalink
fix title fetch and image fetch in hitomi (#7504)
Browse files Browse the repository at this point in the history
Two observations:
- for some reason a direct DOM fetch from the request to get the title does not work (anymore). This is not related to the fetch but rather to the requested page itself, as the title element to be just gone (reproducable in curl). The suspicion I have is that there might be some javascript run afterwards that populates the title instead, hence resorting to js injection to get the title directly (unfortunate, but better than completely broken).
- the source code on the site for fetching images has changed, updating to be consistent to what is on the site.
  • Loading branch information
noname2noname authored Oct 19, 2024
1 parent e1e16f6 commit 00c304c
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/web/mjs/connectors/Hitomi.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,21 @@ export default class Hitomi extends Connector {
}

async _getMangaFromURI(uri) {
let request = new Request(uri, this.requestOptions);
let data = await this.fetchDOM(request, 'div.gallery h1 a', 3);
let id = uri.pathname.match(/(\d+)\.html$/)[1];
let title = data[0].text.trim();
return new Manga(this, id, title);
const request = new Request(uri, this.requestOptions);
const script = `
new Promise((resolve, reject) => {
setTimeout(() => {
try {
resolve(galleryinfo.title);
} catch(error) {
reject(error);
}
}, 1000);
});
`;
const title = await Engine.Request.fetchUI(request, script);
const id = uri.pathname.match(/(\d+)\.html$/)[1];
return new Manga(this, id, title.trim());
}

async _getMangas() {
Expand All @@ -38,7 +48,7 @@ export default class Hitomi extends Connector {
new Promise((resolve, reject) => {
setTimeout(() => {
try {
let images = galleryinfo.files.map(info => url_from_url_from_hash(galleryinfo.id, info));
let images = galleryinfo.files.map(image => url_from_url_from_hash(galleryinfo.id, image, 'webp', undefined, 'a'));
resolve(images);
} catch(error) {
reject(error);
Expand Down

0 comments on commit 00c304c

Please sign in to comment.