コード例 #1
0
@click.option(
    '-u',
    '--user',
    type=click.STRING,
    required=False,
    help='Limit list to a single user. Use either Email or UserKey',
)
@click.option('--read', is_flag=True, help='include books marked as read')
@click.option(
    '--export-library',
    type=click.File(mode='w'),
    help='filepath to write raw JSON library data to.',
)
@click.pass_obj
def list(ctx, user, read, export_library):
    userlist = Globals.Settings.UserList.users
    if user:
        userlist = [Globals.Settings.UserList.getUser(user)]
    books = actions.ListBooks(userlist, read, export_library)
    headers = ['Title', 'Author', 'RevisionId', 'Owner']
    data = sorted([(
        book.Title + decorators(book),
        book.Author,
        book.RevisionId,
        book.Owner.Email,
    ) for book in books])
    click.echo(tabulate(data, headers, tablefmt=ctx['fmt']))


cli.add_command(book)
コード例 #2
0
@click.pass_obj
def add(ctx, email, password):
    user = User(Email=email)
    click.echo(
        """
    Open https://authorize.kobo.com/signin in a private/incognito window in your browser, wait till the page
    loads (do not login!) then open the developer tools (use F12 in Firefox/Chrome), select the console tab,
    and paste the following code there and then press Enter there in the browser.

    var newCaptchaDiv = document.createElement( "div" );
    newCaptchaDiv.id = "new-grecaptcha-container";
    document.getElementById( "grecaptcha-container" ).insertAdjacentElement( "afterend", newCaptchaDiv );
    grecaptcha.render( newCaptchaDiv.id, {
        sitekey: "6Le_Hc8ZAAAAAO6IMIG5zdDmANbljtXY4EHK0wzD",
        callback: function( response ) { console.log( "Captcha response:" ); console.log( response ); }
    } );

    A captcha should show up below the Sign-in form. Once you solve the captcha its response will be written
    below the pasted code in the browser's console. Copy the response (the line below "Captcha response:")
    and paste it here.
    """
    )
    captcha = input('Captcha response: ').strip()
    actions.Login(user, password, captcha)
    Globals.Settings.UserList.users.append(user)
    Globals.Settings.Save()
    click.echo('Login Success. Try to list your books with `kobodl book list`')


cli.add_command(user)