I‘d like to create a realtime database of face images of this homepage beeing saved automatically in a FOLDER DAT:
as this website has two buttons, one „refresh“ and one „download image“, I d like to automate refresh and download, to create a real time updating image folder for a presentation of these images on touchdesigner.
is it possible to do so via the WEB RENDER TOP or WEBSOCKETS?
if yes, how would a possible approach be?
How can I automate this process to get a infinite database automatically refreshing?
the folder could be limited to 20 Images and the would add always new ones and erase the oldest ones (stack principle).
this is certainly possible. But this post of mine you linked to above is very old, these days there are better methods.
Anyway in your case it’s pretty easy. If you look in the sourcecode of the site, you’ll see clicking the reload button calls an reImage() function, which generates an url like this:
?new='+timeInMs+imageType
where timeInMs is the javascript Date.now(), meaning milliseconds since epoch, and imageType is “auto” for persons.
So to translate into Python use this to generate a valid url:
import time
millisec = int(time.time() * 1000)
url = f"https://this-person-does-not-exist.com?new={millisec}auto"
Loading that url gives you a page with some JSON containing the new image url.
Very rough example attached, click the button to load new image in the Movie File In TOP.
Using an Info CHOP you can read the fully_pre_read member of the Movie File In TOP so see when downloading is complete, and trigger a saving to disk action for instance…
@nettoyeur Hey, sorry to bother you again.
for some reason it doesnt work anymore. it says:
error: Failed to parse DAT as JSON in the “JSON DAT”.
it seems, that the homepage this-person-does-not-exist.com has made some changes as well. maybe thats why?
it might have changed a bit - but diving a bit deeper into the javascript function reveals that you can nicely control the parameters and retrieve a json that contains the url.
I packaged this all up into a component.
It looks like there is also a placeholder for this to work for cars, cats, horses and artwork - but I couldn’t get that to work, hence the parameter is disabled.