Exemplo n.º 1
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]
Exemplo n.º 2
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
Exemplo n.º 3
0
import re
import pprint

from media import Movie, TvShow
from fresh_tomatoes import open_movies_page

ROOT_DIR = os.path.dirname(__file__)
RESOURCES_DIR = os.path.join(ROOT_DIR, 'resources')

if not os.path.exists(os.path.join(RESOURCES_DIR, 'adn_trailers.db')):
    db_handler = open(os.path.join(RESOURCES_DIR, 'adn_trailers.db'), 'w')
    movies = []

    for i in range(5):
        movie_obj = Movie()
        movie_obj.title = 'Kung Fu Panda'
        movie_obj.trailer_youtube_url = 'https://www.youtube.com/watch?v=PXi3Mv6KMzY'
        movie_obj.poster_image_url = 'http://ia.media-imdb.com/images/M/MV5BMTIxOTY1NjUyN15BMl5BanBnXkFtZTcwMjMxMDk1MQ@@._V1_SX214_AL_.jpg'
        movie_obj.storyline = 'The Dragon Warrior has to clash against the savage Tai Lung as China\'s fate hangs in the balance: However, the Dragon Warrior mantle is supposedly mistaken to be bestowed upon an obese panda who is a tyro in martial arts.'
        movie_obj.release_date = '2008'
        movie_obj.actors = []

        movies.append(movie_obj)

    pickle.dump(movies, db_handler)

db_handler = open(os.path.join(RESOURCES_DIR, 'adn_trailers.db'), 'rb')
movies = pickle.load(db_handler)

open_movies_page(movies)