Пример #1
0
class Flickr(Action):
    name = "flickr"

    def __init__(self, cfg, card):
        key, secret = cfg.get("__main__", "flickr_key").split(":")
        self.flickr = TwistedFlickrAPI(key, secret)
        self.flickr.authenticate_console("write"
            ).addCallback(log.msg, "got flickr token")
        
    def handle_photo(self, card, files):
        ds = []
        for file in files:
            if os.path.splitext(file)[1].lower() in (".jpg",):
                ds.append(self.flickr.upload(str(file),
                is_public=card["flickr_public"] and "1" or "0"
                    ).addCallback(log.msg, "upload to flickr"))
        d = DeferredList(ds, fireOnOneErrback=1)
        d.addCallback(lambda _: (card, files))
        return d
Пример #2
0
 def __init__(self, cfg, card):
     key, secret = cfg.get("__main__", "flickr_key").split(":")
     self.flickr = TwistedFlickrAPI(key, secret)
     self.flickr.authenticate_console("write"
         ).addCallback(log.msg, "got flickr token")