• Gear
  • Shots
  • Photo Craft
  • Video
  • Wide Angle
  • Support
  • New Stuff
  • More
Support SmugMug APIs, Hacks & Tricks smdown.pl - Unix command-line album downloader

Need some help with your New SmugMug Site?

Dgrin Challenges

Our Challenges moderator has lined up an new set of challenges for you. The Weekly Word Challenge. Get all the details and participate in the conversation Weekly Word Challenge.

Past DSS Challenge Winners, DSS Challenge Rules, and other important DSS Challenge information is here.

Looking for a little challenge? The Dgrin Mini-Challenges are a great way to challenge yourself. Take a moment to look through past winners and find the current Mini Challenge here.

From Around the Net

Enjoy a few of our favorite articles from around the 'net. If you have something you think we should see, post it here and we'll have a look.

Journeys

Landscapes

Sports

 
Thread Tools Display Modes
Old Oct-30-2006, 04:57 PM
#1
darryl is offline darryl OP
Major grins
smdown.pl - Unix command-line album downloader --> now OS X compatible!
Hi -- a while back I wrote a quick and dirty album downloader in Perl that scraped the HTML from your albums, grabbed links to the originals, and used curl to download the images.

One drawback to the hack was that it didn't get your files back to their original filename.

Well, I finally sat down, figured out this Smugmug API thing, and wrote myself a new version.

Basically it works like this:

smdown.pl --login login --password password http://your.smugmug.com/album

If you use John Ruttenberg's great sm_tool.py for uploading, your .smugmugrc file with login: and password: should work for smdown.pl as well, meaning you won't have to use --login and --password every time you call this script.

It requires a few fairly standard Perl modules (XML::Simple, Getopt::Long and File::Spec) and it makes calls to curl to actually talk to the Smugmug website. These come standard on most Linux/FreeBSD boxes, as well as OS X. You might be able to get this script to work in Windows as well, but I don't have the time nor inclination to test this.

Here's the link: http://www.darryl.com/smdown/

Feedback welcome. Enjoy!

Last edited by darryl; Nov-16-2006 at 12:45 AM. Reason: added OS X support
Old Oct-30-2006, 05:02 PM
#2
devbobo is offline devbobo
LR whisperer
devbobo's Avatar
Hey Darryl,

I have written a fair bit of scraping stuff in perl but not for smugmug, I am interested to know why did decided to use curl in of something like LWP, which is part of the perl distribution ?

Cheers,

David
__________________
David Parry
SmugMug API Developer
My Photos
Old Oct-30-2006, 05:10 PM
#3
devbobo is offline devbobo
LR whisperer
devbobo's Avatar
Also, you are using the old api endpoints...

https://api.SmugMug.com/hack/rest/beta.mg?method=smugmug.login.withPassword&EmailAdd ress=$login&Password=$password&Version=1.1.1&APIKe y=$apikey
https://api.SmugMug.com/hack/rest/beta.mg?method=smugmug.albums.getInfo&SessionID=$s essionid&AlbumID=$albumid
https://api.SmugMug.com/hack/rest/beta.mg?method=smugmug.images.get&SessionID=$sessi onid&AlbumID=$albumid&Heavy=1
https://api.SmugMug.com/hack/rest/beta.mg?method=smugmug.logout&SessionID=$sessionid

all become...

https://api.SmugMug.com/hack/rest/1.1.1/?method=smugmug.login.withPassword&EmailAddress=$l ogin&Password=$password&APIKey=$apikey
https://api.SmugMug.com/hack/rest/1.1.1/?method=smugmug.albums.getInfo&SessionID=$sessioni d&AlbumID=$albumid
https://api.SmugMug.com/hack/rest/1.1.1/?method=smugmug.images.get&SessionID=$sessionid&Al bumID=$albumid&Heavy=1
https://api.SmugMug.com/hack/rest/1.1.1/?method=smugmug.logout&SessionID=$sessionid

note, you can drop the Version parameter from the login method.

Cheers,

David
__________________
David Parry
SmugMug API Developer
My Photos
Old Oct-31-2006, 10:01 AM
#4
darryl is offline darryl OP
Major grins
Quote:
Originally Posted by devbobo
Also, you are using the old api endpoints...

[snip]

note, you can drop the Version parameter from the login method.

Cheers,

David
Ah, thanks David. Fixed. I didn't realize that 1.1.1 was out of beta. When I was testing w/o beta.mg or a version number in the URL, the Heavy bit didn't work for images.
Old Oct-31-2006, 10:05 AM
#5
darryl is offline darryl OP
Major grins
Quote:
Originally Posted by devbobo
Hey Darryl,

I have written a fair bit of scraping stuff in perl but not for smugmug, I am interested to know why did decided to use curl in of something like LWP, which is part of the perl distribution ?

Cheers,

David
Laziness. I did all my testing on the command-line w/ curl, so it was easier for me to cut and paste those lines into a Perl script that handles all of the logic. I come from a lazy sysadmin bastard background, so that's how I work, using Perl to glue together system tools.

Also, I think like how curl displays stats about download speed and status. Saves me from having to write progress bars, etc.

:-}

--Darryl
Old Oct-31-2006, 01:11 PM
#6
devbobo is offline devbobo
LR whisperer
devbobo's Avatar
Quote:
Originally Posted by darryl
Ah, thanks David. Fixed. I didn't realize that 1.1.1 was out of beta. When I was testing w/o beta.mg or a version number in the URL, the Heavy bit didn't work for images.
Version 1.1.1 isn't out of beta yet, Don's has just changed the api endpoints to make things easier for future development.
__________________
David Parry
SmugMug API Developer
My Photos
Old Oct-31-2006, 03:12 PM
#7
darryl is offline darryl OP
Major grins
Quote:
Originally Posted by devbobo
Version 1.1.1 isn't out of beta yet, Don's has just changed the api endpoints to make things easier for future development.
Ah, and it clearly *is* still in Beta. In smugmug.albums.getInfo, <info> changed to <Albums>. Or maybe that's because I was using the old endpoints.

Anyways, lost my Album titles for a little bit back there. I probably should do a bit more error checking. :-}

--Darryl
Old Nov-16-2006, 12:44 AM
#8
darryl is offline darryl OP
Major grins
Hi all...

Well, I finally got around to trying my script on my OS X box, and lo and behold, XML::Simple isn't installed by default. Well, phooey.

So I hacked it to work without a real XML parser. Suuuuper-hackish, but hey, it works for me. :-}

http://www.darryl.com/smdown/

Grab the one named, smdown-noxml.txt and save it as smdown.pl

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