H2Owater425 / node-hitomi

Hitomi.la api for Node.js
https://npm.im/node-hitomi
MIT License
15 stars 2 forks source link

Subdomain mismatch on the url of the image #43

Closed bass9030 closed 2 years ago

bass9030 commented 2 years ago

Environment

Code

const hitomi = require('node-hitomi').default;

const gallery hitomi.getGallery(1434389).then(image => {
    const isThumb = true; // same to false
    const ext = (isThumb ? (image.hasAvif ? 'avif' : image.extension) : (((image.hasAvif) ? 'avif' : ((image.hasWebp) ? 'webp' : image.extension))));
    const url = hitomi.getImageUrl(image, ext, {isThumbnail: isThumb})
    console.log(url); // it return wrong url
})

I try getImageUrl to gallery No 1434389, and it return wrong url. I also try to connect url with Referer header, it same. So i think Hitomi uses different image routing rules according to the presence of avif.

H2Owater425 commented 2 years ago

Thank you for creating an issue to inform me a bug! I found some mistakes in your source code, but I'll assume that you used hitomi.getGallery's result named image as Gallery['files'][number] Nevertheless, I noticed some structural changes in Hitomi's image system that didn't affect just limited galleries And this time, I guarantee you that you will soon find the new version of this package (not like before) Again, thanks for your contribution!

이슈 생성을 통해 버그를 보고해주셔서 감사합니다. 주신 코드에서 조금의 실수를 발견했지만 hitomi.getGallery의 결과인 image로 망명되는 인수를 hitomi.Gallery['files'][number]로써 사용하셨으리라 추정하겠습니다 그럼에도 불구하고, 한정된 겔러리에만 작용하는 것이 아닌 히토미 이미지 시스템의 구조적인 변화를 확인했습니다 그리고 이번에는 금방 새로운 버전을 내놓을 것을 장담드립니다 (이전과는 다르게 말이죠) 다시한번, 기여에 감사드립니다!

H2Owater425 commented 2 years ago

I just released a new release, please check it out for the package's new version!

방금 새 버전를 출시했습니다, 확인해주세요!

bass9030 commented 2 years ago

I try new version, but hitomi.getImageUrl is work with only isThumbnail: true option. Option isThumbnail: false returns a page that still does not exist.

새 버전을 시도해봤지만 isThumbnail이 true일때만 작동합니다. isThumbnail가 false일때는 여전히 존재하지 않는 링크를 줍니다.

H2Owater425 commented 2 years ago

This requires some explanation Before like a month ago, they used a kind of static method to get the url of the image But after the change, they made an external element(ltn.hitomi.la/gg.js) that can alter the url of the image so that they can block the outsiders' usage One good thing is I'm finding a method to fix this problem by making hitomi.getImageUrl flexible (#36) Anyway, as a temporary measure, I'll release a new version of this package

이건 설명이 좀 필요한데요 한 한 달 쯤 전에는 사진 링크를 얻는데 고정된 방법이 사용됐습니다 근데 언젠가부터 외부인의 사용을 막기 위해서인지 외부 요소(ltn.hitomi.la/gg.js)가 사진 링크를 변경할 수 있게 바꿔놨더라고요 하나 희소식은 제가 hitomi.getImageUrl을 변화에 유연하게 반응할 수 있도록 바꾸는 방법을 찾고 있다는겁니다 아무튼 임시방편으로 새 버전을 출시하겠습니다

bass9030 commented 2 years ago

Oh okay. i will wait it 아 그렇군요 알겠습니다!

H2Owater425 commented 2 years ago

The new version has came out, please check it out! In this version, you can always synchronize with Hitomi to get proper url of image I'll show you some example code for new version down below in javascript

const hitomi = require('node-hitomi').default;

(async function () {
    const imageUrlResolver = new hitomi.ImageUrlResolver();

    await imageUrlResolver.synchronize();

    console.log(imageUrlResolver.getImageUrl((await hitomi.getGallery(/* any number */))['files'][0], 'webp'));
})();

새로운 버전이 출시했습니다, 확인해주세요! 이 버전에서는 제대로된 이미지 url을 얻기 위해 언제든지 히토미와 동기화할 수 있습니다 아래에 자바스크립트로 새로운 버전을 위한 예시 코드를 보여드리겠습니다 (상단에 위치)

ayenz commented 2 years ago

Hello, I'm still getting "some" wrong image url (404) even I already updated node-hitomi package to latest version (7.0.1)

My Code

const hitomi = require('node-hitomi').default;

(async function () {
    const imageUrlResolver = new hitomi.ImageUrlResolver();
    await imageUrlResolver.synchronize();
    const files = (await hitomi.getGallery(2163268)).files;

    files.forEach(file =>{
        console.log(imageUrlResolver.getImageUrl(file, 'webp'));
    })
})();

I got right image for first url, but 404 for second url and so on (random). I already tried webp or avif but still no luck. Any help is appreciated. Thank you.

H2Owater425 commented 2 years ago

Hello, I'm still getting "some" wrong image url (404) even I already updated node-hitomi package to latest version (7.0.1)

My Code

const hitomi = require('node-hitomi').default;

(async function () {
    const imageUrlResolver = new hitomi.ImageUrlResolver();
    await imageUrlResolver.synchronize();
    const files = (await hitomi.getGallery(2163268)).files;

    files.forEach(file =>{
        console.log(imageUrlResolver.getImageUrl(file, 'webp'));
    })
})();

I got right image for first url, but 404 for second url and so on (random). I already tried webp or avif but still no luck. Any help is appreciated. Thank you.

First of all, thank you for reporting the issue! I'll soon start to examine for that problem, please wait until I find whats wrong.

H2Owater425 commented 2 years ago

@ayenz I released another version, please check it out! If you find new bugs, I would like to ask you to report it again. Thank you for your contribution to the package!

ayenz commented 2 years ago

Thank you for your hard work! I already tested the latest version and now work like a charm. I'll report if any weird bugs happen. Thank you so much!

ayenz commented 2 years ago

And it's not working again. It's a cat and mouse game omg. I got 404 for all image urls (avif or webp) using same code for testing latest version (7.0.2). Sorry for taking your time.

H2Owater425 commented 2 years ago

Let me check the irregular, once more. Give me some time, and I'll release a new version.

ayenz commented 2 years ago

Don't worry, just take your time. Looking forward for new version! Cheers!

H2Owater425 commented 2 years ago

@ayenz Okay, I just released the new version. Just in case you're curious, the reason why the package didn't work was Hitomi's addition of another external element that can alter the url of the image. Anyway, as always, thank you for using and contributing to the package!

ayenz commented 2 years ago

Updated to latest version, now it's working. It's hard to maintain code for hitomi, even tachiyomi extension for hitomi was already dead. Thank you for your hard work and make this happen!