z411 / trackma

Open multi-site list manager for Unix-like systems. (ex-wMAL)
https://z411.github.io/trackma
GNU General Public License v3.0
775 stars 81 forks source link

kitsu image URLs have an expiration time #669

Open FichteFoll opened 1 year ago

FichteFoll commented 1 year ago

Via #665, it appears that URLs to images from kitsu have an expiration time that prevents us from loading and displaying them on-demand in the UI.

Excerpt of a response:

        "posterImage": {
            "original": "https://kitsu-production-media.s3.us-west-002.backblazeb2.com/anime/44834/poster_image/def4bedfad0f1d8b97ad7d7fe83e8b92.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=002d6013655cdc00000000003%2F20230114%2Fus-west-002%2Fs3%2Faws4_request&X-Amz-Date=20230114T120944Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=b0b38c983a05de4e8375f2b1f0ce46a48042d037cb8fa284a6edd40ae745331c",
            "meta": {"dimensions": {}},
        },

Response when accessing this URL:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Error>
    <Code>UnauthorizedAccess</Code>
    <Message>Request has expired given timestamp: '20230114T120944Z' and expiration: 900</Message>
</Error>

We'll need to think of something different to get re-usable images. Either re-request a new URL whenever we need one and the previous one has expired or cache the thumbnails aggressively on disk. I'd prefer the former, combined with caching if that's not happening already (didn't check).

Eiji7 commented 2 weeks ago

Hi, not sure if it's brilliant or stupid solution, but I found that simply removing all query parameters from url fixes the problem. 🤔

Not sure if it's a proper way as they still have an issue in their search results, but for all links I found and also in DOM of Kitsu search applying this workaround fixes the issue. 🚀

Examples

Here is a screenshot of original search results: search results containing src with query parameters and here is a screenshot of the same search results when updated src attribute: search results containing src without query parameters

Similarly here is an original image using a link copied from your comment: image link with query parameters

and here is the same image, but without query parameters in it's url: image link without query parameters

As you can see this applies to up-to-date data as well as the urls having many years. If I can help with something else just let me know, but my replies may be late because of arm injury. 💪