Perl Script to upload Gallery2 albums to SmugMug
madeingermany
Registered Users Posts: 22 Big grins
Hi,
Based on on Jeremy Mooney's FileUpload for SmugMug I created a Perl script that takes a Gallery album, looks up the tilte from Gallery's mysql database and uploads the images into a new album on SmugMug.
You can find the script and documentation at
http://marcofrom.com/smug-uploadalbum/
Let me know, what you think and pardon my code :dunno
Thank you!
Marco
PS: Alternative Hacks dealing with Gallery are Gallery Album to SmugMug and Migratr but both didn't cut it for me
Based on on Jeremy Mooney's FileUpload for SmugMug I created a Perl script that takes a Gallery album, looks up the tilte from Gallery's mysql database and uploads the images into a new album on SmugMug.
You can find the script and documentation at
http://marcofrom.com/smug-uploadalbum/
Let me know, what you think and pardon my code :dunno
Thank you!
Marco
PS: Alternative Hacks dealing with Gallery are Gallery Album to SmugMug and Migratr but both didn't cut it for me
0
Comments
Hi Marco,
I'm in the same struggles you had, looking for other options to migrate from gallery2 and well the other options so far have given me no luck in compeletly working.
I'm running gallery2, and older 2.1X and I feel that is giving me problems with some of the other migration programs. I don't have the option to update, because as many gallery2 users might know that always opens up another can of worms, or so has been my luck.
cutting to the quesiton here
I'm running g2 usingpostgres, I'm probably dangerous enough to get in trouble with things, and feel your script might provide the best options . I'm having a problem running the script. The output follows
$ ./uploadalbum --directory /home/test/gallery/g2data/albums/test --database DBI:Pg:test_gallery:localhost --dbuser test --dbpass test --email test@t.net --pass test
....logged in successfully.
DBI connect('test_gallery:localhost','test',...) failed: missing "=" after "test_gallery:localhost" in connection info string
at ./uploadalbum line 104
DB error: missing "=" after "test_gallery:localhost" in connection info string
Any help would be great
thank you..
I'm trying to import my galleries from g2 using this script (thank you, BTW) and it looks like it's *really* close to working :-)
produces
For all of my G2 albums...but none of the albums were actually uploaded...
???
I'm afraid I'm not real sure where to look. Any ideas?
thanks.
sorry that it is not working for you. It has been a while that I looked at this... because you only need it once
If you run it for just one album Is the Session ID the last thing you see?
You should get "Using Album $albumname (Gallery2 ID $parent)" after that, otherwise I'm thinking it has to do with the mysql connection.
Can you double check your mysql settings in the config file?
On the other hand the script should throw an error, if anything goes wrong.
Marco
I tried running it against one folder and the SessionID was still the last thing I saw.
So I looked through the script and found where it prints the Session ID and then I started adding print statements after that to see if I could figure out what was going on.
It looks like the g2_FileSystemIdentity table is empty (I think that was the one - I don't have it in front of me this morning). Which, as far as I can tell, means that my SQL export didn't work correctly
The real bugger is that the original DB is no longer in existence and the only thing I *had* was the SQL export.....
Anyway, it looks like this script hasn't been updated in a while, and I ran into a few problems with it. Mainly, it doesn't handle the new album keys that were added a while ago, so it doesn't properly parse the album and image IDs. This was causing it to be unable to upload images to an album that had just been created by the script. The URL displayed at the end of the script also cannot be used to view the album, since the key is not appended to the end of the URL.
I went ahead and fixed the problems, the updated script can be downloaded from here:
http://www2.maiman.net/smug-uploadalbum/uploadalbum
While I was at it, I added two new features (to suit my import needs). I added two command line switches, --nofilenamecaptions and --captionsfromdescriptions. The first switch prevents the filename from being used as the caption if there is no caption present in Gallery2. The second switch causes the "description" field on the Gallery2 item to be used instead of the "title" field. (All of my captions were in that field, not in the title).
I attached a diff to this message showing the code changes.
I tested out the changes, and they appear to be working correctly, but it's always good if some other people try it out.
I hope you don't mind that I modified your code, hopefully you'll be able to incorporate these changes into your next version.
This was a good first exposure to the SmugMug API for me. I think I'll take a crack at writing a Blackberry Uploader to SmugMug next (being able to post geotagged photos from my phone like I can do with Flickr would be a cool feature and it doesn't look like anyone else has tried to write one yet). Plus, I saw that SmugMug has an offer that authors of apps that use the API can be eligible for a free account, so I can kill two birds with one stones (save money and finally learn the Blackberry JDE which I've been meaning to do for a while).
Just a quick note for postgresql users--you can't use double quotes " in WHERE clauses, so this script will only work if you change the double quotes to single quotes ' in all of the SELECT queries
Updated script:
http://www.midwinter.com/~koreth/uploadalbum
Hi Erick,
I haven't looked at this for 2 years ... but looking at the code now, it seems to not support the feature of getting Album name from the Database.
I don't know why (thinking there must have been a good reason). I'll try to look at it next weekend.
Thanks,
Marco
Any ideas? Thanks.
Also, for anyone looking for a tool to move menalto gallery images to smugmug, Smuganizer at http://code.google.com/p/smuganizer/ does seem to work, albeit (unfortunately) without moving across data from custom fields.
Keith
The issue is you dont have a cookie jar and they are shoving some stuff in there upon login:
Find this section:
my $ua = LWP::UserAgent->new;
$ua->agent('MarcosGallery2PerlUploader/0.1');
add this line beneath:
$ua->cookie_jar( {} );
Community efforts like this are great - thanks to all who have worked on this.
Has anyone updated it to be able to transfer a Gallery3 album (set of albums, website)?
With Menalto Gallery3 now obsoleted, we all need to transfer, and there don't seem to be any scripts or services to do it
thanks,