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()
continue next2_s = next_s.next_sibling if next2_s and isinstance(next2_s, Tag) and next2_s.name == 'br': text = str(next_s).strip() if text: (name, year) = parse(text) print('Adding ' + name + ', ' + str(year) + '..') film = Film() film.name = name film.year = year load_url(film) imdb_meta(film) rotten(film) get_score(film) db.add_entry_to_main(film) db.set_ratings(film) if count % 10 == 0: db.conn.commit() print('Added.') time.sleep(3) except: print(sys.exc_info()[0]) # db.conn.commit() # db.conn.close() fp.write(str(sys.exc_info()[0]) + '\n') print('Added all movies.') db.conn.commit() fp.close() db.conn.close() # print(br.next_sibling.strip())
print('Loading movies from IMDb 250 to Database..') print('Beginning..') try: while row_id <= 250: print('Adding ' + str(row_id) + '..') row = db.get_row_by_id(row_id) row_id = row_id + 1 film = Film() film.name = row[1] film.year = row[2] load_url(film) imdb_meta(film) rotten(film) get_score(film) home_db.add_entry_to_main(film) home_db.set_ratings(film) del film print('Added ') time.sleep(3) if row_id % 10 == 0: home_db.conn.commit() except: print(sys.exc_info()[0]) print('Added movies to database.') home_db.conn.commit() home_db.conn.close() db.conn.close() # print(row[2])