def add_all_movies(self): local_http = http.request('GET', self._movies_url) date = BeautifulSoup(local_http.data, 'html.parser').find('a', attrs={ 'class': 'selected' }).text[:5] year = str(date) + "." + str(current_year) for movie in self.get_all_movies(): local_soup = BeautifulSoup(str(movie), 'html.parser') movie_name = local_soup.find('h5').text try: self._movies[movie_name]['projections'] except KeyError: if movie_name in Movie.all_movies: self._movies[movie_name] = Movie.all_movies[movie_name] else: time.sleep(10) movie = Movie(url=home + local_soup.a['href']) movie.load_movie(movie_name) self._movies[str(movie)] = movie.__dict__ row = local_soup.find_all('div', attrs={'class': 'row'}) for current in row: mini_soup = BeautifulSoup(str(current), 'html.parser') attributes = [] for image in mini_soup.find_all('img'): if image['alt']: attributes.append(image['alt']) if attributes: for item in current.find('div', attrs={ 'class': 'timelineSet' }).text.split(): try: self._movies[str(movie)]['projections'].append({ 'features': attributes, 'projection': item, 'date': year }) except KeyError: self._movies[movie_name]['projections'].append({ 'features': attributes, 'projection': item, 'date': year })
def parse_add(self, imdbID): print('Inform the database file name: ') db_filename = input() movie = Movie(http_get(imdbID)) pos = ms.writeAppend(db_filename, movie, keep_open=False) print('Inform the B Tree indexing fields: ') btree_fields = input().replace(' ', '').split(',') for field in btree_fields: node_element = BTreeNodeElement(movie.__dict__[field], pos, []) bt = BTree.load(field) bt.insert(node_element) bt.save(field) print('Inform the Patricia Trie indexing fields: ') ptrie_fields = input().replace(' ', '').split(',') for field in ptrie_fields: pt = PatriciaTrie.load(field) pt.insert(movie, position=pos, db_filepath=db_filename, λ=lambda x: x.__dict__[field].lower()) pt.save(field) print('Inform the Reversed File indexing fields: ') rf_fields = input().replace(' ', '').split(',') for field in rf_fields: rf.inc_reversed_file(db_filename, movie, field) return movie.title + ' was added to the database'
def read_json(self, json_file): ''' read the data from a json file to create the movie list keyword arguments: json_file (string) the path to the json file ''' def parse_params(json_element): ''' returns an array of objects to compose a media with ease keywords arguments: json_element (Object) -- a python object converted from a json element attributes: title (string) -- the media title summary (string) -- the media summary url (string) -- the media url featured (boolean) -- if the media is featured or not. Default false ''' def evaluate(param, else_value=None): ''' check if the given param has value to return or returns an optional value if it has not keyword arguments: param (string) -- the attribute name from the jsn_element else_value (variant) -- the value to be used if the attribute has no value. defautl None ''' if param not in json_element: return else_value return json_element[param] title = evaluate('title') summary = evaluate('description') url = evaluate('url') featured = evaluate('featured', False) return title, url, summary, featured json_file = json.load(open(json_file, 'r')) for json_nodes in json_file: movie = Movie(json_nodes['title'], json_nodes['sinopse'], json_nodes['year']) if 'trailers' in json_nodes: for trailer in json_nodes['trailers']: attr = parse_params(trailer) movie.add_trailer(attr[0], attr[1], attr[3]) if 'posters' in json_nodes: for poster in json_nodes['posters']: attr = parse_params(poster) movie.add_poster(attr[0], attr[1], attr[2]) self.add(movie)
def process(movie_path, record_dir_format, class_mapping): try: records = [] for label in class_mapping.items(): record = Record() record.dir_format = record_dir_format record.label = label record.threshold = config["threshold"] record.skip_frame_interval = config["skip_frame_interval"] record.prepare() records.append(record) model = keras.models.load_model(model_file_path, compile=False) predictor = Predictor(model, config["image_size_px"]) movie = Movie(movie_path, config["skip_frame_interval"], records, predictor) if movie.is_completed_clip(): return movie.capture() movie.write_period_to_file() except Exception as e: print("record ERROR: ", movie_path) print(e) print(traceback.format_exc())
import math from matplotlib import patches from lib.Interpolation import Interpolation from lib.data.interval import Interval from lib.data.options import Options from lib.data.property import Property from lib.movie import Movie from lib.scene import Scene from lib.shapes.animated_grid import AnimatedGrid from lib.animation_initializers.value_animation import ValueAnimation # Create a new movie with one scene movie = Movie() scene = Scene() movie.scenes.append(scene) # Create a grid with center (0, 0), with 30 points in each direction that are .05 apart grid = AnimatedGrid((0, 0), 30, .05) # Add the visible parts of the grid to the scene scene.add_artists(grid.artists) # Add a circle (the "unit circle") to the scene scene.add_artists([patches.Circle((0, 0), .5, facecolor='None')]) interpolation = Interpolation.quintic # Add an animation of the theta parameters of the points in the grid to the scene (rotate every point pi radians with # respect to the origin)
def step_set_movie_name(context, movie_name): context.movie = Movie() context.movie.set_movie(movie_name)
def test_read_movies_from_file(self): Store.set_file(file_path) a = Movie.read_movies_from_file()[0] self.assertIsInstance(a, Movie)
def test_add_movie_into_file(self): Store.set_file(file_path) args = ["Super Man", "2013", "8.5"] self.assertTrue(Movie.add_movie_into_file(args))
def test_accessors_value(self): a = Movie("Iron Man3", "2013", "8.5") self.assertEqual("Iron Man3", a.get_movie() ) self.assertEqual("2013", a.get_date() ) self.assertEqual("8.5", a.get_rating())