H2Owater425 / node-hitomi

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

getImageUrl is throwing 403 #35

Closed Shompi closed 2 years ago

Shompi commented 2 years ago

Any chance of getting this fixed again or is not worth the time? :(

H2Owater425 commented 2 years ago

I'm on my way to fix it, since putting Hitomi's code directly to this package will make it heavier, I made compact way to solve this problem. Because of my school's graudation, I have no time now, but I think I can release a new release of this package today(in KST). Sorry, wait for some time please.

Shompi commented 2 years ago

All good, take your time and good luck on your graduation!

On Thu, Jan 6, 2022, 6:26 AM H2Owater425 @.***> wrote:

I'm on my way to fix it, since putting Hitomi's code directly to this package will make it heavier, I made compact way to solve this problem. Because of my school's graudation, I have no time now, but I think I can release a new release of this package today(in KST). Sorry, wait for some time please.

— Reply to this email directly, view it on GitHub https://github.com/H2Owater425/node-hitomi/issues/35#issuecomment-1006407254, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACN2MR3GAEXQUQUW4XZ2LDLUUVN3NANCNFSM5LLX7SQQ . You are receiving this because you authored the thread.Message ID: @.***>

H2Owater425 commented 2 years ago

Thank you for words of blessing :) Also, I got good news for you. I've just tested new code and it worked completely fine! Below is the test result, and please check the new version when it comes out! (In addition, I think your 403 problem occurred because of Hitomi's request rule. You must set Referer header to 'https://hitomi.la' if you want a normal response) image

Shompi commented 2 years ago

Ok so, I got the latest version of the package (5.0.4) through npm. I dont know if im doing something wrong or if theres something wrong with hitomi but what im doing right now is the following:

Im getting a Hitomi.Gallery with this by providing an Id

const result = await Hitomi.getGallery(hitomiId, { includeFullData: true, includeFiles: true }).catch(console.log);

then to get the images im passing one of result.files objects to getImageUrl() like this, and logging it to the console

const imageUrl = Hitomi.getImageUrl(result.files[1], result.files[1].extension);

I do get a url's back (this is from some other tests but using the latest version too) image and when I open them in the browser i just get 403 forbidden errors.

I think it works sometimes because im pretty sure I was able to visualize one of the images but after that it just started throwing 403s again.

If you have any idea of whats happening i would be really glad to hear it Also I dont think I quite get what you mean setting the referer header to 'hitomi.la' since I dont see any method on your library to do that.

H2Owater425 commented 2 years ago

Every http(s) requests have key-value data called header (I guess you will know this, but anyway)

So basically, Hitomi provides its image resources to its own services only, and they judge the origin of the request with a value of key 'Referer' in the header which is automatically filled when you use the browser.

Since your browser fills that data with its own, you need a third-party extension for you to modify the header to see them properly with your browser. Or you can just use requesting program like Postman.

In fact, the purpose of providing the image url is to download, not see them directly from the browser. (Because it requires a lot of things) But I hope your problem will be solved, thanks for using my package!

Shompi commented 2 years ago

Oh I understand now thanks you so much for explaining it to me! I guess ill download the images and see what can I do then.

Thanks you for this library! you can close this issue.