ccloli / E-Hentai-Downloader

Download E-Hentai archive as zip file
GNU General Public License v3.0
1.84k stars 138 forks source link

wrong mime 问题 #153

Closed Dreamodd closed 4 years ago

Dreamodd commented 4 years ago

您好, 以前使用的时候都是很正常的,但是现在出现图片文件下载完成时报错“wrong mime”。 使用的浏览器是Google Chrome。 已经彻底清理过cookies,但是依然有这个问题。

kolshix commented 4 years ago

same problem

SECOND24 commented 4 years ago

我也是一樣的問題
早上是正常的 今天下午就出現 Failed! (Wrong MIME)

Web Browser:Google Chrome 80.0.3987.122 64 bit Tampermonkey:v4.9

shining730 commented 4 years ago

下午3点左右出现这个情况,还好影响的只是下载原图的功能,把脚本设置里面的“Force download resized image (never download original image”功能勾选,下载压缩之后的图片还是可以的。

ccloli commented 4 years ago

I'm not sure should it be a bug, it's due to E-Hentai server returns an invalid Content-Type header. Like in this case, the valid Content-Type should be image/png, but E-Hentai server returns png only.

image

Looks like only original images are affected, if the image loads from H@H network, it gives the corrected header Content-Type: image/jpeg.

Dreamodd commented 4 years ago

我找到了一个解决的办法: 将原先的 mime[0] !== 'image' 调整为 mime[0] !== 'image' && mime[0] !== 'jpg' && mime[0] !== 'png' && mime[0] !== 'jpeg' && mime[0] !== 'gif' && mime[0] !== 'bmp' && mime[0] !== 'tif' 目前看还是可以的

ccloli commented 4 years ago

The script heavily relies on the Content-Type header, as it's used to verify the file is valid or not. I'm not sure should I fix this case, but at this time, you can manually modify the script to skip the verification, by replacing else if (mime[0] !== 'image') { with else if (false && mime[0] !== 'image') { at line 13230.


我不太确定这个算不算 bug,因为这个是 E-Hentai 的服务器的问题。E-Hentai 的图片服务器错误地返回了 Content-Type ,例如上面这个图片,理论上它应该是 image/png,但是服务器返回的是 png

似乎这个问题只出现在原始图片服务器上,如果图片是从 H@H 网络加载的话,Content-Type 是合法的 image/jpeg

这个脚本非常依赖 Content-Type 这个响应头来判断返回的文件是否合法(比如可以用来过滤掉代理服务器返回的错误文件、image limits 耗尽后的警告文件等),所以我不太确定我应不应该针对性修复。就目前而言,如果需要绕过脚本的校验,请将脚本第 13230 行的 else if (mime[0] !== 'image') { 替换为 else if (false && mime[0] !== 'image') { 来绕过 MIME 检查(如果这一行找不到,可以借助 Ctrl + F)。

image

kolshix commented 4 years ago

thanks! works

I also renamed the file "info.txt" to "z_info.txt" The names of the images are different and the file is often located in the middle of the list. If "z_info.txt" the file is 99% located at the end.

ccloli commented 4 years ago

The "bug" should be "fixed", v1.31.6 will use @Dreamodd's suggestion to work around with the invalid Content-Type header, it should pass most cases and won't break the original expectations. But if you find some images still cannot be downloaded, please paste the page URL here and let me know.


这个“bug”应该在刚刚发布的 v1.31.6 中“修复”了,目前考虑采用了 @Dreamodd 的方案来绕过服务器返回的错误响应头。现在的代码应该可以匹配大多数的文件格式,理论上也不会影响原来的逻辑。不过因为只是判断了常用的文件格式,所以如果一些图片仍然无法下载,请考虑将页面地址贴在此处。

kanachi00 commented 4 years ago

thank you so much it works now!

wenheyuran commented 4 years ago

你好,现在使用的新版本还是会出现wrong mime问题。我使用的公众账号,不知道是否有关系

ccloli commented 4 years ago

@wenheyuran 已在表站与里站测试无问题,请确认目前是否可以正常浏览页面并直接下载图片,并考虑提供一下下载时控制台的输出日志(F12 -> Console,URL 之类的可以去掉),里面应该会有输出 content-type 之类的信息

ccloli commented 4 years ago

你好,现在使用的新版本还是会出现wrong mime问题。我使用的公众账号,不知道是否有关系

@wenheyuran 此问题可能与 #155 有关,估计是此账号已被封禁