from IPTC import IPTCInfo import sys, os, shutterfly class ShutterflyUploadr: def __init__(self): pass def grab_new_images( self ): """ Recurses thru directories and looks for images to upload. I only want to upload my '5-star' images, so we scan the IPTC tags for 'r5', my way of tagging my pics I really like (usually get prints of r5s) """ images = [] for dirpath, dirnames, filenames in os.walk('/users/chad/pictures/2008'): for f in filenames : # Grab IPTC keywords info = IPTCInfo(os.path.join(dirpath, f)) # Is it a 5-star photo? if 'r5' in info.keywords: ext = f.lower().split(".")[-1] if ( ext == "jpg" ): images.append( os.path.normpath( dirpath + "/" + f ) ) images.sort() return images def upload( self ): """ Upload images to Shutterfly """ user = 'your_user_name' pwd = 'your_password' sfly = shutterfly.Shutterfly(user,pwd) # Get an existing album album = sfly.getAlbums()['Album_Name'] image_list = self.grab_new_images() for image in image_list: album.uploadPhoto(image, 'image/jpeg', os.path.basename(image)) if __name__ == '__main__': sfu = ShutterflyUploadr() sfu.upload()