Ejemplo n.º 1
0
def test_search():
    results = NineAnime.search('dragon ball super')

    assert len(results) == 30
    assert results[0].title.lower() in [
        'dragon ball super', 'dragon ball super movie'
    ]
Ejemplo n.º 2
0
def search(query):
    # Since this function outputs to stdout this should ideally be in
    # cli. But it is used in watch too. :(
    search_results = NineAnime.search(query)
    click.echo(format_search_results(search_results))

    val = click.prompt('Enter the anime no: ', type=int, default=1)

    try:
        url = search_results[val - 1].url
        title = search_results[val - 1].title
    except IndexError:
        logging.error('Only maximum of 30 search results are allowed.'
                      ' Please input a number less than 31')
        sys.exit(1)

    logging.info('Selected {}'.format(title))

    return url