def main():
    """ Run this file to build the site """
    fresh_tomatoes.open_movies_page(entertainment_center.get_movies())
Exemple #2
0
def main():
    """
    main subroutine
    """
    movies = get_movies('data/movie_collection.csv')
    open_movies_page(movies)
def main():
    """
    main subroutine
    """
    movies = get_movies('data/movie_collection.csv')
    open_movies_page(movies)
Exemple #4
0
def create_movie_tiles_content(movies):
    """Generate the <movie-tile> elements"""
    content = ''  # The HTML content for this section of the page
    for movie in movies:
        # Append the card for the movie with its content filled in
        content += MOVIE_TILE_CONTENT.format(
            title=movie.title,
            poster=movie.poster,
            youtube=movie.youtube,
        )
    return content


def open_movies_page(movies):
    """Create index.html"""
    # Create or overwrite the output file
    output_file = open('../generated/index.html', 'w')

    # Replace the movie tiles placeholder generated content
    rendered_content = MAIN_PAGE_CONTENT.format(
        movie_tiles=create_movie_tiles_content(movies))

    # Output the file
    output_file.write(MAIN_PAGE_HEAD + rendered_content)
    output_file.close()


MOVIES = get_movies()  # Get a list of our favorite movies from movies.txt
open_movies_page(MOVIES)  # Generate a website from the list
Exemple #5
0
def get_imdb_data():
    data = json.loads(urllib.urlopen("http://www.omdbapi.com/?t="+request.form['movie-title']).read())
    if data["Response"] == "True":
        entertainment_center.add_movie(data)
    return entertainment_center.get_movies()
Exemple #6
0
def index_page():
    return entertainment_center.get_movies()
                              if youtube_id_match else None)

        # Append the tile for the movie with its content filled in
        content += movie_tile_content.format(
            movie_title=movie.title,
            poster_image_url=movie.poster_image_url,
            trailer_youtube_id=trailer_youtube_id)
    return content


def open_movies_page(movies):
    # Create or overwrite the output file
    output_file = open('fresh_tomatoes.html', 'w')

    # Replace the movie tiles placeholder generated content
    rendered_content = main_page_content.format(
        movie_tiles=create_movie_tiles_content(movies))

    # Output the file
    output_file.write(main_page_head + rendered_content)
    output_file.close()

    # open the output file in the browser (in a new tab, if possible)
    url = os.path.abspath(output_file.name)
    webbrowser.open('file://' + url, new=2)


# Main code
result = entertainment_center.get_movies()
open_movies_page(result)