Announcement

#1 2017-04-14 13:51:02

Protheus
Member
2016-10-25
7

Piwigo Refresh

Greetings,

Since i upload all my Android Photos via FolderSync and SSH, they are already on the Server in the right place. I couldn't find a proper Commandline Tool to trigger only the Syncronization of this Incoming Folder to Piwigo. So i have tried too write my own small Script. I have used piwigo_import_tree.pl as inspiration since this is my first try with a Perl Script.

In my case i run the Script via a Cronjob, but maybe later i switch to inotify or anything similar. You can run the Script manually or via Cron like this example:

perl /media/hdd/piwigo_refresh.pl --base_url=http://localhost:81/piwigo/ --user=your_username --password=your_password --directory="absolute_path_to_your_ssh_upload_dir" --caddie=0 --privacy_level=4 --cat=your_category_id --subcat=1

If you find Problems, please let me know. I will try to solve them. I have tested this Script via 2.8.6 and 2.90RC2.

Piwigo URL: http://piwigo.org/ext/extension_view.php?eid=855

Offline

 

#2 2017-04-14 14:24:21

Protheus
Member
2016-10-25
7

Re: Piwigo Refresh

If you want, here is a small Shell Script which uses inotify-tools (install via "apt install inotify-tools" on Ubuntu/Debian) to monitor my Directory (and Subdirs) for Uploads, Delete's, Changes and so on and starts afterwards a Sync.

Code:

#!/bin/bash
monitor_dir="Absolute/Path/To/Monitor/And/Sync"
pwg_user="Piwigo_Username"
pwg_pwd="Piwigo_Password"
base_url="URL To your Piwigo Installation"
script_path="/Absolute/Path/To/The/QuickSync/Script"

while true
do 
inotifywait -r -e modify,attrib,close_write,move,create,delete $monitor_dir && perl $script_path --base_url=$base_url --user=$pwg_user --password=$pwg_pwd --directory=$monitor_dir --caddie=0 --privacy_level=4 --cat=162 --subcat=1
done

You should start the Script to the Background, so that you can close your SSH Session after starting

Offline

 

#3 2018-04-22 17:05:04

darenwelsh
Member
2018-04-22
3

Re: Piwigo Refresh

Thank you for sharing this script. I'm trying to understand the arguments. Can you explain the meaning and options for "caddie", "privacy_level", "cat", and "subcat"? Also, in the Piwigo admin menu for sync, it offers to perform a simulation. I've never done this but it seems that you can try it out without messing up your database. Is there a way to test out your script without committing changes to the database?

Offline

 

#4 2018-04-22 17:49:44

darenwelsh
Member
2018-04-22
3

Re: Piwigo Refresh

Trying to answer at least part of my questions ...

By viewing the source of the sync form in the Piwigo admin menu, I found the privacy levels:

Code:

<option value="8">Admins</option>
<option value="4">Admins, Family</option>
<option value="2">Admins, Family, Friends</option>
<option value="1">Admins, Family, Friends, Contacts</option>
<option value="0" selected="selected">Everybody</option>

It looks like if you set caddie to "1" then it puts these new images into your basket.

I see how the categories are really just the album/folder names. But does this mean you have to perform at least one manual sync to generate the cat number first before trying to run your script with the cat specified as an argument?

Offline

 

#5 2018-04-22 18:26:13

darenwelsh
Member
2018-04-22
3

Re: Piwigo Refresh

Working to answer more of my questions ...

I added a new directory to test things out. I did this via SSH to the server. I added one photo in that directory. Then I used the Piwigo web admin interface to run sync. It added that new directory and single image. After that was done, I could see the new directory's "cat" on the album admin page. It's called the "Numeric identifier" on that page. Or you can view the source of the sync page to get it. Once all that was in place, I could then run your script and specify that new cat number.

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact