Source

HSmugAPI /

Filename Size Date modified Message
Network
3.2 KB
1.5 KB
1.7 KB
2.7 KB
71 B
473 B
INSTALLING

hg clone https://bitbucket.org/dbpatterson/hsmugapi/
or
wget http://dbpatterson.com/static/hsmugapi-0.1.tar.gz

Then grab the json library by Paul Brown:
darcs get http://datapr0n.com/repos/perpubplat

and install it:
cd perpubplat/json
runghc Setup.lhs configure
runghc Setup.lhs make
runghc Setup.lhs make install

And then install, making sure you have curl already:
cd hsmugapi
runghc Setup.hs configure
runghc Setup.hs build
runghc Setup.hs install



API
here is a (very) short description of the public api:

-- for the following, the Bools are for values that can be 'Heavy',
-- the session is always first, where needed (the String).
loginAnonymously :: IO (Maybe J.Value)
loginWithPassword :: String -> String -> IO (Maybe J.Value)
logout:: String -> IO ()
usersGetTree :: String -> Maybe String -> Bool -> IO (Maybe J.Value)
albumsGet :: String -> Maybe String -> Bool -> IO (Maybe [J.Value])
albumsGetInfo :: String -> J.Value -> IO (Maybe J.Value)
imagesGet :: String -> J.Value -> Bool -> IO (Maybe [J.Value])
imagesGetInfo :: String -> J.Value -> IO (Maybe J.Value)
imagesGetURLs :: String -> J.Value -> IO (Maybe J.Value)
imagesGetEXIF :: String -> J.Value -> IO (Maybe J.Value)

-- all of the following are of type J.Value -> Maybe String except:
-- getId, getPosition, getSerial, getSize, getWidth, getHeight, and getImageCount
-- which are of type J.Value -> Maybe Double
-- and getHidden, which is of type J.Value -> Maybe Bool
-- and getCategory, getSubcategory, which are of type J.Value -> Maybe J.Value
getSessId
getId
getKey
getTitle
getAlbumURL
getLargeURL
getXLargeURL
getX2LargeURL
getX3LargeURL
getOriginalURL
getMediumURL
getSmallURL
getTinyURL
getThumbURL
getDate
getKeywords
getFormat
getCaption
getPosition
getSerial
getSize
getWidth
getHeight
getLastUpdated
getFileName
getMD5Sum
getWatermark
getHidden
getAlbum
getPublic
getName
getDescription
getImageCount
getCategory
getSubCategory
makeIdKey :: Double -> String -> J.Value 


EXAMPLE

To download all the original sized images from my smugmug site (public and private), 
a program like this will spit out a list of filenames. Process that with wget or the
 downloader of your preference.

module Main where
import Data.Maybe (fromJust, isJust)
import Network.Libraries.HSmugAPI

onlyJust m = map fromJust (filter isJust m)
mkIdKey (i, k) = makeIdKey i k
ses s = fromJust $ getSessId $ fromJust s

iGet s alb = do ims <- imagesGet (ses s) alb True
                sequence $ map putStrLn $ onlyJust $ map getOriginalURL (fromJust ims)
main = do s <- loginWithPassword "mylogin" "mypassword"
          h <- albumsGet (ses s) (Just "dbpatterson") False
          sequence $ map (iGet s) (fromJust h)
          logout (ses s)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.