eight04 / image-picka

A Firefox/Chrome extension helping you download images.
MIT License
161 stars 19 forks source link

Cannot download images from deviantart #333

Closed vigilantesculpting closed 9 months ago

vigilantesculpting commented 11 months ago

I am using the latest image-picka 0.16.1, on Firefox 115.0.2 (64-bit) running on macOS 12.6.7. As of yesterday, I cannot seem to easily download images from deviantart.com anymore. Other websites, such as artstation.com and pinterest still work fine.

Steps to reproduce:

  1. go to deviantart.com
  2. open an image
  3. click on the pop-up download button

Expected result: the image should download in the background. Observed result: Firefox displays a pop-up notification saying "SERVER_BAD_CONTENT", and the download fails.

Workaround: I can work around this issue by right-clicking on the image and selecting "open in a new tab". Image-picka then works on the newly opened image, albeit without the context information to save the image in the right subfolder.

Details:

I've built the latest master branch using npm, and debugged it in Firefox. What seems to happen is that the url of the image is somehow changed, and this results in a bad response from the server.

For example, this image: https://www.deviantart.com/morxx/art/Hellion-489441231 will have an tag that has a src attribute, as well as a srcset attribute. The srcset attribute has 5 entries, for varying sizes of the image content. Image-picka seems to choose the correct (highest resolution) source image url. However, instead of the actual url https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/e535ddb0-54f4-4b05-b632-4e002ee0f15e/d83ef9r-66ed9f23-eae0-4bf7-8994-b9647962cb3e.jpg/v1/fill/w_1240,h_644,q_70,strp/hellion_by_morxx_d83ef9r-pre.jpg?token=eyJ0eXAiOiJKV1QiLCJhbGci...Sia419pj9LdNX54Cnt964jQCc it instead ends up with a transformed url that looks like this: https://www.deviantart.com/morxx/art/strp/hellion_by_morxx_d83ef9r-pre.jpg?token=eyJ0eXAiOiJKV1QiLCJhbGc...Sia419pj9LdNX54Cnt964jQCc

So everything appears in order, except for the first part of the url, where https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/e535ddb0-54f4-4b05-b632-4e002ee0f15e/d83ef9r-66ed9f23-eae0-4bf7-8994-b9647962cb3e.jpg/v1/fill/w_1240,h_644,q_70,strp is swapped out for https://www.deviantart.com/morxx/art/strp

I don't know who is responsible for the url swap, I am still debugging this.

Thanks as always for a great tool! Chris

bumbaras commented 9 months ago

Confirmed - Picka can't download anything (except some few common images like thumbnails in background, not related to the main content). But images can be downloaded without issues with PPM and save image as directly in browser.

And I think there is one thing author could expand addon - pictures which failed to be recognized are symbolized with small red rectangle, focused with mouse the link to source appears but there is no way to copy the link to clipboard. It only appears as tooltip (at least in Firefox). It would be good to add option to copy these links. Button "copy urls" doesn't work for the failed images.

eight04 commented 9 months ago

https://github.com/eight04/image-picka/blob/9a71160c25788978ba264ad34cf4e5cff24a919d/src/lib/image-util.js#L19 There is a bug when parsing srcset if there is a comma , in the URL. Need a better logic to parse srcset.

https://html.spec.whatwg.org/multipage/images.html#image-candidate-string