예제 #1
0
    def load_default_movies(self):
        """
        Creates movie objects and adds to the movies list.
        Returns: None
        """

        self.movies["Uriyadi"] = (Movie(
            "Uriyadi",
            "A political thriller set in the late 1990s, revolving around an engineering college in the interiors of Tamil Nadu",
            "https://upload.wikimedia.org/wikipedia/commons/f/f0/Uriyadi_Tamil_Movie.jpg",
            "https://www.youtube.com/watch?v=hifdGU654R4"))

        self.movies["Iraivi"] = (Movie(
            "Iraivi",
            "Three women become liberated after unfortunate circumstances drive their husbands to become involved in crime.",
            "https://upload.wikimedia.org/wikipedia/en/3/36/Iraivi.jpg",
            "https://www.youtube.com/watch?v=DH3iKNTT9-M"))

        self.movies["Kabali"] = (Movie(
            "Kabali",
            "An aged gangster tries to protect his family and his business from his enemies.",
            "https://upload.wikimedia.org/wikipedia/en/9/9e/Rajinikanth_in_Kabali.jpg",
            "https://www.youtube.com/watch?v=9mdJV5-eias"))

        self.movies["Virumandi"] = (Movie(
            "Virumandi",
            "A reporter researching the death penalty meets Virumandi and Kuthala. While listening to their versions of the same story, she realises that Virumandi is being punished for a crime he did not commit.",
            "https://upload.wikimedia.org/wikipedia/en/thumb/7/75/Virumaandi.jpg/220px-Virumaandi.jpg",
            "https://www.youtube.com/watch?v=fLhW-oYtd4Q"))
예제 #2
0
def main():
    """
    Main function to store a list of Movie objects
    then generate proper HTML file.
    """
    mission_impossible_vi = Movie(
        title="Mission Impossible VI",
        poster_image_url="images/Mission-Impossible-Poster.jpg",
        trailer_youtube_url="https://www.youtube.com/watch?v=hR-0po0hzDQ")
    transformer_iii = Movie(
        title="Transformer III",
        poster_image_url="images/TransformersIII-Poster.jpg",
        trailer_youtube_url="https://www.youtube.com/watch?v=kHRf01Gjosk")
    independence_day = Movie(
        title="Independence Day",
        poster_image_url="images/Independence-Day-Poster.jpg",
        trailer_youtube_url="https://www.youtube.com/watch?v=NZZvtQtdbzM")
    manchester_by_the_sea = Movie(
        title="Manchester by the Sea",
        poster_image_url="images/Manchester-By-The-Sea-Poster.jpg",
        trailer_youtube_url="https://www.youtube.com/watch?v=gsVoD0pTge0")
    movies = \
        [mission_impossible_vi,
         transformer_iii,
         independence_day,
         manchester_by_the_sea]
    fresh_tomatoes.open_movies_page(movies)
def main():
    terminator2 = Movie("Terminator 2: Judgment Day", "https://goo.gl/x1z2jh",
                        "https://www.youtube.com/watch?v=-W8CegO_Ixw")

    desperate_measures = Movie("Desperate Measures", "https://goo.gl/TYLtYW",
                               "https://www.youtube.com/watch?v=i63VGK1ElN0")

    the_other_guys = Movie("The Other Guys", "https://goo.gl/52CCzt",
                           "https://www.youtube.com/watch?v=D6WOoUG1eNo")

    movie_list = [terminator2, desperate_measures, the_other_guys]
    fresh_tomatoes.open_movies_page(movie_list)
def make_page():
    """create move objects and display them in a webbrowser"""
    mad_max = Movie("Mad Max: Fury Road", "May 15, 2015",
                    "http://ia.media-imdb.com/images/M/MV5BMTUyMTE0ODcxNF5BMl5BanBnXkFtZTgwODE4NDQzNTE@._V1_SY317_CR2,0,214,317_AL_.jpg",
                    "https://www.youtube.com/watch?v=hEJnMQG9ev8")
    bad_boys = Movie("Bad Boys", "March 25, 1983",
                     "http://www.gstatic.com/tv/thumb/movieposters/6963/p6963_p_v7_aa.jpg",
                     "https://www.youtube.com/watch?v=RRILgwNJNkI")
    enter_the_void = Movie("Enter the Void", "September 24, 2010",
                           "https://upload.wikimedia.org/wikipedia/en/3/39/Enter-the-void-poster.png",
                           "https://www.youtube.com/watch?v=bKRxDP--e-Y")
    fresh_tomatoes.open_movies_page([mad_max, bad_boys, enter_the_void])
예제 #5
0
def main():
    """Function called when executed as standalone script"""
    movies = []
    # Add each movie and respective data to list of movies
    movies.append(
        Movie("Toy Story", "http://blog.nileslibrary.org/assets/toystory.jpg",
              "https://www.youtube.com/watch?v=KYz2wyBy3kc", 1995, 4.2))

    movies.append(
        Movie(
            "Toy Story 2",
            "http://ia.media-imdb.com/images/M/MV5BMTQ0OTU0NTcyNl5BMl5BanBnXkFtZTcwOTk5Mjc4OA@@._V1_SX640_SY720_.jpg",
            "https://www.youtube.com/watch?v=Lu0sotERXhI", 1999, 4.0))

    movies.append(
        Movie(
            "Toy Story 3",
            "http://ia.media-imdb.com/images/M/MV5BMTgxOTY4Mjc0MF5BMl5BanBnXkFtZTcwNTA4MDQyMw@@._V1_SX640_SY720_.jpg",
            "https://www.youtube.com/watch?v=JcpWXaA2qeg", 2010, 4.2))

    movies.append(
        Movie(
            "WALL-E",
            "http://images1.fanpop.com/images/image_uploads/Official-Movie-Poster-wall-e-818680_565_837.jpg",
            "https://www.youtube.com/watch?v=alIq_wG9FNk", 2008, 4.2))

    movies.append(
        Movie(
            "Cars",
            "https://www.movieposter.com/posters/archive/main/98/MPW-49378w",
            "https://www.youtube.com/watch?v=WGByijP0Leo", 2006, 3.7))

    movies.append(
        Movie(
            "Ratatouille",
            "http://pixar-planet.fr/wp-content/uploads/2010/04/affiche-ratatouille-06.jpg",
            "https://www.youtube.com/watch?v=KQUpZqshj7M", 2007, 4.0))

    movies.append(
        Movie(
            "Shrek",
            "http://vignette4.wikia.nocookie.net/shrek/images/2/2a/Shrek1.jpg/revision/latest?cb=20150119043746",
            "https://www.youtube.com/watch?v=W37DlG1i61s", 2001, 4.0))

    movies.append(
        Movie(
            "Shrek 2",
            "http://vignette3.wikia.nocookie.net/voiceacting/images/1/12/Shrek_2_DVD_Cover.jpg/revision/latest?cb=20130208181328",
            "https://www.youtube.com/watch?v=V6X5ti4YlG8", 2004, 3.6))

    movies.append(
        Movie(
            "Shrek the Third",
            "http://www.gstatic.com/tv/thumb/movieposters/159731/p159731_p_v7_aa.jpg",
            "https://www.youtube.com/watch?v=ZGmRsNM0JXM", 2007, 3.0))
    # Send list of movies to be displayed via HTML
    fresh_tomatoes.open_movies_page(movies)
def build_movie(movie_url):
    """Build movie object from movie URL page."""
    response = requests.get(movie_url)
    html = Soup(response.text, 'html.parser')
    title_tag = html.find('h1', {'itemprop': 'name'})
    title, year = title_tag.text.strip().split('\xa0')
    year = year[1:-1]
    duration = html.find('time', {'itemprop': 'duration'}).text.strip()
    duration_minutes = calculate_mins(duration)
    rating = html.find('span', {'itemprop': 'ratingValue'}).text
    mpaa_rating = html.find('meta', {
        'itemprop': 'contentRating'
    }).attrs['content']
    if mpaa_rating.upper() not in Movie.MPAA_RATINGS:
        mpaa_rating = ''
    poster_url = html.find('div', {'class': 'poster'}).find('img').attrs['src']
    synopsis = html.find('div', {'class': 'summary_text'}).text.strip()
    cast = html.find('table', {'class': 'cast_list'})
    cast_links = cast.find_all('td', {'itemprop': 'actor'})
    starring = [cast_links[0].text.strip(), cast_links[1].text.strip()]
    trailer_tag = html.find('a', {'itemprop': 'trailer'})
    trailer_url = trailer_tag.attrs['data-video'] if trailer_tag else ''

    movie = Movie(title, synopsis, rating, poster_url, duration_minutes,
                  starring, trailer_url, mpaa_rating, year)
    return movie
예제 #7
0
def get_douban(key):
    """
    This function for search movie info with key from douban api.

    Parameters:
        key - search key word.

    Returns:
        Return movie object list.
    """
    response = urllib.urlopen('https://api.douban.com/v2/movie/search?q='+ key +'&count=' + str(search_count))
    html = response.read()
    jsonMap = json.loads(html)
    movies = []
    for subject in jsonMap['subjects']:
        alt = subject['alt']
        play_url = 'http://v.youku.com/v_show/id_XMjg0ODU2MDY4MA==.html?spm=a2hww.20027244.ykRecommend.5~5!2~5~5~A'
        movie = Movie(
                subject['title'],#电影标题
                subject['rating']['average'],#电影评分
                subject['rating']['stars'],#星星数
                subject['collect_count'],#电影收藏次数
                subject['genres'],#电影分类
                subject['casts'],#电影主演
                subject['directors'],#电影导演
                subject['year'],#上映时间
                subject['images']['medium'],#电影海报
                play_url
                )
        movies.append(movie)

    return movies if len(movies) > 0 else None
예제 #8
0
def main():
    # To read movies' data from the json file
    json_path = "./movies.json"
    movie_list = Movie.make_movies_list(json_path)

    # To generate the final HTML file and open it in browser
    fresh_tomatoes.create_main_page(movie_list)
예제 #9
0
def create_movies_from_json(json_file):
    """Transform a json file in a Movie instance"""
    movie_list = []
    for data in json.load(open(json_file)):
        movie = Movie(data["title"], data["image"], data["trailer"])
        movie_list.append(movie)
    return movie_list
def get_data():
    # To get popular movie data and return a list of Movie instance
    url = 'https://api.themoviedb.org/3/movie/popular?api_key=1f4817acb34ea3063d54e2f4c641c5cb&language=en-US&page=1'
    response = request.urlopen(url)
    # opening the url and getting the data
    response_read = str(response.read())

    # Removing unwanted characters from response_read
    response_read = response_read.replace('b\'', '')
    response_read = response_read.replace('\'', '')
    response_read = response_read.replace('\\\\\"', '')
    response_read = response_read.replace('\\', '')

    # Converting String to Python Dictionary
    movie_dict = yaml.load(response_read)['results']

    # list to store Movie instances
    movies = []
    for movie in movie_dict:
        if(movie['original_language'] == 'en'):
            trailer = get_trailer_link(movie['id'])
            if(trailer is None):
                # if trailer does not exist do not include the movie
                continue
            storyline = movie["overview"]
            title = movie['title']
            poster = get_poster_link(movie['poster_path'])
            # Movie Instance and adding them to movie list
            movies.append(
                Movie(title, storyline, poster, trailer)
            )
    return movies  # returing the list of Movie instance
예제 #11
0
def init(movies_path):
    """Function to initialize the data for the application.

    Parameters:
    - movies_path - path to a file from which the initial data should
    be taken

    Returns: a list of Movie objects
    """
    try:
        # Open file specified in movies_path and populate movies list
        with open(movies_path) as movies_file:
            movies_list = []
            # Get contents of the file by lines
            contents = movies_file.readlines()
            for movie in contents:
                # Strip newline and split by comma
                movie_details = movie.rstrip().split(',')
                if len(movie_details) != 5:
                    raise ValidationError('Incorrect number of movie details')
                # Instantiate Movie class and append it to the list
                movies_list.append(Movie(*movie_details))

        if not movies_list:
            raise ValidationError('Empty file')

        return movies_list
    except IOError:
        raise ValidationError('No such file')
예제 #12
0
def load_movies_from_file(path):
    """Load movies from file and create the related classes, returning them
    as a list"""
    # Check if provided path exists, including relative folders
    split_path = path.split("/")[:-1]
    check_folder = ""
    for folder in split_path:
        check_folder += folder + "/"
        if not os.path.isdir(check_folder):
            print("""The directory specified do not exist,
                please check the path to the movie file.""")
            #Return empty movie list if failed to load file
            return []

    if os.path.isfile(path):
        # Open file, parse it as json
        with open(path) as movie_file:
            json_object = json.loads(movie_file.read())
            movie_list = []
            for element in json_object:
                movie_list.append(
                    Movie(element["title"], element["poster"],
                          element["trailer"], element["date"],
                          element["main_cast"]))
            return movie_list
    else:
        print("There is no file to load movies from, check provided file.")
def getMovieObject(movie_dict, key):
    title = movie_dict['title']
    poster_path = movie_dict['poster_path']
    trailer_path = getTrailerPath(movie_dict['id'], key)
    storyline = movie_dict['overview']
    release_date = movie_dict['release_date']
    return Movie(title, poster_path, trailer_path, storyline, release_date)
def get_movie(tmdb_id):
    """Returns a Movie object given the TMDb ID of a movie.

    Args:
        tmdb_id (str): The unique ID for a movie on the TMDb website.

    Returns:
        An object of class Movie.
    """

    # TMDb API key
    api_key = "a67cb6ea86667935513fc0b0e51f0d1e"

    # Retrieve movie information
    url = ("https://api.themoviedb.org/3/movie/" + tmdb_id + "?api_key=" +
           api_key)
    movie = json.load(urllib.urlopen(url))
    title = movie['original_title']
    duration = movie['runtime']
    overview = movie['overview']
    poster_image_url = "http://image.tmdb.org/t/p/w1920" + movie['poster_path']

    # Retrieve YouTube trailer URL
    url = ("https://api.themoviedb.org/3/movie/" + tmdb_id +
           "/videos?api_key=" + api_key)
    movie = json.load(urllib.urlopen(url))
    trailer_youtube_url = ("https://www.youtube.com/watch?v=" +
                           movie['results'][0]['key'])

    # Return a movie object for the given movie
    return Movie(title, duration, overview, poster_image_url,
                 trailer_youtube_url)
예제 #15
0
    def _extract_movie(self, html_content):
        """Extract single movie information.

        Parameters
        ---
        html_content : string
            The HTML content fragment of one single movie information.

        Returns
        ---
        Movie
            A single `Movie` object.
        """
        # get title and trailer_url through regexp
        match = re.compile('<a href="([^"]+)" title="([^"]+)"',
                           re.DOTALL).search(html_content)
        if match:
            title = match.group(2)
            trailer_url = 'http:' + match.group(1)

        # get poster_image_url through regexp
        match = re.compile('<img.+?src="([^"]+)"',
                           re.DOTALL).search(html_content)
        if match:
            poster_image_url = match.group(1)

        movie = Movie(title, poster_image_url, trailer_url)
        return movie
예제 #16
0
    def _convert_movie_detail(self, response):
        """Convert a movie API detail response to a Movie instance

        Arguments:
            response (dict): The API response containing movie results

        Returns:
            Movie -- Movie instance
        """

        youtube_url = None

        # find the trailer url in video results
        for video in response['videos']['results']:
            if(video['type'] == 'Trailer' and video['site'] == 'YouTube'):
                youtube_url = 'https://www.youtube.com/watch?v=' + video['key']

        return Movie(
            response['id'],
            response['title'],
            response['overview'],
            TMDB.image_url + response['poster_path'],
            response['release_date'],
            youtube_url
        )
예제 #17
0
def main():
    movies = []
    for title, urls in d.items():
        poster = urls[0]
        trailer = urls[1]
        movies.append(Movie(title, poster, trailer))

    ft.open_movies_page(movies)
예제 #18
0
def getAllMovies():
    """
	Returns:
		An array of movies initialized with their supporting data.
	"""

    return [
        Movie("Gladiator",
              "https://www.movieposter.com/posters/archive/main/22/A70-11370",
              "https://www.youtube.com/watch?v=DQc0lFrHICQ"),
        Movie("Top Gun",
              "https://www.movieposter.com/posters/archive/main/15/A70-7600",
              "https://www.youtube.com/watch?v=qAfbp3YX9F0"),
        Movie("The Matrix",
              "https://www.movieposter.com/posters/archive/main/9/A70-4902",
              "https://www.youtube.com/watch?v=m8e-FF8MsqU"),
    ]
예제 #19
0
def split_movie_details(movie_details):
    """ Split movie details from the movie details list and return a single
        movie object """
    movie_obj = Movie(movie_details[1],  # movie title
                      movie_details[2],  # movie poster url
                      movie_details[3],  # youtube trailer url
                      movie_details[4],  # movie short info
                      movie_details[5])  # wiki url
    return movie_obj
예제 #20
0
def main():
    if type(sys.argv) and len(sys.argv) > 1:
        # an option is given
        option = sys.argv[1].strip()
        if option == "-sw":
            # switches database option. If enabled then creates a db file. Else deletes if any exists.
            if MMDB.movie_db_exists():
                # if already exists disable db options.
                delete = input(
                    "DB option is enabled (All the movies added will be lost). "
                    "Do you want to disable it and hence delete the db file? Press Y/N"
                )
                if delete.lower().startswith("y"):
                    #         user wants to continue to delete db
                    MMDB.delete_db()
            else:
                # enable db options.
                MMDB.save_movie_dict()
        elif option == "-a":
            print("Interactive mode!!! add your favourite movie to MMDB.")
            while True:
                title = input("Movie title: ")
                story = input("Story line: ")
                poster = input("URL to poster image: ")
                trailer = input("URL to youtube trailer: ")
                MMDB.movies[title] = Movie(title, story, poster, trailer)
                more = input(
                    "%s is added to MMDB. Do you want to add more? Press Y/N "
                    % (title))
                if more.lower().startswith("n"): break
            MMDB.save_movie_dict()
        #
        # elif option == "-e":
        #     # fixme have to add edit option
        #     print("Interactive mode!!! edit your favourite movie in the MMDB.")
        elif option == "-d":
            print("Interactive mode!!! delete your favourite movie from MMDB.")
            while True:
                print("ID: Movie Title")
                movie_titles = sorted(MMDB.movies.keys())
                for idx, title in enumerate(movie_titles):
                    print("%s : %s " % (idx + 1, title))
                # id of the movie to delete
                idx = eval(
                    input(
                        "Enter the id of the movie that you want to delete: "))
                if type(idx) == int and idx <= len(MMDB.movies):
                    MMDB.movies.pop(movie_titles[idx - 1])
                    more = input(
                        "%s is deleted from MMDB. Do you want to delete more? Press Y/N "
                        % (movie_titles[idx - 1]))
                    # exit interactive mode
                    if more.lower().startswith("n"): break

    # generate html code and display that to user.
    fresh_tomato.open_movies_page(MMDB.get_movies_as_list())
예제 #21
0
def get_movie_list():
    '''
    Fetch the movie list

    This currently fetches the movie list from a JSON file
    but can be updated later to fetch from a remote endpoint
    '''

    with open('movie_list.json', 'r') as json_file:
        return [Movie(**i) for i in json.load(json_file)]
def main():
	forrest_gump = Movie('Forrest Gump', 'Depicts a life of a man',
		'https://upload.wikimedia.org/wikipedia/en/6/67/Forrest_Gump_poster.jpg',
		'https://www.youtube.com/watch?v=uPIEn0M8su0')

	avatar = Movie('Avatar', 'A man tries to save the planet Pandora',
		'https://upload.wikimedia.org/wikipedia/en/b/b0/Avatar-Teaser-Poster.jpg',
		'https://www.youtube.com/watch?v=5PSNL1qE6VY')

	shawshank = Movie('The Shawshank Redemption', 'A innocent banker tries to escape from prison',
		'https://upload.wikimedia.org/wikipedia/en/8/81/ShawshankRedemptionMoviePoster.jpg',
		'www.youtube.com/watch?v=6hB3S9bIaco')

	three_idiots = Movie('3 Idiots', 'Two friends are looking for a long-lost friend',
		'https://upload.wikimedia.org/wikipedia/en/d/df/3_idiots_poster.jpg',
		'www.youtube.com/watch?v=xvszmNXdM4w')

	movie_list = [forrest_gump, avatar, shawshank, three_idiots]
	open_movies_page(movie_list)
def get_movies_from_json():
    with open('movies_list.json') as movies_file:
        data = json.load(movies_file)

    movies = []
    for movie_data in data["movies"]:
        m = Movie(movie_data["title"], movie_data["duration"],
                  movie_data["trailer_youtube_url"],
                  movie_data['poster_image_url'], movie_data['storyline'])
        movies.append(m)
    return movies
예제 #24
0
def main():
    hp1 = Movie(
        "Harry Potter 1",
        "https://images-na.ssl-images-amazon.com/images/I/51asM9eJMXL.jpg",
        "https://www.youtube.com/watch?v=VyHV0BRtdxo"
    )

    hp2 = Movie(
        "Harry Potter 2",
        "https://i.ytimg.com/vi/zX_PHrUTbLM/movieposter.jpg",
        "https://www.youtube.com/watch?v=1bq0qff4iF8"
    )

    hp3 = Movie(
        "Harry Potter 3",
        "https://cdn.europosters.eu/image/750/posters/harry-potter-3-forest-i621.jpg",  # noqa
        "https://www.youtube.com/watch?v=lAxgztbYDbs"
    )

    hp4 = Movie(
        "Harry Potter 4",
        "https://i.ytimg.com/vi/gPhXYeoCDlQ/movieposter.jpg",
        "https://www.youtube.com/watch?v=3EGojp4Hh6I"
    )

    hp5 = Movie(
        "Harry Potter 5",
        "https://i.ytimg.com/vi/Ak6vjFiZUqM/movieposter.jpg",
        "https://www.youtube.com/watch?v=y6ZW7KXaXYk"
    )

    hp6 = Movie(
        "Harry Potter 6",
        "https://i.ytimg.com/vi/TA7uBS2hfik/movieposter.jpg",
        "https://www.youtube.com/watch?v=jpCPvHJ6p90"
    )

    hp71 = Movie(
        "Harry Potter 7 pt.1",
        "https://imgc.allpostersimages.com/img/print/posters/harry-potter-7-part-2-one-sheet_a-G-8554781-0.jpg",  # noqa
        "https://www.youtube.com/watch?v=MxqsmsA8y5k"
    )

    hp72 = Movie(
        "Harry Potter 7 pt.2",
        "https://static.posters.cz/image/1300/plagaty/harry-potter-7-part-2-teaser-i11030.jpg",  # noqa
        "https://www.youtube.com/watch?v=VGBLczT_sLo"
    )

    # Open movie trailer page with list of provided movie instances
    open_movies_page([hp1, hp2, hp3, hp4, hp5, hp6, hp71, hp72])
예제 #25
0
def main():
    """
    Generate and serve a simple movie trailer website containing some of my
    favorite movies.
    :return: None
    """
    rocky = Movie('Rocky',
                  'https://i.imgur.com/xrJTWjZ.jpg',
                  'https://www.youtube.com/watch?v=3VUblDwa648')

    lethal_weapon = Movie('Lethal Weapon',
                          'https://i.imgur.com/ZIN7nQ2.jpg',
                          'https://www.youtube.com/watch?v=bKeW-MGu-qQ')

    apollo_13 = Movie('Apollo 13',
                      'https://i.imgur.com/7ZaAFsK.jpg',
                      'https://www.youtube.com/watch?v=KtEIMC58sZo')

    la_confidential = Movie('L.A. Confidential',
                            'https://i.imgur.com/4DHMZnZ.jpg',
                            'https://www.youtube.com/watch?v=6sOXrY5yV4g')

    inglourious_basterds = Movie('Inglourious Basterds',
                                 'https://i.imgur.com/Kzg3Ujp.jpg',
                                 'https://www.youtube.com/watch?v=KnrRy6kSFF0')

    moonrise_kingdom = Movie('Moonrise Kingdom',
                             'http://i.imgur.com/ALm2Ciu.jpg',
                             'https://www.youtube.com/watch?v=7N8wkVA4_8s')

    movies = [rocky, lethal_weapon, apollo_13, la_confidential,
              inglourious_basterds, moonrise_kingdom]

    open_movies_page(movies)
예제 #26
0
def create_movies():
    """
    create movies objects
    then send them to open_movies_page function to create the html page
    """
    Movie(title="Big hero 6",
          image_url="http://www6.0zz0.com/2017/09/21/19/825878595.jpg",
          youtube_url="https://www.youtube.com/watch?v=z3biFxZIJOQ")
    Movie(title="frozen",
          image_url="http://www9.0zz0.com/2017/09/21/19/871522439.jpg",
          youtube_url="https://www.youtube.com/watch?v=TbQm5doF_Uc")
    Movie(title="Kimi no na Wa(your name)",
          image_url="http://www9.0zz0.com/2017/09/21/19/467915164.jpg",
          youtube_url="https://www.youtube.com/watch?v=hRfHcp2GjVI")
    Movie(title="A Silent Voice",
          image_url="http://www9.0zz0.com/2017/09/21/19/194459511.jpg",
          youtube_url="https://www.youtube.com/watch?v=nfK6UgLra7g")
    Movie(
        title="spirited away",
        image_url="http://www9.0zz0.com/2017/09/21/19/974860969.jpg",
        youtube_url="https://www.youtube.com/watch?v=ByXuk9QqQkk",
    )
    Movie(
        title="the wind Rises",
        image_url="http://www9.0zz0.com/2017/09/21/19/474969239.jpg",
        youtube_url="https://www.youtube.com/watch?v=2QFBZgAZx7g",
    )

    open_movies_page(Movie.movies)
    def __init__(self):
        # Create Movie instances from hard coded data
        m1 = Movie(
            imdb_id='tt0097958',
            trailer_youtube_url='https://www.youtube.com/watch?v=tLVd4ipC5Lc'
        )  # noqa
        m2 = Movie(
            imdb_id='tt0071853',
            trailer_youtube_url='https://www.youtube.com/watch?v=LG1PlkURjxE'
        )  # noqa
        m3 = Movie(
            imdb_id='tt0072431',
            trailer_youtube_url='https://www.youtube.com/watch?v=mOPTriLG5cU'
        )  # noqa
        m4 = Movie(
            imdb_id='BADIDTOTESTERRORCONDITION',
            trailer_youtube_url='https://www.youtube.com/watch?v=mOPTriLG5cU'
        )  # noqa
        self.movies = [m1, m2, m3, m4]

        # Load movie data from external source: omdb api
        self.__load_movie_data_from_omdb()
def get_movies(filename):
    """
    pulls movie data from csv and returns a list a Movie objects
    """
    movies = []
    with open(filename, 'r') as file:
        reader = csv.DictReader(file)
        for movie in reader:
            movies.append(
                Movie(title=movie['name'],
                      image_url=movie['image_url'],
                      youtube_url=movie['youtube_url']))
    return movies
예제 #29
0
def entertainment_center():
    movie_list = []
    movie1 = Movie("Captain America: Civil War", \
        "https://www.youtube.com/watch?v=QGfhS1hfTWw", \
        "http://t2.gstatic.com/images?q=tbn:ANd9GcQJHE0wTHT_pNRdZlnJj5IkzF49uMF3be1gfIIKw8A8z_3oHVRO", \
        "QGfhS1hfTWw")
    movie_list.append(movie1)

    movie2 = Movie("Neighbors 2: Sorority Rising", \
        "https://www.youtube.com/watch?v=h1pA4Oio6T8", \
        "http://t2.gstatic.com/images?q=tbn:ANd9GcST6cuzBZolESt6KVcg1aUzcFAOZU9CF4YA3OCZfHsdxeSQtbH9", \
        "h1pA4Oio6T8")

    movie_list.append(movie2)

    movie3 = Movie("That Awkward Moment", \
        "https://www.youtube.com/watch?v=wRcVgJjnFLo", \
        "http://t1.gstatic.com/images?q=tbn:ANd9GcTrFSWtS5G_u88IutD_Flen9789bPanDxf1JqUNvpxFJk5cVPyL", \
        "wRcVgJjnFLo")
    movie_list.append(movie3)

    return movie_list
예제 #30
0
def get_mov_details(files):
    '''
    data is being pulled from csv creating list of objects of movie.
    '''
    movies = []
    with open(files, 'r') as file:
        reader = csv.DictReader(file)
        for movie in reader:
            movies.append(
                Movie(title=movie['name'],
                      image_url=movie['image_url'],
                      youtube_url=movie['youtube_url']))
    return movies
예제 #31
0
def get_movie(title):

    # Get the movie info from the api
    movie_json = urlopen(OMDB_API + title)
    # Set info to output
    info = movie_json.read()
    # close the request
    movie_json.close()
    # decode from json to a dictionary
    info = json.loads(info)

    # create an instance of movie with data
    movie = Movie(
        title=title,
        storyline=info["Plot"],
        poster_image_url=info["Poster"],
        rated=info["Rated"],
        runtime=info["Runtime"]
    )
    if movie.rated == "NOT RATED":
        movie.rated = "NOT-RATED"
    # return movie
    return movie
예제 #32
0
def generate_movies(codes):
    """Takes a dictionary of IMDB movie codes, generates their associated movie
    objects and generates the Fresh Tomatoes site with that data.

    Args:
        codes (dict): A dictionary of codes with the following format
            "Movie Name": "imdb_code",
            "The Martian": "tt3659388"

    Returns:
        A list of movie objects
    """
    movies = []
    for k, v in codes.iteritems():
        movies.append(Movie.from_code(v))

    return movies
예제 #33
0
def generate_movie_list_from_json():
    """
    Better way to load the list of movies is from json file. This function can be later enhanced to pull a feed from
    movie database instead.
    :return: list of movies
    """
    movie_list = []
    movies = json.loads(io.open("data.json", encoding='utf-8').read())
    for movie in movies:
        movie_to_add = Movie(movie["title"])
        movie_to_add.story_line = movie["synopsis"]
        movie_to_add.trailer_youtube_url = movie["youtubeUrl"]
        movie_to_add.poster_image_url = movie["posterUrl"]
        movie_to_add.mpaa_rating = movie["mpaaRating"]
        movie_to_add.run_time = movie["runtime"]
        movie_to_add.actors = [x.encode('utf-8') for x in movie["actors"]]
        movie_list.append(movie_to_add)
    return movie_list
예제 #34
0
def generate_movie_list():
    """
    tried this to quickly get the Page running. Seem,s redundant to call the setters for each movie repeatedly.
    :return: list of movies
    """
    school_of_rock = Movie("School Of Rock")
    school_of_rock.story_line = "When struggling musician Dewey Finn finds himself out of work, he takes over his " \
                                "roommate's <p>job as an elementary school substitute teacher and turns class into" \
                                " a rock band."
    school_of_rock.poster_image_url = "http://upload.wikimedia.org/wikipedia/en/1/11/School_of_Rock_Poster.jpg"
    school_of_rock.trailer_youtube_url = "https://www.youtube.com/watch?v=eAry-ZV_gfs"
    avengers = Movie("Avengers: Age of Ultron")
    avengers.story_line = "When Tony Stark and Bruce Banner try to jump-start a dormant peacekeeping program called " \
                          "<p> Ultron, things go horribly wrong and it's up to Earth's Mightiest Heroes to stop the" \
                          " villainous <p> Ultron from enacting his terrible plans."
    avengers.poster_image_url = "http://upload.wikimedia.org/wikipedia/en/1/1b/Avengers_Age_of_Ultron.jpg"
    avengers.trailer_youtube_url = "https://www.youtube.com/watch?v=MZoO8QVMxkk"
    hobbit = Movie("The Hobbit: The Battle of the Five Armies")
    hobbit.story_line = "Bilbo and Company are forced to engage in a war against an array of combatants and keep the" \
                        " Lonely Mountain from falling into the hands of a rising darkness."
    hobbit.poster_image_url = "http://upload.wikimedia.org/wikipedia/en/0/0e/The_Hobbit_-_The_Battle_of_the_Five_Armies.jpg"
    hobbit.trailer_youtube_url = "https://www.youtube.com/watch?v=iVAgTiBrrDA"
    madmax = Movie("Mad Max: Fury Road")
    madmax.story_line = "In a stark desert landscape where humanity is broken, two rebels just might be able to restore" \
                        " order: Max, a man of action and of few words, and Furiosa, a woman of action who is looking" \
                        " to make it back to her childhood homeland."
    madmax.poster_image_url = "https://upload.wikimedia.org/wikipedia/en/2/23/Max_Mad_Fury_Road_Newest_Poster.jpg"
    madmax.trailer_youtube_url = "https://www.youtube.com/watch?v=YWNWi-ZWL3c"
    return [school_of_rock, avengers, hobbit, madmax]
예제 #35
0
# -*- coding: utf-8 -*-
from media import Cast, Movie
import lovely_dove

# You might consider using OMDb API instead (http://www.omdbapi.com/)

# Movies (Begin) ||==================================================

## Interstellar
interstellar = Movie('Interstellar', 2014, 'Christopher Nolan', 169,
                     'Adventure, Drama, Sci-Fi',
                     'A team of explorers travel '
                     'through a wormhole in space in an attempt to ensure '
                     'humanity\'s survival.',
                     'http://www.youtube.com/embed/zSWdZVtXT7E', 5,
                     'http://upload.wikimedia.org/wikipedia/en/b/bc/Interstellar_film_poster.jpg')
interstellar.add_cast('Matthew McConaughey', True)
interstellar.add_cast('Anne Hathaway', True)
interstellar.add_cast('Jessica Chastain', True)
interstellar.add_cast('Mackenzie Foy', False)

## Agora
agora = Movie('Agora', 2009, 'Alejandro Amenábar', 127,
              'Adventure, Drama, History',
              'A historical drama set in Roman Egypt, concerning a slave who '
              'turns to the rising tide of Christianity in the hope of '
              'pursuing freedom while falling in love with his mistress, the '
              'famous philosophy and mathematics professor '
              'Hypatia of Alexandria.',
              'https://www.youtube.com/embed/RbuEhwselE0', 4.5,
              'https://upload.wikimedia.org/wikipedia/en/8/81/Agoraposter09.jpg')
import media
import fresh_tomato
import csv
from media import Movie

# read movie informations from movies_info.csv, and store in a list movies
with open("db/movies_info.csv", "rb") as csvfiles:
    movies = map(lambda entry: Movie.make_movie(entry), csv.reader(csvfiles, delimiter=","))

fresh_tomato.open_movies_page(movies)
예제 #37
0
파일: ecenter.py 프로젝트: oser520/ud
# open the database
db = shelve.open(args.dbfile, writeback=True)

# list of movies to include in trailer web page
movies = []

# process each movie title
for title in movie_titles:
    print 'Searching for movie %s' % title
    if db.has_key(title):
        print 'Movie %s found in database via search title' % title
        movies.append(db[title])
        continue
    response = get_movie_info(title)
    time.sleep(1)
    movie = Movie(response)
    if not movie.found:
        err('Error: Movie %s not found in OMDB\n' % title)
        err('Error: Response: %s\n' % response)
    elif not movie.url_poster:
        err('Error: Movie %s does not contain a poster URL\n' % title)
        err('Error: Response: %s\n' % response)
    else:
        print 'Found details for movie %s' % title
        if db.has_key(movie.title):
            print 'Movie %s found in database via OMDB title' % movie.title
            movie = db[movie.title]
        else:
            movie.search_title = title
            movie.url_trailer = get_trailer_url(movie.title)
            db[movie.title] = movie