示例#1
0
def smugup(opts, args):
    albumId = opts.album
    if "_" in albumId:
        albumId, albumKey = albumId.split("_")
    logger.info("using album %s", albumId)

    # login
    m = pysmug.login()

    filenames = set()
    if not opts.overwrite:
        # get the current filenames
        images = m.images_get(albumId=albumId, albumKey=albumKey, heavy=True)
        [filenames.add(x["FileName"]) for x in images["Album"]["Images"]]

    # check for files to upload
    n = 0
    b = m.batch()
    b.concurrent = 2
    for arg in args:
        basename = os.path.basename(arg)
        if basename in filenames:
            logger.warning("skipping %s", arg)
            continue
        n += 1
        logger.info("uploading %s", arg)
        b.images_upload(albumId=albumId, filename=arg)

    # upload
    logger.info("uploading %d files", n)
    for i, (params, result) in enumerate(b()):
        logger.info("uploaded (%d/%d) %s", i, n, result)
示例#2
0
文件: smugup.py 项目: bzimmer/pysmug
def smugup(opts, args):
    albumId = opts.album
    if "_" in albumId:
        albumId, albumKey = albumId.split("_")
    logger.info("using album %s", albumId)

    # login
    m = pysmug.login()

    filenames = set()
    if not opts.overwrite:
        # get the current filenames
        images = m.images_get(albumId=albumId, albumKey=albumKey, heavy=True)
        [filenames.add(x["FileName"]) for x in images["Album"]["Images"]]

    # check for files to upload
    n = 0
    b = m.batch()
    b.concurrent = 2
    for arg in args:
        basename = os.path.basename(arg)
        if basename in filenames:
            logger.warning("skipping %s", arg)
            continue
        n += 1
        logger.info("uploading %s", arg)
        b.images_upload(albumId=albumId, filename=arg)

    # upload
    logger.info("uploading %d files", n)
    for i, (params, result) in enumerate(b()):
        logger.info("uploaded (%d/%d) %s", i, n, result)
示例#3
0
文件: slurpfromsm.py 项目: cro/pysmug
def main(argv=None):
    if argv is None:
        argv = sys.argv

    p = OptionParser(usage="usage: %prog [options] AlbumID AlbumKey\n       %prog [options] AlbumID_AlbumKey\n  (second usage is handy for copy/paste from a SmugMug URL).\n  Username and password are stored in ~/.pysmug.")
    p.add_option("-q", "--quiet", dest="quiet",
        default=False, action="store_true", help="Don't display names of images downloaded.")
    opts, args = p.parse_args()
    
    if len(args) == 1 and args[0].find("_"):
        idandkey = args[0].split("_")
        albumid = idandkey[0]
        albumkey = idandkey[1]
    elif len(args) == 2:
        albumid = args[0]
        albumkey = args[1]
    elif len(args) < 1 or len(args) > 2 or opts.help == True:
        Usage(p)
        return(-1)

    m = pysmug.login()
    b = m.batch()
    if (opts.quiet == False):
        print "Downloading..."
    total_images = 0
    for album, image in b.images_download(AlbumID=albumid, AlbumKey=albumkey):
        if (opts.quiet == False):
            targetfilename = image['Image']['FileName'].split("/")[-1]
            print targetfilename + ": " + image['stat']
        total_images += 1
        
    if (opts.quiet == False):
        print "Total images: " + str(total_images)
        
    return 0;
示例#4
0
 def __init__(self):
     self.m = pysmug.login()
     self.fields = dict(_fields)
示例#5
0
 def __init__(self):
     self.m = pysmug.login()
     self.fields = dict(_fields)
示例#6
0
 def setup_class(cls):
     cls.m = pysmug.login()