smugmug command line tool in python
rutt
Registered Users Posts: 6,511 Major grins
I have written a command line tool that uses the smugmug labs API to create gallereis, upload photos to them, and keep them updated as images change and new images are added locally. This is very useful if you want to treat you smugmug account as a mirror of a local directory tree. It also is not subject to the 100MB limit of the various browser based upload tools.
Who is this for? The brave, people who want to deal with a lot of photos and galleries, rogrammers; in short people like me. If you are not comfortable with command line programs, you won't like this. If you are aggressively non-technical, this isn't for you. But if you like to tinker and you aren't afraid of what's under the hood of your computer, this might be just the thing for you.
I have been using variants of this program for almost a year, but this version has been radically revised in hopes that it can be more than personal software. As such, I'm sure there will be bugs. Please email me with these. (please don't PM.) The program text contains a disclaimer, but I suppose I'd better add one here as well. Use this thing at your own risk. I won't be responsible for any damage it inflicts.
I have used and tested on OS X and on Linux. I have not tried on windows, but there really is no reason that it shouldn't work there. I have tried to be as portable as possible (and python allows a lot of this.) I'd like to hear about experiences on windows. Best of all, I'd like a python programmer on windows to smooth out the rough corners there.
Download sm_tool.py
Smugmug.py requires python 2.3 or better.
[Edited to reflect the true correct home of the script.]
Who is this for? The brave, people who want to deal with a lot of photos and galleries, rogrammers; in short people like me. If you are not comfortable with command line programs, you won't like this. If you are aggressively non-technical, this isn't for you. But if you like to tinker and you aren't afraid of what's under the hood of your computer, this might be just the thing for you.
I have been using variants of this program for almost a year, but this version has been radically revised in hopes that it can be more than personal software. As such, I'm sure there will be bugs. Please email me with these. (please don't PM.) The program text contains a disclaimer, but I suppose I'd better add one here as well. Use this thing at your own risk. I won't be responsible for any damage it inflicts.
I have used and tested on OS X and on Linux. I have not tried on windows, but there really is no reason that it shouldn't work there. I have tried to be as portable as possible (and python allows a lot of this.) I'd like to hear about experiences on windows. Best of all, I'd like a python programmer on windows to smooth out the rough corners there.
Download sm_tool.py
Smugmug.py requires python 2.3 or better.
[Edited to reflect the true correct home of the script.]
If not now, when?
0
Comments
Gallery creation customizations don't work properly. I fixed a bug with my script. Pick up a new version. You want at least version 1.4 (look near the top of the script.)
Nevertheless, gallery creation currently ignores all parameters except the category. I strongly suspect an API bug and have submitted a bug. Stay tuned.
So far, all I can get to work under Mac OS X is the simple upload command, but that's all I was looking for. By invoking your script within a do shell script command in applescript, I can now automate uploads to smugmug from within iView Media Pro.
DE.
I am running Mac OS X 10.3.4. When I invoke your script with the update command from the terminal, I get:
Traceback (most recent call last):
File "/Users/dephron/Library/Application Support/SmugMug/smugmug.py", line 625, in ?
main()
File "/Users/dephron/Library/Application Support/SmugMug/smugmug.py", line 616, in main
update(Options(argv[2:]))
File "/Users/dephron/Library/Application Support/SmugMug/smugmug.py", line 577, in update
update_dir(smugmug,".",opts,listdir("."))
NameError: global name 'listdir' is not defined
The upload command works fine.
The script works fine on Windows(so far) using python included the cygwin unix environment. I haven't used it for much other than uploading.. Haven't played with the creation stuff yet.
Cygwin gives you a bash shell, complete with unix style path's, home dirtectory, etc. Get it at http://www.cygwin.com
NOTE:
While you are in the cygwin environment, you need to use unix style path names. All windows drives are mounted under /cygdrive/ . So, to access files on the c: drive, you would access them through /cygdrive/c/ . ie., the path "c:\mypic.jpg" would be translated to "/cygdrive/c/mypic.jpg". Also, if there are any spaces in the path, like in "My Pictures", you need to escape the spaces, or wrap quotation marks around the entire path.
Thanks for the script!
-Matt M.
Hi,
I'd love to try this out. The java uploader is annoying for Linux...
but when trying to download the script and get a file not found error.
Can someone email me the file or tell me where to find it? I could host it on my site if needed also...
Thanks,
Brian
Sorry, I was at work earlier and they block all ports other than 80.
Got it now. Thanks!
Would the March 4th API changes have broken this? I tried changing the URL as descriped in the API change annoucement and the script still worked the same way. Uploads pictures, but they don't show up anywhere.
Thanks for any assistance! This is just the tool I need so I hope to be able to get it working one way for another :
In the function post_multipart, you'll find some print statements that have been commented out. Try uncommenting them and try to upload just one file. What happens?
Rich
Suppose "VacationShots" is a directory full of jpgs from your trip. Cd there and do:
It has an even more high level usage model. Suppose you have a directory tree of galleries, each containing some shots and perhaps other directories. If you cd to the root of this tree and do:
Neither of these modes requires you to know the gallery_id.
Sorry, it's http://www.chezrutt.com/rutt/sm_tool/sm_tool.py
**Caution** python.com is very different then python.org
No login and/or password. Both are required
I've tried putting the password/username on the command line as well as in .smugmugrc. Any suggestions?
Thanks!
What OS are you using? Where is your .smugmugrc located? What does it look like (use XXX for password).
Sorry for not providing any details.I'm running Linux (Debiain), Python 2.3.5, and the .smugmugrc is in the same directory as sm_tool.py, (the directory with the pictures).
The syntax was: ./sm_tool.py --login=LOGIN --password=PASSWORD create Trip (and I've tried combos of this with quotes around login/pass and gallery name.
Thanks for your help,
Scott
The .smugmugrc is supposed to be in your home directory (~). If you put your login and password there, things should work.
The command line syntax is a little different that what you used. Note, that it says:
That means that the options come after the command name (in this case "create"). Move them there and it will also work.
David, please share your AppleScript with us. I'm new to AppleScript but would love to be able to upload from iView MediaPro.
Thanks!
Michael
I used sm_tool.py last night to upload a few hundred photos. Nice, very nice.
I had to pull sm_tool.py out of the Google cache, though. Apparently www.chezrutt.com is redirecting to gate.chezrutt.com on port 8030, which is refusing connections (perhaps the web server is not listening).
Anybody got a recent copy of this script? I think mine might be older as the create function doesn't actually work for me from OS X. If you have a reasonably recent version of this tool, please email it to mdm [at] tanagra [dot] com. I'd even be happy to host it - it's so small.
Thanks!
Michael
I'm sorry, I've had sort of an IT infrastructure meltdown and I no longer have a great way to provide access to script, at least until September. I've sent mdm a copy of the most recent version of the script. Great if he hosts it.
And here it is:
http://michaelmcdaniel.net/files/sm_tool.py
Rutt, just let me know if you update the script so I can stay up to date! :
I'm running this on Windows XP. The file upload doesn't seem to work for me. When I run full_update I get the galleries created and lines like this that make it appear like the files were uploaded:
.\A611904_May\25871677_2005-05-19~13-47~1.jpg...[OK] 2298927 bytes 0 seconds 2834KB/sec ETA 6
.\A611904_May\25871688_2005-05-20~16-43~1.jpg...[OK] 1050724 bytes 0 seconds 1811KB/sec ETA 9
.\A611904_May\25871733_2005-05-20~17-34~1.jpg...[OK] 1535479 bytes 186 seconds 8KB/sec ETA 33:02
.\A611904_May\25871843_2005-05-20~17-48~1.jpg...[OK] 2538017 bytes 0 seconds 3017KB/sec ETA 4
Any idea why the photos aren't showing up?
Version 1.10 fixes this problem for windows (thanks, Rutt!) and is now available at:
http://www.michaelmcdaniel.net/files/sm_tool.py
Enjoy!
--Michael
Great tool! I'm sure it's me still being relatively new at Linux, but I can't seem to get smugmug.py to background happily and continue to function. I ssh into my home server, then run:
It runs happily (I can see the pictures being updated on the website) as long as the terminal window (ssh session) stays open. As soon as I log out (close the window, because it won't logout like normal), it stops functioning. If I ssh in again, I can still see the python process running, but it's not doing anything (website not updating).
Thanks!
Scott
Try using something like:
and see what happens.
Adding "nohup" before the smugmug.py command seemed to work. I still can't logout of the ssh session normally -- I have to close that terminal window, but the script keeps running! Thanks a lot
I already have a significant number of pix on smugmug arranged in galleries that aren't directly related to the directory names. From the pictures 'root' directory (Family Pictures), I ran smugmug.py create October-2005 .......adding two directories (2005-10-18 and 2005-10-24) worth of files on the same command line. After that finished, I tried to run smugmug.py create November-2005 2005-11-18/* from the same root directory. Because the SMUGMUG-INFO directory was created in that 'root' directory, it only had the gallery entry for the October gallery, and so started adding the November pictures to the October-2005 directory instead. So I had to stop and use the smugmug.py upload 1039405 2005-11-18/* to get the pictures into the right gallery.
Maybe a future release could include support for uploading to one gallery from multiple directories and still retaining the SMUGMUG_INFO. Until then, I think I can work around just fine Thanks very much for a great script!! Now I can semi-automate my updates and not worry about someone else closing the darn browser in the middle of an upload!
Scott
Scott