def add_new(film): db = HomeDB() db.add_entry_to_main(film) db.set_ratings(film) row_id = db.get_row_id(film) db.add_director(film, row_id) db.add_links(film, row_id) db.conn.commit() db.conn.close()
def check_movie(film=None, name=None, year=None): # name = film.name # year = film.year if name is not None: f = Film() f.name = name f.year = year check_movie(film=f) else: print('Validating movie information..') if check(film) is not True: print('Movie Not present in database. Adding..') print(film.name + ', ' + str(film.year)) if film.imdb_link is None: review_info1.load_imdb_url(film) review_info1.imdb_content(film) print(film.genre) review_info1.get_rotten_link(film) review_info1.rotten(film) review_info1.get_score(film) add_new(film) print('Added.') return else: db = HomeDB() row_id = db.get_row_id(film) # These snippets could be written as separate functions in order to improve functionality. # Checking for links if db.check_links(film) is None: print('Links not present in the database. Adding.') if film.imdb_link is None: review_info1.load_imdb_url(film) review_info1.get_rotten_link(film) db.add_links(film, row_id) db.conn.commit() print('Added new links for the movie.') else: print('Links present in the database.') # Checking for director if db.check_director(film) is None: print('Director not present. Adding.. ') review_info1.get_director(film) db.add_director(film, row_id) db.conn.commit() db.conn.close() load_info(film) print('Done verifying..') return