Lurk all you'd like, but why not register and post some pics? Registering also makes it easier to find the good stuff. Need help?

Go Back   Digital Grin Photography Forum > Support > SmugMug APIs, Hacks & Tricks
Dgrinner
Password
Register FAQ Shooters Calendar Reviews Tutorials Gallery Books Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old Jan-13-2008, 09:28 PM   #1
madeingermany
I'm new to all this :)
 
madeingermany's Avatar
 
Join Date: May 2006
Posts: 22
Cool2 Perl Script to upload Gallery2 albums to SmugMug

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

Thank you!
Marco


PS: Alternative Hacks dealing with Gallery are Gallery Album to SmugMug and Migratr but both didn't cut it for me ;)
madeingermany is offline   Reply With Quote
Old Mar-06-2008, 07:31 PM   #2
batts
lost in confusion
 
batts's Avatar
 
Join Date: Mar 2008
Location: Wisconsin
Posts: 79
script help

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


Quote:
Originally Posted by madeingermany
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

Thank you!
Marco


PS: Alternative Hacks dealing with Gallery are Gallery Album to SmugMug and Migratr but both didn't cut it for me ;)
batts is offline   Reply With Quote
Old Aug-07-2008, 07:30 PM   #3
ubahmapk
Beginner grinner
 
Join Date: Aug 2008
Posts: 2
So close...I think

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

Code:
find /path/to/g2data/albums -type d -exec ./uploadalbum --directory {} \;
produces

Code:
Using path /path/to/g2data/albums
Using path /path/to/g2data/albums/AlbumName1
found AlbumName1
Session a12b3c4d5e6f7a8b9c0d52336c2b5
smugmug-user-id logged in successfully.
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.
ubahmapk is offline   Reply With Quote
Old Aug-07-2008, 08:02 PM   #4
madeingermany
I'm new to all this :)
 
madeingermany's Avatar
 
Join Date: May 2006
Posts: 22
Hi ubahmapk,

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
Code:
./uploadalbum --directory /path/to/g2data/albums/AlbumName1
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
madeingermany is offline   Reply With Quote
Old Aug-08-2008, 06:55 AM   #5
ubahmapk
Beginner grinner
 
Join Date: Aug 2008
Posts: 2
Bncry sadness

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.....
ubahmapk is offline   Reply With Quote
Old Sep-05-2008, 05:50 PM   #6
Andrew Maiman
Big grins
 
Join Date: Sep 2008
Posts: 50
Thanks for writing this great script. I'm new to SmugMug and DGrin and am in the process of migrating my photos from my old Gallery2 site to my new SmugMug site. (And I'll eventually upload the thousands of newer pictures that I didn't have on the old site since I didn't want to pay for the disk space for my web server. Unlimited storage on SmugMug sounds like a good deal to me ). Most of the stuff on my old gallery is from several years ago, I haven't posted any of the (much better) stuff from any of my recent travel since my new camera generates gigabytes of pictures for each trip.

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).
Attached Files
File Type: txt diff.txt (1.8 KB, 92 views)

Last edited by Andrew Maiman; Sep-05-2008 at 06:10 PM.
Andrew Maiman is offline   Reply With Quote
Old May-22-2009, 01:44 PM   #7
rdk8
Beginner grinner
 
Join Date: May 2009
Posts: 1
For postgresql users--can't use "

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
rdk8 is offline   Reply With Quote
Old May-28-2009, 01:30 PM   #8
koreth
Beginner grinner
 
Join Date: May 2009
Posts: 3
I made another tweak to the script. Now if --captionsfromdescription is specified, it will try to use the description, then the summary, then the title, then the filename (unless --nofilenamecaptions is specified) until it finds something. Also, if --nofilenamecaptions is specified, it now checks for filename titles that got saved to the Gallery2 database and strips them off (previously that option would only avoid creating *new* filename captions but would use existing ones.)

Updated script:

http://www.midwinter.com/~koreth/uploadalbum
koreth is offline   Reply With Quote
Old Jan-09-2010, 09:22 AM   #9
Laephis
Beginner grinner
 
Join Date: Jan 2010
Posts: 3
This script almost works perfectly for me with one major problem: all of my Gallery 2.3 albums are being named with their filename instead of their Title. So for example, /home/user/g2data/albums/album01 is being imported into Smugmug and called "album01" instead of being named "Family Photos" which is its title in Gallery 2.3. Is there anyway to fix this? I've spent some time looking at the script, but I'm no Perl guru. :(
Laephis is offline   Reply With Quote
Old Jan-11-2010, 09:05 AM   #10
madeingermany
I'm new to all this :)
 
madeingermany's Avatar
 
Join Date: May 2006
Posts: 22
Quote:
Originally Posted by Laephis
all of my Gallery 2.3 albums are being named with their filename instead of their Title.
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
madeingermany is offline   Reply With Quote
Reply

Tell The World!

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Times are GMT -8.   It's 09:20 PM.


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.