Hello,
I'm trying to synchronize piwigo gallery automatically..it looks its working
wget "https://host.com/gallery/admin.php?page=site_update&site=1" --user=user --password="password" --no-check-certificate -O output.html
(this is possible because im using http authentication)
but not really - synchronization is not done and in output html one can see synchronization page without any changes
im not really a web developer so im probably missing something :). At the end is form i used as inspiration for wget command. It looks all variables are set by hidden input elements. But there has to be still something missing.
Thank a lot ;)
Radim
<form name="QuickSynchro" action="./admin.php?page=site_update&site=1" method="post" id="QuickSynchro" style="display: block; text-align:right;">
<div>
<input type="hidden" name="sync" value="files" checked="checked" />
<input type="hidden" name="display_info" value="1" checked="checked" />
<input type="hidden" name="add_to_caddie" value="1" checked="checked" />
<input type="hidden" name="privacy_level" value="0" checked="checked" />
<input type="hidden" name="sync_meta" checked="checked"/>
<input type="hidden" name="simulate" value="0" />
<input type="hidden" name="subcats-included" value="1" checked="checked"/>
</div>
<div class="bigbutton">
<span class="bigtext">Quick Local Synchronization</span>
<input type="submit" value="" name="submit">
</div>
</form>
Offline
[Forum, topic 11924] Automatic synchronization? the user gave no feedback about he did it.
Sorry for the late reply worwan, your topic is very interesting and thanks to my involvement in pLoader and piwigo_remote.pl, I've coded a much cleaner solution, inspired from your wget script. Instead of wget, let's write a small Perl script (oh yes, just like piwigo_remote.pl):
#!/usr/bin/perl # perl remote_sync.pl --base_url=http://localhost/piwigo/dev/branches/2.0 --username=plg --password=plg use strict; use warnings; use LWP::UserAgent; use Getopt::Long; my %opt = (); GetOptions( \%opt, qw/ base_url=s username=s password=s / ); our $ua = LWP::UserAgent->new; $ua->agent('Mozilla/remote_sync.pl'); $ua->cookie_jar({}); $ua->default_headers->authorization_basic( $opt{username}, $opt{password} ); my $form = { method => 'pwg.session.login', username => $opt{username}, password => $opt{password}, }; my $result = $ua->post( $opt{base_url}.'/ws.php?format=json', $form ); # perform the synchronization $form = { 'sync' => 'files', 'display_info' => 1, 'add_to_caddie' => 1, 'privacy_level' => 0, 'sync_meta' => 1, # remove this parameter, turning to 0 is not enough 'simulate' => 0, 'subcats-included' => 1, 'submit' => 1, }; $result = $ua->post( $opt{base_url}.'/admin.php?page=site_update&site=1', $form ); use Data::Dumper; print Dumper($result);
With this script you don't need to have HTTP basic authentication (but it also works with it) and you know what? it just works :-) (I've coded it in 30 minutes approximately and I'm quite proud of it)
Copy this code in a file "remote_sync.pl" and then run:
perl remote_sync.pl --base_url=http://localhost/piwigo/dev/branches/2.0 --username=plg --password=plg
If you're using Debian/Ubuntu, you will have to perform:
sudo apt-get install libwww-perl
I think I will add the action "synchronize" in piwigo_remote.pl :-) Please give me your feedback.
Offline
Hi,
thank you very much. Works like a charm. Only think I had to do was to install libcrypt-ssleay-perl to get https support for LWP user agent.
Going to use it daily now ;)
Cheers,
worwan
Offline
hello.. can i asking something? how to use this code?
thank u b4
Offline
sOndakH wrote:
hello.. can i asking something? how to use this code?
This is a Perl script.
What is your operating system? (the one you can schedule to perform synchronization on the remote Piwigo installation)
Offline
yeah i have the same question, i wanna run autosync on webserver
I have a question:
How could i modify this code to synchronize only one album?
I have 10 main physical category, but I want to synchronize only one. Is possible with this code in perl? perhaps putting the name of the class or some other modification?
in advance thank you very much
julian wrote:
I have a question:
How could i modify this code to synchronize only one album?
I have 10 main physical category, but I want to synchronize only one. Is possible with this code in perl? perhaps putting the name of the class or some other modification?
in advance thank you very much
On the page synchronization, you can select only one album, it'is standard
Offline
ddtddt wrote:
julian wrote:
I have a question:
How could i modify this code to synchronize only one album?
I have 10 main physical category, but I want to synchronize only one. Is possible with this code in perl? perhaps putting the name of the class or some other modification?
in advance thank you very muchOn the page synchronization, you can select only one album, it'is standard
I mean to use the code you put in this post.
only one alblum. sync with the code in perl ..
@plg
Bravo, thank you for posting! This code works great on 2.4.4.
Offline
I know I'm late to the part, but I found this thread and it seems to be what I'm looking for.
I have a cron job running on my local computer that sends new images in a folder up to piwigo via rsync. What I'd like to do is run Piwigo's local syncronization every few minutes to keep an album updated.
I tried running the perl script, but it doesn't seem to be working. Here's what I get (I do use my actual username and password, but not showing them here):
$ perl remote_sync.pl --base_url=http://MYSITE/piwigo --username=MYUSERNAME --password=MYPASSWORD
$VAR1 = bless( {
'_protocol' => 'HTTP/1.1',
'_content' => '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://www.MYSITE/piwigo/admin.php?page=site_update&site=1">here</a>.</p>
</body></html>
',
'_rc' => '301',
'_headers' => bless( {
'connection' => 'close',
'client-response-num' => 1,
'location' => 'http://www.MYSITE/piwigo/admin.php?page=site_update&site=1',
'date' => 'Wed, 26 Jun 2013 12:19:35 GMT',
'vary' => 'Accept-Encoding',
'client-peer' => '64.111.115.12:80',
'content-length' => '282',
'client-date' => 'Wed, 26 Jun 2013 12:19:35 GMT',
'content-type' => 'text/html; charset=iso-8859-1',
'title' => '301 Moved Permanently',
'server' => 'Apache'
}, 'HTTP::Headers' ),
'_msg' => 'Moved Permanently',
'_request' => bless( {
'_content' => 'privacy_level=0&sync=files&submit=1&add_to_caddie=1&subcats-included=1&simulate=0&sync_meta=1&display_info=1',
'_uri' => bless( do{\(my $o = 'http://MYSITE/piwigo/admin.php?page=site_update&site=1')}, 'URI::http' ),
'_headers' => bless( {
'user-agent' => 'Mozilla/remote_sync.pl',
'content-type' => 'application/x-www-form-urlencoded',
'content-length' => 108,
'authorization' => 'Basic Y2hyaXNiZWNrc3Ryb206c3VwamhhMjUxMA=='
}, 'HTTP::Headers' ),
'_method' => 'POST',
'_uri_canonical' => $VAR1->{'_request'}{'_uri'}
}, 'HTTP::Request' )
}, 'HTTP::Response' );
I'm not very familiar with perl, but this seems like I'm just using the wrong URL to update.
Any ideas? I would love a way to auto-sync my directories.
Offline
Hi cbfishes,
Don't you have a redirection (mod_rewrite) configured with Apache?
Offline
Hmmm... not sure.. I'm on a shared hosting server with Dreamhost-
I have an .htaccess file at the root of my Piwigo installation, and it looks like this:
Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
To be honest, I don't really understand what mod_rewrite is or how to turn it on. Perhaps I need to activate in my Apache configurations? Not sure if I have direct access to those since it's shared hosting...
Thanks for helping out a noob!
Offline
Hi guys,
I realize this is old thread, but I recently started using this remote_sync.pl from plg (great work by the way, I love it) and now I need to move the gallery to password secured site.
How would I modify the code to pass the credentials to Microsoft IIS 7.5 first before calling the sync itself?
Thank you for help,
Mike
Hi there,
I'm currently running Piwigo on a webhosting. Different photographers are on the road with an Eye-fi SD-card.
They're uploading to FTP automaticly, and I'd love to get the photo's in the gallery automaticly...
Is there a how-to or tutorial to get this autosync running? I'm not familiar with perl or anything.
I'm not sure where I've to put the script you posted, or how I can run that command...
Can someone please help me? :)
Thanks in advance!