ANNOUNCE: galleryadd.pl 2.30

iainlea

Joined: 2004-09-24
Posts: 10
Posted: Wed, 2007-04-11 08:18

URL: http://freshmeat.net/projects/galleryadd/

galleryadd.pl is a script that recursively adds directories or images to a Gallery installation. Its features include a listing of the albums available in a Gallery, the creation of top-level albums with titles and descriptions, and support for the addition of images and directories to an existing album.

Changes in 2.30:
- fixed to work with new auth_token authentication scheme in G2

Usage: galleryadd.pl [options] [file(s) | dir(s)]
-a album album to be used for uploading image(s) or directory
-c album create new album for uploading image(s) or directory
-C text caption for image(s)
-d text description for new album
-g url URL of gallery (default: http://bricbrac.dyndns.org/gallery)
-G [1|2] gallery version being accessed (default: v1.x)
-l list available albums for specified gallery
-n do not verify if album exists before starting upload
-p pass password to use to login to gallery
-q quiet mode (unless errors are encountered)
-t text title for new album (if not specified uses -c value)
-T test image(s) integrity before uploading (jpeg only)
-u user username to use to login to gallery (default: admin)
-z zap caption that is by default derived from filename
-h help
-v verbose

Examples:
galleryadd.pl -g http://gallery -u admin -p secret123 -a mycars bmw.jpg

upload image bmw.jpg to album mycars

galleryadd.pl -g http://gallery -u admin -p secret123 -c xmas /tmp/*

create album xmas and upload images located in /tmp directory

NOTE: G2 users need to specify the album ID (not name) when using -a option

 
bernard74

Joined: 2007-04-24
Posts: 1
Posted: Tue, 2007-04-24 13:03

Hello,

I have a problem when using galleryadd.pl :

./galleryadd.pl -g http://bpinf.sytes.net/gallery2 -G2 -u admin -p my_password -c 0004_RRC_2006

System http://bpinf.sytes.net/gallery2/main.php [G2]
Login: admin [ERROR]

http://bpinf.sytes.net/gallery2/main.php
500
<HTML>
<HEAD><TITLE>An Error Occurred</TITLE></HEAD>
<BODY>
<H1>An Error Occurred</H1>
500 Internal Server Error
</BODY>
</HTML>

admin and password are ok

Thanks for your help

Bernard

 
GJM

Joined: 2005-07-31
Posts: 14
Posted: Fri, 2007-04-27 16:04

I am experiencing the exact same problem, on Gallery 2.2.1 at http://www.snowbombing.com/gallery/

 
GJM

Joined: 2005-07-31
Posts: 14
Posted: Mon, 2007-04-30 09:57

Does nobody have any clue why this would be happening? It renders this tool completely useless!

My Gallery install is completely standard, apart from I have switched to using the Siriux theme and put an image in the header div.

Can anybody offer any suggestions?

 
doomedtx

Joined: 2007-05-06
Posts: 2
Posted: Sun, 2007-05-06 14:25

I'm on a new 2.2.1 install. I originally started out with an old version of galleryadd.pl and then tried 2.30, both without success. I started going through 2.30 line-by-line in gedit and noticed that a good portion of it was pink (ie, string text). I traced the start of the pink to the AddDirectory subroutine which has this line:

$cleanAlbumName =~ s/\\|\/|\*|\?|"|'|<|>|\||\.|\+|#|\s|&|\(|\)/_/g;

Notice that the double and single quotes aren't escaped out with a slash. The AddAlbum subroutine has an identical line. I escaped out the quotes properly (and the #) and the text started looking more like a script than a big string, but it still doesn't work. I'm trying to upload a bunch of directories into the album "2007" on the server. I type the following command:

galleryadd.pl -g http://www.mysite.com -c 2007 -u Me -p pass -G 2 *

where "mysite," "Me" and "pass" are all correctly replaced by my info. The result I receive is:

System  http://www.mysite/main.php  [G2]
Login:  Me  [OK]
Album:  fetching list  [OK]
Check:  2007  [OK]
Create  2007  (2007)  (692)  [OK]
Check:  01ChristmasinLA  [OK]
Create  2007/01ChristmasinLA  (01christmasinla)  [ERROR]

Error:  could not create album - unknown error

200
Error: Error (ERROR_PERMISSION_DENIED) : user id: 13 doesn't have permission: core.addAlbumItem for item id: 2007 <b>in</b> modules/core/classes/helpers/GalleryUserHelper_simple.class <b>at line</b> 47 (gallerycoreapi::error) 
<b>in</b> modules/core/classes/GalleryCoreApi.class <b>at line</b> 477 (galleryuserhelper_simple::asserthasitempermission) 
<b>in</b> modules/remote/GalleryRemote.inc <b>at line</b> 649 (gallerycoreapi::asserthasitempermission) 
<b>in</b> modules/remote/GalleryRemote.inc <b>at line</b> 139 (galleryremotecontroller::newalbum) 
<b>in</b> main.php <b>at line</b> 231 (galleryremotecontroller::handlerequest) 
<b>in</b> main.php <b>at line</b> 94
<b>in</b> main.php <b>at line</b> 83
#__GR2PROTO__
debug_user=Me
debug_time=0.012s
debug_exception=user id\: 13 doesn't have permission\: core.addAlbumItem for item id\: 2007

As you can see, it makes the top-level album but doesn't get through making the first sub-album for the first sub-directory, and it doesn't upload a single picture. This is driving me crazy because I know it's likely a minor error in the code like the one I already found, but I don't have nearly enough experience with galleryadd.pl and GalleryRemote to figure out what's wrong. The Gallery Remote app works just fine so I know my site setup is ok, but since galleryadd.pl seems to be the only way to upload a complete tree structure I'd like to get it working.

 
Blazer0x

Joined: 2005-10-17
Posts: 12
Posted: Wed, 2007-10-17 00:32

I'm having the exact same problem (failed login followed by error 500). Any ideas iainlea?

# /tmp/galleryadd.pl -G2 -g http://mysite.com/gallery2 -u moblogger -p xxx -l
System  http://mysite.com/gallery2/main.php  [G2]
Login:  moblogger  [ERROR]


http://mysite.com/gallery2/main.php
500
<HTML>
<HEAD><TITLE>An Error Occurred</TITLE></HEAD>
<BODY>
<H1>An Error Occurred</H1>
500 Internal Server Error
</BODY>
</HTML>

P.S. I have emailed the galleryadd authors to let them know of these issues. Hopefully I didn't bug them too much and they will find time to look into this :)

*EDIT* I've just discovered that I cannot connect with gallery remote either, so my issue, although same symptoms, may be different. All I know is that the galleryadd.pl I have works fine on gallery 2.1.x, but fails on gallery 2.2.x. Supposedly this is due to the new auth_token requirement, but I tried galleryadd.pl 2.30 which is supposed to address that, to no avail. *scratches head*

 
Wizzu

Joined: 2008-01-17
Posts: 3
Posted: Thu, 2008-01-17 07:05

My story regarding galleryadd.pl and a Gallery installation of 2.1 upgraded to 2.2.

As others who have posted here, galleryadd.pl stopped working with the very annoying 500 Internal Server Error after otherwise successfully upgrading to Gallery 2.2 - the most annoying part was that for some reason I couldn't even find anything in the apache logs, like you're meant to with 500 errors, I guess this is because the error comes from Gallery and not Apache but gallery doesn't log stuff.

First I upgraded my galleryadd.pl from 2.00 to 2.30, but that didn't help. It was probably a necessary first step, though.

Then I found this post at http://gallery.menalto.com/node/61717 which gave me the hint, and sure enough my Remote module was out of synch - I had version 1.0.6 after the upgrade when the current version (as of this writing) is 1.0.9.1. Even though Gallery 2.2 is supposed to have automatic management of modules via the web interface, there was no upgrade feature/link for me (why? the documentation seems to indicate there should be? maybe because mine is an upgraded installation?), so I manually upgraded the module files on the server. After that I could click "upgrade" in the module view of the admin page, and suddenly everything started working.

So I guess there's nothing wrong with galleryadd.pl 2.30 which I'm now using together with Gallery 2.2.4. If you have this problem, check your Gallery installation, especially the Remote module.

I hope this info helps someone!

 
greenleaf_the_savage

Joined: 2008-02-11
Posts: 12
Posted: Fri, 2008-02-15 04:27

I'm getting a different error than everyone else seems to be getting, at least on my main Gallery install. The install I have on my Debian system gives me the 500 error, but on my Ubuntu server (my main server) I get a very long error after logging in, but with the result of not being able to add the pictures I'm trying to add. The user I'm using to add the album and picture is the site administrator, so there should be no permission problems. Here's the error

galleryadd.pl -g <gallery URL> -u <username> -p <password> -c test DSCF4962.JPG
System http://gallifrey/photos/main.php [G2]
Login: greenleaf [OK]
Album: fetching list [OK]
Check: test [OK]
Create test (Test) (13822) [OK]
Upload DSCF4962.JPG (Dscf4962) [ERROR]

Error: could not upload image - unknown error

200
GalleryStatus Object
(
[_stack] =>
[_errorCode] => 5
[_errorMessage] =>
[_stackTrace] => Array
(
[0] => Array
(
[file] => /var/www/photos/modules/remote/GalleryRemote.inc
[line] => 1216
[function] => error
[class] => GalleryCoreApi
[object] => GalleryRemoteController Object
(
[_optionInstances] =>
)

[type] => ->
[args] => Array
(
[0] => 4
)

)

[1] => Array
(
[file] => /var/www/photos/modules/remote/GalleryRemote.inc
[line] => 516
[function] => _assertHasViewPermission
[class] => GalleryRemoteController
[object] => GalleryRemoteController Object
(
[_optionInstances] =>
)

[type] => ->
[args] => Array
(
[0] => test
)

)

[2] => Array
(
[file] => /var/www/photos/modules/remote/GalleryRemote.inc
[line] => 128
[function] => addDataItem
[class] => GalleryRemoteController
[object] => GalleryRemoteController Object
(
[_optionInstances] =>
)

[type] => ->
[args] => Array
(
[0] => Array
(
[protocol_version] => 2.5
[cmd] => add-item
[set_albumName] => test
[caption] => Dscf4962
)

[1] => GalleryRemoteProperties Object
(
[_map] => Array
(
[status] => 403
[status_text] => Upload failed\: ''.
)

)

)

)

[3] => Array
(
[file] => /var/www/photos/main.php
[line] => 231
[function] => handleRequest
[class] => GalleryRemoteController
[object] => GalleryRemoteController Object
(
[_optionInstances] =>
)

[type] => ->
[args] => Array
(
[0] => Array
(
[protocol_version] => 2.5
[cmd] => add-item
[set_albumName] => test
[caption] => Dscf4962
)

)

)

[4] => Array
(
[file] => /var/www/photos/main.php
[line] => 94
[function] => _GalleryMain
[args] => Array
(
[0] =>
)

)

[5] => Array
(
[file] => /var/www/photos/main.php
[line] => 83
[function] => GalleryMain
[args] => Array
(
)

)

)

)
GalleryStatus Object
(
[_stack] =>
[_errorCode] => 5
[_errorMessage] =>
[_stackTrace] => Array
(
[0] => Array
(
[file] => /var/www/photos/modules/remote/GalleryRemote.inc
[line] => 1216
[function] => error
[class] => GalleryCoreApi
[object] => GalleryRemoteController Object
(
[_optionInstances] =>
)

[type] => ->
[args] => Array
(
[0] => 4
)

)

[1] => Array
(
[file] => /var/www/photos/modules/remote/GalleryRemote.inc
[line] => 516
[function] => _assertHasViewPermission
[class] => GalleryRemoteController
[object] => GalleryRemoteController Object
(
[_optionInstances] =>
)

[type] => ->
[args] => Array
(
[0] => test
)

)

[2] => Array
(
[file] => /var/www/photos/modules/remote/GalleryRemote.inc
[line] => 128
[function] => addDataItem
[class] => GalleryRemoteController
[object] => GalleryRemoteController Object
(
[_optionInstances] =>
)

[type] => ->
[args] => Array
(
[0] => Array
(
[protocol_version] => 2.5
[cmd] => add-item
[set_albumName] => test
[caption] => Dscf4962
)

[1] => GalleryRemoteProperties Object
(
[_map] => Array
(
[status] => 403
[status_text] => Upload failed\: ''.
[status_debug] => 1
)

)

)

)

[3] => Array
(
[file] => /var/www/photos/main.php
[line] => 231
[function] => handleRequest
[class] => GalleryRemoteController
[object] => GalleryRemoteController Object
(
[_optionInstances] =>
)

[type] => ->
[args] => Array
(
[0] => Array
(
[protocol_version] => 2.5
[cmd] => add-item
[set_albumName] => test
[caption] => Dscf4962
)

)

)

[4] => Array
(
[file] => /var/www/photos/main.php
[line] => 94
[function] => _GalleryMain
[args] => Array
(
[0] =>
)

)

[5] => Array
(
[file] => /var/www/photos/main.php
[line] => 83
[function] => GalleryMain
[args] => Array
(
)

)

)

)
#__GR2PROTO__
status=403
status_text=Upload failed\: ''.
status_debug=1
debug_user=<username>
debug_time=0.015s
auth_token=3d8fbd10d923

I'm not any good at programming, and I picked Gallery because I didn't need to know any programming to make it work. I was really hoping this script would let me take the pictures off my digital camera and download them to an album on Gallery, but if I can't make it work, I'm going to be back to trying to find something that will suit my needs.

Gallery version = 2.2.4 core 1.2.0.6
PHP version = 5.2.1 apache2handler
Webserver = Apache/2.2.3 (Ubuntu) PHP/5.2.1
Database = mysqli 5.0.38-Ubuntu_0ubuntu1.2-log, lock.system=database
Toolkits = Dcraw, Exif, Getid3, LinkItemToolkit, Thumbnail, ImageMagick, SquareThumb
Acceleration = none, none
Operating system = Linux Gallifrey 2.6.20-16-generic #2 SMP Tue Dec 18 05:45:12 UTC 2007 i686
Default theme = matrix
gettext = enabled
Locale = en_US
Browser = Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.11) Gecko/20071204 Ubuntu/7.10 (gutsy) Firefox/2.0.0.11
Rows in GalleryAccessMap table = 28
Rows in GalleryAccessSubscriberMap table = 4509
Rows in GalleryUser table = 4
Rows in GalleryItem table = 4507
Rows in GalleryAlbumItem table = 44
Rows in GalleryCacheMap table = 0

*EDIT* I Tried again, and the error seems to be in creating the album. I created an album to put the picture into and then tried uploading it (using the album's ID, not the name) and it worked fine. Is there a bug that doesn't let GAllery2 users create albums using the Perl script?

 
Blazer0x

Joined: 2005-10-17
Posts: 12
Posted: Sat, 2009-11-14 12:20

I am having the exact same problem. If anyone could help me figure this out I would much appreciate it. Here is my full sanitized debug output:

Quote:
# /usr/local/bin/galleryadd.pl -G2 -q -g http://gallery.mysite.com/ -u xxx -p xxx -a 108 -C "test" /tmp/test.jpg
Error: could not upload image - unknown error

200
GalleryStatus Object
(
[_stack] =>
[_errorCode] => 5
[_errorMessage] =>
[_stackTrace] => Array
(
[0] => Array
(
[file] => /htdocs/apps/gallery2/modules/remote/GalleryRemote.inc
[line] => 516
[function] => error
[class] => GalleryCoreApi
[object] => GalleryRemoteController Object
(
[_optionInstances] =>
)

[type] => ->
[args] => Array
(
[0] => 4
)

)

[1] => Array
(
[file] => /htdocs/apps/gallery2/modules/remote/GalleryRemote.inc
[line] => 129
[function] => addDataItem
[class] => GalleryRemoteController
[object] => GalleryRemoteController Object
(
[_optionInstances] =>
)

[type] => ->
[args] => Array
(
[0] => Array
(
[protocol_version] => 2.5
[cmd] => add-item
[set_albumName] =>
[caption] => test
)

[1] => GalleryRemoteProperties Object
(
[_map] => Array
(
[status] => 403
[status_text] => Upload failed\: ''.
)

)

)

)

[2] => Array
(
[file] => /htdocs/apps/gallery2/main.php
[line] => 250
[function] => handleRequest
[class] => GalleryRemoteController
[object] => GalleryRemoteController Object
(
[_optionInstances] =>
)

[type] => ->
[args] => Array
(
[0] => Array
(
[protocol_version] => 2.5
[cmd] => add-item
[set_albumName] =>
[caption] => test
)

)

)
[3] => Array
(
[file] => /htdocs/apps/gallery2/main.php
[line] => 104
[function] => _GalleryMain
[args] => Array
(
[0] =>
)

)

[4] => Array
(
[file] => /htdocs/apps/gallery2/main.php
[line] => 88
[function] => GalleryMain
[args] => Array
(
)

)

)

)
GalleryStatus Object
(
[_stack] =>
[_errorCode] => 5
[_errorMessage] =>
[_stackTrace] => Array
(
[0] => Array
(
[file] => /htdocs/apps/gallery2/modules/remote/GalleryRemote.inc
[line] => 516
[function] => error
[class] => GalleryCoreApi
[object] => GalleryRemoteController Object
(
[_optionInstances] =>
)

[type] => ->
[args] => Array
(
[0] => 4
)

)

[1] => Array
(
[file] => /htdocs/apps/gallery2/modules/remote/GalleryRemote.inc
[line] => 129
[function] => addDataItem
[class] => GalleryRemoteController
[object] => GalleryRemoteController Object
(
[_optionInstances] =>
)

[type] => ->
[args] => Array
(
[0] => Array
(
[protocol_version] => 2.5
[cmd] => add-item
[set_albumName] =>
[caption] => test
)

[1] => GalleryRemoteProperties Object
(
[_map] => Array
(
[status] => 403
[status_text] => Upload failed\: ''.
[status_debug] => 1
)

)

)

)

[2] => Array
(
[file] => /htdocs/apps/gallery2/main.php
[line] => 250
[function] => handleRequest
[class] => GalleryRemoteController
[object] => GalleryRemoteController Object
(
[_optionInstances] =>
)

[type] => ->
[args] => Array
(
[0] => Array
(
[protocol_version] => 2.5
[cmd] => add-item
[set_albumName] =>
[caption] => test
)

)

)

[3] => Array
(
[file] => /htdocs/apps/gallery2/main.php
[line] => 104
[function] => _GalleryMain
[args] => Array
(
[0] =>
)

)

[4] => Array
(
[file] => /htdocs/apps/gallery2/main.php
[line] => 88
[function] => GalleryMain
[args] => Array
(
)

)

)

)
#__GR2PROTO__
status=403
status_text=Upload failed\: ''.
status_debug=1
debug_user=xxx
debug_time=0.002s
auth_token=bb9bahf00d14

 
Wizzu

Joined: 2008-01-17
Posts: 3
Posted: Sat, 2009-11-14 18:39
Blazer0x wrote:
#__GR2PROTO__
status=403

That bit near the end looks suspiciously like an "authorization required" error (403). If you have access to the web server logs, you could check there if you can see what URL you don't have access to, and what are the access controls to it (web-server level, and for the Gallery user)?

I had a similar problem as this, and as I recall it was a web server side issue (web server did not have read access some file, or something - it's been awhile).

Obviously you should double and triple check that the username/password works, but I assume you've done that.

 
Blazer0x

Joined: 2005-10-17
Posts: 12
Posted: Mon, 2009-11-16 07:18

Yeah the username and password works, as it does login successfully and gets the list of albums. I checked the web server logs and there are no errors, despite the "403" status code, which Im not sure is the same as the apache 403 forbidden error.

 
Wizzu

Joined: 2008-01-17
Posts: 3
Posted: Mon, 2009-11-16 08:46

Another thing to check for (something that bit me at least):
make sure you have the "remote" module installed and configured for your Gallery instance.

It's been awhile (many months) but I think what happened was that after some upgrade or something to a working gallery instance, the remote module was deactivated and I had to go in the modules configuration and (re-)enable it.