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

403 Error #52

Closed
matsamaaa opened this issue Apr 1, 2023 · 2 comments
Closed

403 Error #52

matsamaaa opened this issue Apr 1, 2023 · 2 comments
Labels
good first issue Good for newcomers

Comments

@matsamaaa
Copy link

Description of bug

When I request the image link it sends it to me but when I click on it I get the Nginx 403 error. When I open the doujin before the image it works but suddenly I can't download the image.
It gives me a 403 error.

Code

doujin.js

const hitomi = require('node-hitomi').default;
const { downloadImage } = require('../../utils/download');
const ids = await hitomi.getIds({
    tags: [
        {
            type: "type",
            name: "doujinshi"
        }, {
            type: "female",
            name: "handjob"
        }
    ] 
})
const gallery = await hitomi.getGallery(ids[0], { includeFiles: true });
const IUR = new hitomi.ImageUrlResolver();
await IUR.synchronize()
const url = IUR.getImageUrl(gallery.files[1], 'avif')
console.log(url)
await downloadImage(url, `${__dirname}/../../assets/`)

download.js

const download = require('image-downloader');
const { SimpleConsole } = require('./errors');

async function downloadImage(url, filepath) {
    const options = {
        url: url,
        dest: filepath,
    };
    await download.image(options)
        .then(({ filename }) => {
            SimpleConsole(`saved to ${filename}`)
        })
        .catch((err) => console.error(err));
}

module.exports = { downloadImage };

And even if I add this code in doujin.js it does not work

await open("https://hitomi.la/reader/2510773.html#3")  //doujin link of the request

Environment

  • Version
    • NodeJS: 18.12.1
    • Package: 7.0.6
@matsamaaa matsamaaa added the bug Something isn't working label Apr 1, 2023
@H2Owater425
Copy link
Owner

H2Owater425 commented Apr 1, 2023

Thank you for using the package and reporting the issue.

However, I found that the issue is not closely related to the package.
The package only provides the URL of the image, and it's up to you to download the actual file.

To help you solving the issue you are experiencing, I want you to notice that Hitomi only allows downloads from their own website.
Therefore, in order to download the file, you need to set the value of the 'Referer' header as the site's URL, as if you were accessing the site directly from your browser.

I hope this information was helpful, and if you have any further problems, please let me know!

@matsamaaa
Copy link
Author

thank you very much, i will continue with this information.

@H2Owater425 H2Owater425 pinned this issue Jan 10, 2024
@H2Owater425 H2Owater425 added good first issue Good for newcomers and removed bug Something isn't working labels Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants