Пример #1
0
def main():
    m = MovieSearchClient()

    search_by = input(("What do you want to search by ? [k]eyword /"
                       "[d]irector / [i]mdb number. "))

    if search_by == 'k':
        search = ask_for_searchword()
        resp = m.search_movie(search)
        prints_results(resp.json().get('hits'))
    elif search_by == 'd':
        search = ask_for_searchword()
        resp = m.search_director(search)
        prints_results(resp.json().get('hits'))
    elif search_by == 'i':
        search = ask_for_searchword()
        resp = m.search_imdb_number(search)
        result = resp.json()
        if result:
            print('{} by {} rate {}'.format(result.get('title'),
                                            result.get('director'),
                                            result.get('imdb_score')))
        else:
            print('No results founds')
    else:
        print('Invalid option')
Пример #2
0
def main():
    val = input('To search by keyword enter 1, director enter 2, '
                'or IMDB code enter 3.  To exit enter anything else: ')

    svc = MovieSearchClient()

    if val == '1':
        search = input('Enter a keyword: ')

        response = svc.search_keyword(search)

        results = response.json()

        for idx, item in enumerate(results['hits'], 1):
            print(f'{idx}. {item.get("title")}')
    elif val == '2':
        search = input('Enter a director: ')

        response = svc.search_director(search)

        results = response.json()

        for idx, item in enumerate(results['hits'], 1):
            print(f'{idx}. {item.get("title")}')
    elif val == '3':
        search = input('Enter a IMDB code: ')

        response = svc.search_imdb_code(search)

        results = response.json()

        print(results.get('title'))
    else:
        print('Goodbye!')