Under older versions / installs of Piwigo, I had a script that I hosted externally and called regularly via a CRON job that would visit the Piwigo site, log in as a user, and visit every image that didn't have a thumbnail in order to generate those thumbnails. I'd schedule the job to run overnight during off-peak hours, so that when I added new photos to my site, the thumbnails would be generated overnight and the site would be faster to load when browsing.
I recently moved my home setup to a whole new system. Because of the change in my home server, I had to set the script up as new on the new host. At about the same time, Piwigo 15 came out. The script is no longer working, and I am not sure if the issue is that I am missing something in my new home setup, or Piwigo 15 changed something that breaks the script.
Script, and the output / error message, are below - any input on how to adjust the script would be appreciated.
# Make a login in Piwigo named "cron" and set a strong password, chage the text REDACTED (one instance on Line 9) in this script to the password # # Nightly CRON job (run as apps): 1 0 * * * /mnt/data/apps/piwigo/scripts/piwigo-thumb-generate.sh set -e cd /mnt/data/apps/piwigo/scripts wget --keep-session-cookies --save-cookies cookies.txt --delete-after --post-data="username=cron&password=REDACTED" "http://photos.aiskon.net/ws.php?format=json&method=pwg.session.login" wget --load-cookies cookies.txt -nv -O missing.json "http://photos.aiskon.net/ws.php?format=json&method=pwg.getMissingDerivatives" while [ `wc -c missing.json | awk '{print $1}'` -gt 50 ] do sed -e 's/[\\\"]//g' \ -e 's/{stat:ok,result:{next_page:[0-9]*,urls:\[//' \ -e 's/{stat:ok,result:{urls:\[//' \ -e 's/\]}}/\n/' \ -e 's/,/\n/g' \ -e 's/\&b=[0-9]*//g' missing.json | \ while read line ; do wget -nv -O /dev/null $line done wget --load-cookies cookies.txt -nv -O missing.json "http://photos.aiskon.net/ws.php?format=json&method=pwg.getMissingDerivatives" done rm cookies.txt rm missing.json
And the output:
TrueNAS% ./piwigo-thumb-generate.sh --2024-11-07 20:13:41-- http://photos.aiskon.net/ws.php?format=json&method=pwg.session.login Resolving photos.aiskon.net (photos.aiskon.net)... 10.0.0.240, fe80::7229:c312:f1c4:dc6a Connecting to photos.aiskon.net (photos.aiskon.net)|10.0.0.240|:80... connected. HTTP request sent, awaiting response... 200 OK Length: unspecified [text/plain] ws.php?format=json&method=pwg.session.login.tmp: Bad file descriptor Cannot write to ‘ws.php?format=json&method=pwg.session.login.tmp’ (Bad file descriptor). Cannot open cookies file ‘cookies.txt’: Permission denied TrueNAS%
Offline
The first wget command attempts to write the document to a file named
ws.php?format=json&method=pwg.session.login.tmp
in the current directory, which for some reason it can't due to directory permissions or file system limitations.
Try specifying an output file name; as the output isn't needed here it could be -O /dev/null in which case you also can omit the --delete-after option.
Offline
That was the hint I needed - after changing some permissions, I can run it manually from an elevated prompt.
Thank you!
-Geoffrey
Offline
Hi GJSchaller!
Thank you for the script, I utilized it on my Synology NAS ;)
However, I got a problem: for two photos in my collection 2small derivatives can not be created - no idea why. I tried to run pwg.getMissingDerivatives manually, and still no results. I don't really care about those two, BUT they make your script running infinitely! Only when I created falke derivatives and put them in the proper folder, it stopped.
Now I am afraid to run this script automatically :(
Would it be possible to check somehow, that pwg.getMissingDerivatives returns the same output again and again, and stop the script? I mean, save the output (or only its size?) and compare the next iteration with it?
Sorry, I am not a programmer, don't know proper words to describe it ;)
Last edited by neon (2025-05-16 19:27:38)
Offline
Unfortunately, I did not make the script - I found it online a very long time ago. One of the Piwigo Devs might be able to help, but I am not a programmer either.
Offline