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]
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