Пример #1
0
def list_categories(args):
    imgsrc = ImgSrc(username, password)

    categories = imgsrc.get_categories()

    for i in categories:
        if int(i['parent_id']) == 0:
            print "+ %s : %s" % (i['id'], i['name'])
            for j in categories:
                if int(j['parent_id']) == int(i['id']):
                    print "  + %s : %s" % (j['id'], j['name'])
Пример #2
0
def create_album(args):
    if len(args) != 2:
        usage()

    imgsrc = ImgSrc(username, password)
    
    name = unicode(args[0], sys.stdin.encoding)
    cat_id = args[1]

    album_id = imgsrc.create_album(name, cat_id)
    print "New album created, id = %s" % album_id
Пример #3
0
def list_albums(args):
    imgsrc = ImgSrc(username, password)

    albums = imgsrc.get_albums()

    for i in albums:
        #print i.name
        if i.photos and i.modified and i.name:
            print "%s : %s (%s; %s)" % (i.id, i.name, i.photos, i.modified)
        else:
            print "%s : <no data>" % (i.id)
Пример #4
0
def add_photo(args):
    if len(args) < 2:
        usage()

    album_id = args[0]
    files = args[1:]

    imgsrc = ImgSrc(username, password)
    store_id = imgsrc.get_store()

    album = ImgSrcAlbum(album_id, store_id, (username, password))

    for file in files:
        if urlparse.urlparse(file)[0] == '':
            url = ''.join(["file://", urllib.pathname2url(os.path.abspath(file))])
        else:
            url = file
        album.add_photo(url)

        print "Image '%s' uploaded!" % url