How to use the gkeepapi.Keep function in gkeepapi

To help you get started, we’ve selected a few gkeepapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aFrankLion / hass-google_keep / custom_components / google_keep / __init__.py View on Github external
def setup(hass, config):
    """Setup the google_keep component."""

    import gkeepapi

    config = config.get(DOMAIN)

    username = config.get(CONF_USERNAME)
    password = config.get(CONF_PASSWORD)
    default_list_name = config.get(CONF_LIST_NAME)

    keep = gkeepapi.Keep()

    # Attempt to login
    login_success = keep.login(username, password)
    if not login_success:
        _LOGGER.error("Google Keep login failed.")
        return False

    def add_to_list(call):
        """Add things to a Google Keep list."""

        list_name = call.data.get(SERVICE_LIST_NAME, default_list_name)
        things = call.data.get(SERVICE_LIST_ITEM)

        # Split any things in the list separated by ' and '
        things = [x for thing in things for x in thing.split(' and ')]
github PiotrMachowski / Home-Assistant-custom-components-Google-Keep / custom_components / google_keep / sensor.py View on Github external
def setup_platform(hass, config, add_entities, discovery_info=None):
    sensor_name = config.get(CONF_NAME)
    username = config.get(CONF_USERNAME)
    password = config.get(CONF_PASSWORD)
    titles = config.get(CONF_TITLES)
    labels = config.get(CONF_LABELS)
    pinned = config.get(CONF_PINNED)
    import gkeepapi
    keep = gkeepapi.Keep()
    login_success = keep.login(username, password)
    if not login_success:
        raise Exception('Invalid username or password')
    dev = []
    hash_value = hashlib.md5(str((username, str(titles), str(labels), pinned)).encode()).hexdigest()[-10:]
    uid = '{}_{}'.format(sensor_name, hash_value)
    entity_id = async_generate_entity_id(ENTITY_ID_FORMAT, uid, hass=hass)
    dev.append(GoogleKeepSensor(entity_id, sensor_name, username, keep, titles, labels, pinned))
    add_entities(dev, True)
github kiwiz / keep-cli / kc.py View on Github external
def main(stdscr):
    fh = open('config.yml', 'r')
    config = yaml.load(fh, Loader=yaml.Loader)
    fh.close()

    # keyring.set_password('google-keep', config['username'], 'PWD')
    password = keyring.get_password('google-keep', config['username'])

    keep = gkeepapi.Keep()
    keep.login(config['username'], password)

    ui = KeepUI(stdscr, keep, config)
    ui.process()
github kunesj / conkyKeep / conkyKeep / google_keep_parsers.py View on Github external
def __init__(self, login, pwd, cache_path=None, **kwargs):
        self.keep = gkeepapi.Keep()
        self.keep.login(login, pwd)

        if cache_path is not None:
            cachefile_path = os.path.join(cache_path, self.NOTES_CACHEFILE)
            # restore dat from cache
            if os.path.exists(cachefile_path):
                with open(cachefile_path, 'r') as fh:
                    self.keep.restore(json.load(fh))
            # update data
            try:
                self.keep.sync()
            except gkeepapi.exception.ResyncRequiredException:
                self.keep = gkeepapi.Keep()
                self.keep.login(login, pwd)
                self.keep.sync()
            # save updated data to cache
            with open(cachefile_path, 'w') as fh:
                json.dump(self.keep.dump(), fh)
        else:
            self.keep.sync()
github adamyi / notes_to_keep / notes_to_keep / gkeep.py View on Github external
def login(gaia, pwd):
    # gkeepapi.node.DEBUG = True
    keep = gkeepapi.Keep()
    success = keep.login(gaia, pwd)
    return keep
github Nekmo / gkeep / google_keep_tasks / management.py View on Github external
def cli(ctx, debug, auth):
    keep = gkeepapi.Keep()
    try:
        keep.login(*get_auth(auth))
    except gkeepapi.LoginException:
        raise LoginError
    ctx.obj = {'keep': keep}