def main(): keyword = input('Keyword of Title Search: ') results = api.find_movie_by_title(keyword) print(f"There are {len(results)} movies found:") for r in results: print(f"{r.title}")
def main(): # keyword = 'Python' # input('Keyword of title search: ') keyword = input('Keyword of title search: ') try: results = api.find_movie_by_title(keyword) print(f'There are {len(results)} movies found.') for r in results: print( f"{r.title} with code {r.imdb_code} has score {r.imdb_score}") except requests.exceptions.ConnectionError: print('ERROR: check you connection!') except TypeError: print('ERROR: Got Type Error!') except StopIteration: print('ERROR: We got stop itteration error') except ValueError: print('ERROR: You must enter the name') except Exception as x: print(type(x)) print(f'---- This did not work. error: {x} ----')
def main(): keyword = input('Keyword of title search: ') try: results = api.find_movie_by_title(keyword) print(f'There are {len(results)} movies found.') for r in results: print( f'{r.title} with code {r.imdb_code} has score {r.imdb_score}') app_log.trace( f'Search successful: keyword: {keyword}, {len(results)} results.') except requests.exceptions.ConnectionError: msg = 'Could not find server. Check your network connection.' print(f'Error: {msg}') app_log.warn(msg) except ValueError: msg = 'You must specify a search term.' print(f'Error: {msg}') app_log.warn(msg) except Exception as ex: msg = f"Oh that didn't work. {ex}" print(msg) app_log.exception(ex)
def main(): keyword = input('Keyword of title search: ') try: results = api.find_movie_by_title(keyword) print(f'There are {len(results)} movies found.') for r in results: print( f"{r.title} with code {r.imdb_code} has score {r.imdb_score}") app_log.trace('Search successful: keyword: {}, {:,} results.'.format( keyword, len(results))) except requests.exceptions.ConnectionError: msg = "ERROR: Could not find server. Check your network connection." print("ERROR: " + msg) app_log.warn(msg) except ValueError: msg = "ERROR: You must specify a search term." print("ERROR: " + msg) app_log.warn(msg) except Exception as x: msg = "Oh that didn't work!: {}".format(x) print(msg) app_log.exception(x)
def main(): keyword = input('Keyword of title search: ') results = api.find_movie_by_title(keyword) print(f'There are {len(results)} movies found.') for r in results: print(f"{r.title} with code {r.imdb_code} has score {r.imdb_score}")
def main(): keyword = 'Python' # input('Keyword of title search: ') results = api.find_movie_by_title(keyword) print(f'There are {len(results)} movies found.') for r in results: print(f"{r.title} with code {r.imdb_code} has score {r.imdb_score}")
def main(): keyword = input("Keyword of title search: ") results = api.find_movie_by_title(keyword) print(f"\nThere are {len(results)} movies found: \n") for r in results: # print(f" Title: {r.get('title')}") print(f'{r.title} with code {r.imdb_code} has score {r.imdb_score}')
def main(): # it is better if user put word keyword = input("Keyword of title search: ") results = api.find_movie_by_title(keyword) print(f"There are {len(results)} movies found.") for r in results: #print(f"Title: {r.get('title')}") # Before using list of Movies print(f"Title: {r.title} has score {r.imdb_score}")
def main(): print('In Main') title = input('Entry the keyword to search:') movies = api.find_movie_by_title(title) #print(movies.get('hits')) for movie in moviesjob: print( f"{movie.get('title')} with code {movie.get('imdb_code')} has score {movie.get('imdb_score')}" ) pass
def main(): keyword = input("Enter a search term: ") results = api.find_movie_by_title(keyword) print(f'\nThere are {len(results)} movies found.\n') for r in results: print( f"Title: {r.title} has score {r.imdb_score} and imdb code {r.imdb_code}" )
def main(): keyword = input('Please enter keyword: ') try: for r in api.find_movie_by_title(keyword): print(r.title) except ValueError as ve: print(ve) except TypeError as te: print(f'Empty result. {te}') except StopIteration as se: print(f'Cannot iterate through the collections. {se}') except Exception as e: print(f'{e}')
def main(): keyword = input('Keyword of title search: ') try: results = api.find_movie_by_title(keyword) print(f'There are {len(results)} movies found.') for r in results: print(f"{r.title} with code {r.imdb_code} has score {r.imdb_score}") except requests.exceptions.ConnectionError: print("ERROR: Could not find server. Check your network connection.") except ValueError: print("ERROR: You must specify a search term.") except Exception as x: print("Oh that didn't work!: {}".format(x))
def main(): keyword = input('Keyword of title search: ') try: results = api.find_movie_by_title(keyword) print(f'There are {len(results)} movies found.') for r in results: print( f"{r.title} with code {r.imdb_code} has score {r.imdb_score}") except requests.exceptions.ConnectionError: print("ERROR: Could not find server.Check your network connection.") except ValueError: print("ERROR: You must specify a search term.") except Exception as x: print("Oh that didn't work! {}".format(x))
def main(): keyword = input('Keyword of title search: ') try: results = api.find_movie_by_title(keyword) print(f'There are {len(results)} movies found.') for r in results: print( f"{r.title} with code {r.imdb_code} has score {r.imdb_score}") except ValueError: print("Oops! You need to specify a search term!") except requests.exceptions.ConnectionError: print( "Unable to connect to the movie database server. Please check your network connection." ) except Exception as x: print(f'Oops, an error occurred: ', x)
def main(): search = input('Enter a search term:') results = api.find_movie_by_title(search) print(f"There are {len(results)} results found.") for r in results: print( f" Found in Category : {r.category} has and id of {r.id}. Its url is {r.url}" ) view_id = int(input('would you like to view any of them? Enter id: ')) website = 'talkpython.fm' for r in results: if r.id == view_id: item_url = website + r.url webbrowser.open(item_url, new=2)
def main(): keyword = input('Keyword of title search:') try: results = api.find_movie_by_title(keyword) print('There are {} movies found.'.format(len(results))) for result in results: print("{} with code {} has score {}".format( result.title, result.imdb_code, result.imdb_score)) except requests.exceptions.ConnectionError: print('Error: Could not find server. Check your network connection.') except ValueError: print('Error: You must specify a search term.') except Exception as ex: print('Oh that didn\'t work: {}'.format(ex))
def main(): keyword = input('Keyword of title search: ') try: results = api.find_movie_by_title(keyword) print(f'There are {len(results)} movies found.') for r in results: print( f"{r.title} with code {r.imdb_code} has score {r.imdb_score}") except ValueError: msg = "Oops! You need to specify a search term!" print(msg) app_log.warn(msg) except requests.exceptions.ConnectionError: msg = "Unable to connect to the movie database server. Please check your network connection." print(msg) app_log.warn(msg) except Exception as x: msg = f"Oops, that didn't work! {x}" print(msg) app_log.exception(x)
def main(): keyword = input('Keyword of title search: ') results = api.find_movie_by_title(keyword) results_dict = defaultdict(list) counter = 1 print(f'There are {len(results)} search results found.') for r in results: x = r.url results_dict[counter].append(x) print( f"Result {counter} is a {r.category} with the title of '{r.title}'" ) counter += 1 grabURL = input('What url to visit?') grabURL = int(grabURL) weblink = f'https://talkpython.fm{results_dict[grabURL][0]}' webbrowser.open(weblink, new=2)
def main(): keyword = input('Keyword of title search: ') try: results = api.find_movie_by_title(keyword) print(f'There are {len(results)} movies found.') for r in results: print(f"{r.title} with code {r.imdb_code} has score {r.imdb_score}") app_log.trace('Search successful: keyword: {}, {:,} results.'.format( keyword, len(results))) except requests.exceptions.ConnectionError: msg = "Could not find server. Check your network connection." print("ERROR: " + msg) app_log.warn(msg) except ValueError: msg = "You must specify a search term." print("ERROR: " + msg) app_log.warn(msg) except Exception as x: msg = "Oh that didn't work!: {}".format(x) print(msg) app_log.exception(x)
def main(): keyword = input('Keyword of title search: ') try: results = api.find_movie_by_title(keyword) print(f'There are {len(results)} movies found.') for r in results: print( f"{r.title} with code {r.imdb_code} has score {r.imdb_score}") except requests.exceptions.ConnectionError: print( "ERROR: , could not connect to the API check whether you have juice?" ) except ValueError: print("You must enter a search term") except requests.exceptions.HTTPError: print("ERROR : You have entered an unacceptable search terms" "Please only enter alpha numeric characters") except Exception as e: #catch general exceptions print(type(e)) print(f"An error has occured --> {e}") finally: print("THis will run no matter what !")
import api def main() keyword = 'Python' # test input for api, change as you need or have it be a user input parameter. results - api.find_movie_by_title(keyword) print(f'There are {len(results)} movies found.') for r in results: print(f"{r.title} with code {r.imdb_code} has score {r.imdb_score}")
def main(): keyword = input('Please enter a title search term: ') results = api.find_movie_by_title(keyword) print(f'There are {len(results)} movie(s) found.') for r in results: print(f"Title: {r.title} with score of {r.imdb_score}")