예제 #1
0
 def get_movie(self, node) -> Movie:
     """
     Returns a Movie object with all the data found in the bs4 node
     :param node: A soup object positioned in the movie root
     :return: The Movie object
     """
     # Get the link for the movie and generate a soup for this movie subpage
     # This is required because synopsis and duration are obtained from the subpage
     subpage = self.get_movie_soup(self.get_link(node))
     # Create a Movie object and return it on the fly getting each argument from it's own method
     return Movie(title=self.get_title(node), director=self.get_director(node), section=self.get_section(node),
                  synopse=self.get_synopsis(subpage), duration=self.get_duration(subpage))
예제 #2
0
    def insert_movie(**fields):
        movie = Movie(fields.get('id'), fields.get('name'), fields.get('year'),
                      fields.get('director'), fields.get('duration'),
                      fields.get('rating'), fields.get('users_votes'),
                      fields.get('budget'), fields.get('opening_revenue'),
                      fields.get('total_revenue'),
                      fields.get('motion_picture_rating'),
                      fields.get('release_date'), fields.get('genres'),
                      fields.get('studios'), fields.get('cast'),
                      fields.get('countries'))

        DBManager.session.add(movie)
        DBManager.session.commit()