Announcement

#1 2009-11-22 22:35:14

worwan
Member
2008-06-16
21

wget to automatically quick local sync

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&amp;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

 

#2 2009-11-26 01:19:41

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13571

Re: wget to automatically quick local sync

[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):

Code:

#!/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:

Code:

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:

Code:

sudo apt-get install libwww-perl

I think I will add the action "synchronize" in piwigo_remote.pl :-) Please give me your feedback.

Offline

 

#3 2009-11-26 02:26:31

worwan
Member
2008-06-16
21

Re: wget to automatically quick local sync

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

 

#4 2009-12-01 23:44:57

sOndakH
Member
2009-12-01
1

Re: wget to automatically quick local sync

hello.. can i asking something? how to use this code?

thank u b4

Offline

 

#5 2009-12-02 00:42:10

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13571

Re: wget to automatically quick local sync

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

 

#6 2011-04-05 22:04:03

oneandonly
Guest

Re: wget to automatically quick local sync

yeah i have the same question, i wanna run autosync on webserver

 

#7 2011-04-06 05:11:17

julian
Guest

Re: wget to automatically quick local sync

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

 

#8 2011-04-06 06:48:48

ddtddt
Piwigo Team
Quetigny - France
2007-07-27
7056

Re: wget to automatically quick local sync

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


You love Piwigo so don't hesitate to participate, learn more on the "Contribute to Piwigo" page. If you don't have much time for contribution, you can also help the project with a donation.

Offline

 

#9 2011-04-06 20:25:19

julian
Guest

Re: wget to automatically quick local sync

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 much

On 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 ..

 

#10 2012-09-28 16:40:06

CamaroOB
Member
2012-09-28
1

Re: wget to automatically quick local sync

@plg

Bravo, thank you for posting!  This code works great on 2.4.4.

Offline

 

#11 2013-06-26 14:26:24

cbfishes
Member
2013-02-22
2

Re: wget to automatically quick local sync

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&amp;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

 

#12 2013-06-26 14:43:27

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13571

Re: wget to automatically quick local sync

Hi cbfishes,

Don't you have a redirection (mod_rewrite) configured with Apache?

Offline

 

#13 2013-06-26 14:57:24

cbfishes
Member
2013-02-22
2

Re: wget to automatically quick local sync

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

 

#14 2014-02-20 19:32:11

Mikee
Guest

Re: wget to automatically quick local sync

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

 

#15 2014-03-08 11:31:54

Robin Leltz
Guest

Re: wget to automatically quick local sync

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!

 

Board footer

Powered by FluxBB

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