GithubHelp home page GithubHelp logo

pyzenfolio's Introduction

PyZenfolio

https://badge.fury.io/py/pyzenfolio.png

Light-weight Zenfolio API Python wrapper.

Using this wrapper is pretty straight-forward and does not require to use any special data-structures. Everything is returned as an AttrDict (same as dict however dictionary items can be accessed via Python attribute dot notation foo['bar'] == foo.bar).

Example

from pyzenfolio import PyZenfolio

api = PyZenfolio(auth={'username': 'foo', 'password': 'bar'})
api.Authenticate()

# lookup user
user = api.LoadPublicProfile()
# AttrDict allows to access items like this
domain = user.DomainName
uploaded_photos = user.PhotoCount

# create photoset
photoset = api.CreatePhotoSet(
    user.RootGroup.Id,
    attr={
        'Title': 'foo'
    }
)
photoset_url = photoset.PageUrl

# upload image
api.UploadPhoto(photoset, 'bar.jpg')

# get image download URL
image = api.LoadPhotoSetPhotos(photoset.Id)
url = image.OriginalUrl

Warning

This is a beta release. Please report bugs via GitHub issues.

Bitdeli badge

pyzenfolio's People

Contributors

miki725 avatar bitdeli-chef avatar

Stargazers

 avatar

Watchers

Mike avatar James Cloos avatar  avatar Andrew avatar  avatar

pyzenfolio's Issues

Error in example code

The below code didn't work for me.

create photoset

photoset = api.CreatePhotoSet(
user.RootGroup.Id,
attr={
'Title': 'foo'
}
)

What did work was to replace attr= with photoset=
By the way, thanks for doing this. Here is a simple example of uploading photos in a set of directories:

from pyzenfolio import PyZenfolio
from sys import exit, argv
import os.path
from glob import glob

"""
This script uploads jpg format photos from a list of directors
in a file named uploaddirs.txt. The format of uploaddirs.txt
is one directory name per line and should be the full path. The
photos are uploaded into a Group named 'Upload' and the photos from
each directory are loaded into a photoset with a name equal
to the last component of the directoy. There is no error checking, etc.
"""

api=PyZenfolio(auth={'username': 'myusername', 'password':'mypassword'})
api.Authenticate()

user=api.LoadPublicProfile()
g=api.LoadGroup(user.RootGroup.Id, recursive=True)
el=g.Elements

find folder name "Upload"

for e in el:
typ=e['$type']
title=e['Title']
id=e['Id']
#print("%s:%s:%s" % (e['$type'], e['Title'], e['Id']))
if title == 'Upload': break
print('upload folder id=',id)
upload_id=id

with open('uploaddirs.txt','r') as inf:
for l in inf:
p=l.strip()
if not os.path.isdir(p):
print('%s is not a directory, skipping' % d)
continue
d=os.path.basename(os.path.normpath(p))
print(d)
photoset = api.CreatePhotoSet(upload_id, photoset={'Title':d})
for f in glob(os.path.join(p,'*.jpg')):
print(os.path.basename(f))
api.UploadPhoto(photoset,f)

AddMessage generates APIError

I give AddMessage a mailbox_id and a message to post to it, both strings. pyzenfolio generates an APIError with the following traceback

File "api.py", line 194, in AddMessage
validate_object(message, 'MessageUpdater', 'AddMessage')
File "validate.py", line 148, in validate_object
''.format(data_struct, method))
APIError: `MessageUpdater` must be a dict for `AddMessage` method.

Presumably, AddMessage should build a MessageUpdater dict and validate+send that instead of the user's message input; or users should have a more obvious way of building the MessageUpdater object themselves.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.