Gallery2 Album Upload to SmugMug in Perl
Description|Requirements|Inputs needed|What this script does|License|Download|Feedback/Help
Description
This perl script can help you upload your images from you Gallery2 to SmugMug.
It is based on Jeremy Mooney's FileUpload for SmugMug. Jeremy graciously agreed that I can extend his script and release it in this version specialized on Gallery2. Thank you!
If you just want to upload single files in an automated fashion or have iphoto albums to upload, check out his website.
Requirements
- Access to the Linux Server where Gallery2 keeps its data (the g2data directory).
- Access to the mysql server running the G2 database. I guess you could copy the g2data/albums directory and the mysql DB to a different linux host and do the upload from there - the actual G2 does not have to be running. This was developed on Gallery version 2.2.4 of the DB.
- Internet access and a login to SmugMug. You can sign up for a free 14 day trial without a Credit Card.
- Perl with the following Modules: DBI, LWP::UserAgent, HTTP::Request, a compatible SSL library such as Crypt::SSLeay, Digest::MD5, Cwd. I tested this running Perl v5.8.4
Inputs needed
There is two ways of putting the required parameters in: The config file (downlaod the template "uploadalbum.cfg) or via the command line.
- directory = /home/user/g2data/albums/travel/brasil07, all jpg (jpeg) files from directory will be uploaded to SmugMug. Note that this directory need to be under the albums directory.
- database = 'DBI:mysql:databasename_g2:localhost', see cpan for documentation
- dbuser = 'dbuser', login for your mysql db
- dbpass = 'xxx', password for your mysql db
- email = 'user@example.com', SmugMug login email address
- pass = 'xxx', SmugMug login password
- albumid = 12345, optional, if you specify an existing album id, all pictures will go in there. If don't specify it, a new album by the name of the directory will be created.
- categoryid = 0, leave the default 0 for the 'Other' Category or specify a different CategoryID (see "uploadalbum.cfg for the standard options).
Example call:
./uploadalbum --directory /home/user/g2data/albums/travel/brasil07 --database DBI:mysql:databasename_g2:localhost --dbuser user --dbpass pass --email user@example.com --pass smugpass
You can easily upload all albums in your gallery using the find command (specify all other required parameters in the config file):
find /home/user/g2data/albums -type d -exec ./uploadalbum --directory {} \;
(the last two characters are a backslash followed by a semi-colon)
What the script does
- Check if the specified directory is valid, readable and under albums
- Login to SmugMug (https)
- Log into mysql db
- Finding the id of the album that is stored in the specified directory
- Creating a new album on SmugMug with the specified CategoryID, unless an AlbumID was specified
- Looping over all the jpeg files in the directory
- Looking up the title for each one, defaulting to the filename if missing
- Upload the file to the Album, continue with the next image
- Logging out the SmugMug Session
License
This work is licensed under a
Creative Commons Attribution-Share Alike 3.0 United States License.
Download
You only need the main file uploadalbum (right-click 'Save Link As'), but I recommend you also get the config file uploadalbum.cfg to go with it (the command line tends to get very long).
Feedback/Help
I do not promise to support this script or that I will always keep it up to date, when Gallery or SmugMug change things on a greater scale. However, if I have the time, I will do what I can to help you. Just drop me an email at marco (ät) marcofrom (döt) com.
Alternatively, you can check out the Digital Grin Forum Thread.