smugmug command line tool in python

ruttrutt 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.]
If not now, when?
«134

Comments

  • ruttrutt Registered Users Posts: 6,511 Major grins
    edited November 20, 2004
    Gallery creation issues
    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.
    If not now, when?
  • David EphronDavid Ephron Registered Users Posts: 5 Beginner grinner
    edited November 22, 2004
    Thanks very much for posting this great tool!

    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.
  • ruttrutt Registered Users Posts: 6,511 Major grins
    edited November 22, 2004
    Thanks very much for posting this great tool!

    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.
    Please tell me about your other problems.
    If not now, when?
  • David EphronDavid Ephron Registered Users Posts: 5 Beginner grinner
    edited November 23, 2004
    rutt wrote:
    Please tell me about your other problems.

    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.
  • ruttrutt Registered Users Posts: 6,511 Major grins
    edited November 23, 2004
    I am running Mac OS X 10.3.4. When I invoke your script with the update command from the terminal, I get:The upload command works fine.
    Fixe. Get yourself a new copy here.
    If not now, when?
  • digimattdigimatt Registered Users Posts: 1 Beginner grinner
    edited January 20, 2005
    Using on Windows
    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.
  • vthokiestmvthokiestm Registered Users Posts: 4 Beginner grinner
    edited February 24, 2005
    Script down?
    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
  • ruttrutt Registered Users Posts: 6,511 Major grins
    edited February 24, 2005
    vthokiestm wrote:
    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
    This URL works for me: http://www.chezrutt.com/rutt/smugmug/smugmug.py
    If not now, when?
  • vthokiestmvthokiestm Registered Users Posts: 4 Beginner grinner
    edited February 25, 2005
    Working Now
    Sorry, I was at work earlier and they block all ports other than 80.

    Got it now. Thanks!
  • ryderryder Registered Users Posts: 2 Beginner grinner
    edited March 18, 2005
    Is there any reason why smugmug.py would stop working? I just subscribed to smugmug and found this script which is just what I was looking for. I ran it under linux and I can create empty galleries with it fine, and I can apparently upload photos with it, but the photos don't appear in the galleries! I uploaded quite a few photos overnight (with OK's at the end of each files upload) and they seem to have vanished. I've tried to do single file uploads as well with no luck. smugmug.py put out no errors or any other suspicous output.


    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 :):
  • ruttrutt Registered Users Posts: 6,511 Major grins
    edited March 18, 2005
    ryder wrote:
    Is there any reason why smugmug.py would stop working? I just subscribed to smugmug and found this script which is just what I was looking for. I ran it under linux and I can create empty galleries with it fine, and I can apparently upload photos with it, but the photos don't appear in the galleries! I uploaded quite a few photos overnight (with OK's at the end of each files upload) and they seem to have vanished. I've tried to do single file uploads as well with no luck. smugmug.py put out no errors or any other suspicous output.


    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 :):
    It works for me as of yesterday and I have made no changes to it. Let's see if we can figure this out.

    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?
    If not now, when?
  • ryderryder Registered Users Posts: 2 Beginner grinner
    edited March 18, 2005
    Did that, saw that the error was 'system error (nogallery) ' . When I saw that I realized that maybe I should be using the numeric ID of the gallery rather than the alphanumeric name. Tried that and it worked. Chalk one up to being a smugmug newbie. Thanks so much for the quick help!

    Rich

    rutt wrote:
    It works for me as of yesterday and I have made no changes to it. Let's see if we can figure this out.

    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?
  • ruttrutt Registered Users Posts: 6,511 Major grins
    edited March 18, 2005
    ryder wrote:
    Did that, saw that the error was 'system error (nogallery) ' . When I saw that I realized that maybe I should be using the numeric ID of the gallery rather than the alphanumeric name. Tried that and it worked. Chalk one up to being a smugmug newbie. Thanks so much for the quick help!

    Rich
    I rarely use it in this low level mode. It supports two higher level models:


    Suppose "VacationShots" is a directory full of jpgs from your trip. Cd there and do:
    smugmug.py create "My Trip" *.jpg
    After this, suppose you add a new shot to the directory VacationShots, perhaps a PS edit of one of the originals. You can always cd to VacationShots and do:
    smugmug.py update
    and it will find and upload any shots that are new or have changed since the last upload. It remembers the gallery from the create.

    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:
    smugmug.py full_update
    it will crawl the entire directory tree making sure that a gallery exists for each directory in the tree that contains shots and uploading the shots not already uploaded.

    Neither of these modes requires you to know the gallery_id.
    If not now, when?
  • toybreakertoybreaker Registered Users Posts: 3 Beginner grinner
    edited April 19, 2005
  • ruttrutt Registered Users Posts: 6,511 Major grins
    edited April 19, 2005
  • toybreakertoybreaker Registered Users Posts: 3 Beginner grinner
    edited April 20, 2005
    rutt wrote:
    Yup! That one works.

    **Caution** python.com is very different then python.org11doh.gif
  • klettkeklettke Registered Users Posts: 12 Big grins
    edited June 17, 2005
    I'm looking forward to using this plugin. However, no matter what I do it always gives me the error message:

    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!
  • ruttrutt Registered Users Posts: 6,511 Major grins
    edited June 17, 2005
    klettke wrote:
    I'm looking forward to using this plugin. However, no matter what I do it always gives me the error message:

    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).
    If not now, when?
  • klettkeklettke Registered Users Posts: 12 Big grins
    edited June 18, 2005
    Hey,

    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
    rutt wrote:
    What OS are you using? Where is your .smugmugrc located? What does it look like (use XXX for password).
  • ruttrutt Registered Users Posts: 6,511 Major grins
    edited June 18, 2005
    klettke wrote:
    Hey,

    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:
    smugmug.py create gallery_name [options] [file...]

    That means that the options come after the command name (in this case "create"). Move them there and it will also work.
    If not now, when?
  • mdmmdm Registered Users Posts: 9 Beginner grinner
    edited July 7, 2005
    iView Applescript?
    Thanks very much for posting this great tool!

    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.

    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
  • mwgricemwgrice Registered Users Posts: 383 Major grins
    edited July 24, 2005
    Nice tool, although I had download problems
    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).
  • mdmmdm Registered Users Posts: 9 Beginner grinner
    edited August 9, 2005
    Anybody got a copy?
    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
    mwgrice wrote:
    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).
  • ruttrutt Registered Users Posts: 6,511 Major grins
    edited August 9, 2005
    mdm wrote:
    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.
    If not now, when?
  • mdmmdm Registered Users Posts: 9 Beginner grinner
    edited August 9, 2005
    sm_tool.py back online!
    rutt wrote:
    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! :):
  • yahootintinyahootintin Registered Users Posts: 6 Beginner grinner
    edited October 7, 2005
    Photos not uploading
    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?
    mdm wrote:
    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! :):
  • mdmmdm Registered Users Posts: 9 Beginner grinner
    edited October 12, 2005
    Windows Fix
    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
  • firecat53firecat53 Registered Users Posts: 13 Big grins
    edited December 13, 2005
    Backgrounding smugmug.py
    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:
    smugmug.py create 2005-October --category=Family 2005-10-18/* 2005-10-24/* --quiet &
    

    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
  • ruttrutt Registered Users Posts: 6,511 Major grins
    edited December 13, 2005
    firecat53 wrote:
    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:
    nohup smtool.py ... &
    

    and see what happens.
    If not now, when?
  • firecat53firecat53 Registered Users Posts: 13 Big grins
    edited December 13, 2005
    re: Backgrounding smugmug.py
    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
Sign In or Register to comment.