Erisa/download-image

Downloading Pixiv images doesn't work on Chromium

Erisa opened this issue · 3 comments

Erisa commented

Downloading images from Pixiv doesn't work on Chromium-based browsers (Chrome, Edge, etc.) because of "No permission".
Tested on Chrome Dev and Edge Dev
image
Likely has something to do with Pixiv requiring auth for image access, unclear if this can be worked around or not.

Pixiv works fine on Firefox.

Erisa commented

This now happens in Firefox as well :(

Phles commented

You just need to add some headers to authenticate to pixiv.
Here's the curl headers for that:

curl https://i.pximg.net/c/250x250_80_a2/img-master/img/2020/05/18/13/19/42/81659864_p0_square1200.jpg \
   	-H "Referer: https://www.pixiv.net/" \
       -H "Sec-Fetch-User: ?1" \

It's probably just checking to see if you're a bot, so don't abuse this.

Erisa commented

Thank you for the information!

The Referer header seemed to do the trick, it now works perfectly on Firefox.
Setting Sec-Fetch-User was apparently disallowed by the downloads extension API, but it seems it wasn't necessary (Maybe the browser is setting it already?)

On Chromium however, even setting Referer is too much for it, giving

Unchecked runtime.lastError: Unsafe request header name

Which as far as I can tell is because Chromium thinks I shouldn't be allowed to a modify that header here. Not sure what else to do there, unless Chromium changes its behaviour and allows it.