Closed Vipitis closed 2 months ago
Commonly used location would be:
Unix
~/.cache/shadertoy
(or $XDG_CACHE_HOME/shadertoy
if set)
macOS
~/Library/Caches/shadertoy
Windows
%LOCALAPPDATA%\shadertoy\Cache
This mirrors what tools like pip and poetry use
Imageio has a similar utility. Here's the code that does the downloading: https://github.com/imageio/imageio/blob/master/imageio/core/fetching.py. It uses a progress-bar (implemented here), which may be a bit much for this use-case, but perhaps it can serve as inspiration, especially regarding edge-cases like the local file being in use (on Windows), etc.
This was mentioned in #25
Main idea is to avoid downloading the same media (currently just images, maybe additional resources later) over and over again. Should speed things up and avoid duplicate requests. Media isn't included in the repo, it's build dynamically. The website only offers a quite limited number of default media. Perhaps there could be an init function to grab all of it instead.
This implementation is really crude, as media is cached to a folder in the library, which I don't think is the proper solution. I will look at some other examples.