Skip to content
This repository was archived by the owner on Jun 28, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
# ud036_StarterCode
Source code for a Movie Trailer website.

## What's needed for this code to work
All that's really needed is for you to have an IDLE (preferably `Python`) to run the code. You would also need to have a browser for the code to open in. I use `Google Chrome` as my webbrowser.

## How the code work
In the project, there are several files that work with each other. There's a file called `media.py` which holds the `class Movie()`. The class movie was created so that a user can call it and create instances of their favorite movies. When the user create those instances, the `__init__` function inside the `class Movie()` gets initialize. The `__init__` function takes in the parameters of self, movie_title, movie_storyline, poster_image, and trailer_youtube. These parameters set the poster image and youtube trailer for your website. There's another function inside the class Movie() that's called an `instance method`. This `instance method` is what opens the webbrowser and go to the youtube trailer on the web. You can create all of your movie instances in the same flie as `media.py` but it's good practice to keep your classes separated. The `entertainment_center.py` file is were all of the movie instances are created. The final file needed to make this code work is a file called `fresh_tomatoes.py`. This file contains the contents of the `html5`, `css`, `JavaScript`, `jQuery`, and `python` code for the functionality and design of the website. This file has a function called `open_movies_page()` which takes in a parameter called `movies`. The `movies` parameter is just an array you'll have to create of all the movie instances you created earlier. Once you create the `movies` array and call it inside of `open_movies_page()` you should be able to create a website with all of your favorite movies.

## Issues
You may run into some issues if you running an old version of python or a newer version. If that's the case make sure you check the documentation to make sure you changes accordingly.
116 changes: 116 additions & 0 deletions entertainment_center.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# coding=utf-8
import fresh_tomatoes
import media

# dragonballz is an instance of class Movie()
dragonballz = media.Movie(
'DBZ Resurrection of F',
'''Goku and Vegeta must protect Earth from the resurrected Frieza and his army
of soldiers.''',
'https://upload.wikimedia.org/wikipedia/en/6/6a/DBZ_THE_MOVIE_NO._15.png',
'https://www.youtube.com/watch?v=5z_nWwKBiRw')

# the town is an instance of class Movie()
the_town = media.Movie(
'The Town',
'''Doug MacRay (Ben Affleck) leads a band of ruthless bank robbers and has no
real attachments except for James (Jeremy Renner), who -- despite his
dangerous temper -- is like a brother. Everything changes for Doug when
James briefly takes a hostage, bank employee Claire Keesey. Learning that
she lives in the gang\'s neighborhood, Doug seeks her out to discover what
she knows, and he falls in love. As the romance deepens, he wants out of
his criminal life, but that could threaten Claire.''',
'https://upload.wikimedia.org/wikipedia/en/d/da/The_Town_Poster.jpg',
'https://www.youtube.com/watch?v=WcXt9aUMbBk')

# den of thieves is an instance of class Movie()
den_of_thieves = media.Movie(
'Den of Thieves',
'''Nick O\'Brien is the hard-drinking leader of the Regulators, an elite unit
of the Los Angeles County Sheriff\'s Department. Ray Merrimen is the
recently paroled leader of the Outlaws, a gang of ex-military men who use
their expertise and tactical skills to evade the law. O\'Brien, Merrimen
and their crews soon find themselves on a direct collision course as the
criminals hatch an elaborate plan for a seemingly impossible heist -- the
city\'s Federal Reserve Bank.''',
'https://i2.wp.com/teaser-trailer.com/wp-content/uploads/Den-of-Thieves-movie-poster-2.jpg?ssl=1', # noqa
'https://www.youtube.com/watch?v=HusPt_1-qto')

# avatar is an instance of class Movie()
avatar = media.Movie(
'Avatar',
'''On the lush alien world of Pandora live the Na\'vi, beings who appear
primitive but are highly evolved. Because the planet\'s environment is
poisonous, human/Na\'vi hybrids, called Avatars, must link to human minds
to allow for free movement on Pandora. Jake Sully (Sam Worthington), a
paralyzed former Marine, becomes mobile again through one such Avatar and
falls in love with a Na\'vi woman (Zoe Saldana). As a bond with her grows,
he is drawn into a battle for the survival of her world''',
'http://cdn1-www.comingsoon.net/assets/uploads/2009/08/file_57684_0_avatarhiresposter.jpg', # noqa
'https://www.youtube.com/watch?v=5PSNL1qE6VY')

# boruto the movie is an instance of class Movie()
boruto_the_movie = media.Movie(
'Boruto The Movie',
'''Several years after the end of the Shinobi War, Naruto\'s son Boruto is
about to enter the Chûnin exams alongside Sarada Uchiha and the mysterious
Mitsuki.''',
'https://vignette.wikia.nocookie.net/naruto/images/5/50/Boruto_the_Movie_poster_2.png/revision/latest?cb=20161117222759', # noqa
'https://www.youtube.com/watch?v=Qyonn5Vbg7s')

# hitch is an instance of class Movie()
hitch = media.Movie(
'Hitch',
'''Dating coach Alex "Hitch" Hitchens (Will Smith) mentors a bumbling
client, Albert (Kevin James), who hopes to win the heart of the glamorous
Allegra Cole (Amber Valletta). While Albert makes progress, Hitchens faces
his own romantic setbacks when proven techniques fail to work on Sara Melas
(Eva Mendes), a tabloid reporter digging for dirt on Allegra Cole\'s love
life. When Sara discovers Hitchens\' connection to Albert -- now Allegra\'s
boyfriend -- it threatens to destroy both relationships.''',
'https://images-na.ssl-images-amazon.com/images/I/419kSwDKlYL.jpg',
'https://www.youtube.com/watch?v=dMaq_pfxs-0')

# avengers is an instance of class Movie()
avengers = media.Movie(
'Avengers: Age of Ultron',
'''When Tony Stark (Robert Downey Jr.) jump-starts a dormant peacekeeping
program, things go terribly awry, forcing him, Thor (Chris Hemsworth), the
Incredible Hulk (Mark Ruffalo) and the rest of the Avengers to reassemble.
As the fate of Earth hangs in the balance, the team is put to the ultimate
test as they battle Ultron, a technological terror hell-bent on human
extinction. Along the way, they encounter two mysterious and powerful
newcomers, Pietro and Wanda Maximoff.''',
'http://static.tvtropes.org/pmwiki/pub/images/avengers_age_of_ultron.jpg',
'https://www.youtube.com/watch?v=JAUoeqvedMo')

# transformer is an instance of class Movie ()
transformer = media.Movie(
'Transformer: The Last Knight',
'''Humans are at war with the Transformers, and Optimus Prime is gone. The
key to saving the future lies buried in the secrets of the past and the
hidden history of Transformers on Earth. Now, it\'s up to the unlikely
alliance of inventor Cade Yeager, Bumblebee, an English lord and an Oxford
professor to save the world.''',
'https://upload.wikimedia.org/wikipedia/en/2/26/Transformers_The_Last_Knight_poster.jpg', # noqa
'https://www.youtube.com/watch?v=6Vtf0MszgP8')

# ninja assassin is an instance of class Movie ()
ninja_assassin = media.Movie(
'Ninja Assassin',
'''Trained in methods of killing from an early age, Raizo (Rain) is a member
of the secret clan of assassins known as the Ozunu. After the Ozunu kill
his friend, however, Raizo breaks free from them and vanishes. Meanwhile,
Europol agent Mika Coretti (Naomie Harris) discovers a money trail linking
the the group to murders. Raizo saves Mika from his former comrades and
joins forces with her to bring down the Ozunu forever.''',
'https://images-na.ssl-images-amazon.com/images/M/MV5BMTcxNDYzMjU1Ml5BMl5BanBnXkFtZTcwMTYzOTM3Mg@@._V1_UY1200_CR90,0,630,1200_AL_.jpg', # noqa
'https://www.youtube.com/watch?v=NhYH26KTNbQ')

movies = [
dragonballz,
the_town, den_of_thieves,
avatar, boruto_the_movie,
hitch, avengers, transformer,
ninja_assassin]
fresh_tomatoes.open_movies_page(movies)
19 changes: 18 additions & 1 deletion fresh_tomatoes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
<style type="text/css" media="screen">
body {
padding-top: 80px;
background-color: black;
color: white;
}
.navbar-brand {
list-style: none;
display: flex;
}
.navbar-brand li {
padding: 0 15px;
display: flex;
align-items: center;
}
#trailer .modal-dialog {
margin-top: 200px;
Expand All @@ -40,7 +51,7 @@
padding-top: 20px;
}
.movie-tile:hover {
background-color: #EEE;
background-color: gray;
cursor: pointer;
}
.scale-media {
Expand Down Expand Up @@ -108,6 +119,11 @@
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">Fresh Tomatoes Movie Trailers</a>
<ul class="navbar-brand">
<li><a class="navbar-brand" href="#">My Favorites</a></li>
<li><a class="navbar-brand" href="#">Coming Soon</a></li>
<li><a class="navbar-brand" href="#">In Theaters</a></li>
</ul>
</div>
</div>
</div>
Expand Down Expand Up @@ -165,3 +181,4 @@ def open_movies_page(movies):
# 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)

30 changes: 30 additions & 0 deletions media.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import webbrowser

'''This class Movie() is like a blue print with a constructor that creates
instance variables to create an instance of the class Movie(). After an
instance is created, the class constructor gets called. This is the
__init__ method inside the class. This __init__ method initializes all
of the data inside the class. The constuctor uses the key word self.
You can think of the key word self as itself of the instances in question.
So if an instance of Avatar is being created, Avatar is self.'''
class Movie():
'''This class a way to store my favorite movies and related information'''
VALID_RATINGS = ['G', 'PG', 'PG-13', 'R']

'''The variables associated with a specific instance is called instance
variables. These are unique to an object. They can be access by using the
self keyword inside the class and the instance name outside the class.'''
def __init__(self,
movie_title,
movie_storyline,
poster_image,
trailer_youtube):
self.title = movie_title
self.storyline = movie_storyline
self.poster_image_url = poster_image
self.trailer_youtube_url = trailer_youtube

'''This function inside of the Movie class that has the first argument
as self is called instance method.'''
def show_trailer(self):
webbrowser.open(self.trailer_youtube_url)