HDoujinDownloader / HDoujinDownloader

An easy-to-use manga and dōjinshi downloader supporting 800+ different websites
https://doujindownloader.com
473 stars 20 forks source link

Misnamed images on NHentai #346

Open ale5000-git opened 1 month ago

ale5000-git commented 1 month ago

Jpg files are misnamed as png. Example: nhentai.net/g/348878/

Is it possible for the app to read the start of the image to see if there is the JFIF marker and then rename to jpg? It is possible to do it inside LUA but I think it would be better to detect it directly inside the app so it can work from all websites.

Example of detection code (the code is in Python but it isn't difficult to convert it): https://stackoverflow.com/a/51931778

HDoujinDownloader commented 1 month ago

You're right, I was able to reproduce this. By default, it will attempt to fix the file extension based on the Content-Type header (which is usually correct), but even the header is incorrectly set to image/png here.

If you go to Tools > General settings, under "Advanced settings", there's a Downloads.ChangeFileExtensionToMatchSignature setting you can enable that does exactly what you're suggesting. It will detect a wide variety of image formats.

Another user reported a different website sending an incorrect Content-Type header recently, too. If this is a common occurance I may just have to enable that setting by default.