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
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,43 @@
# ud036_StarterCode
Source code for a Movie Trailer website.

Purpose of this code is to create a webpage that will allow you to click on a picture and play youtube videos.

There are 3 primary py files in this grouping:
media2.py = class formating module for the movies content
entertainment_center2.py = Execution and content module: listing of the movies, details about the movies, links and corresponding functions
fresh_tomatoes.py = webpage module. script that will launch the website with mark up language. Uses entertainment_center2 as the content module.


#media2.py
There is 1 parent class and 1 child class in this file. Intent is to make it modular for it can grow over time.
There are a total of 6 entries that are standardized across the group
2 entries are inhereted from the 'Videos' object
4 are unique to the 'Movies' object
Youtube is the source of choice when opening a trailer. I tried secondary sources but the play back would fail often.
wikimedia is the source of choice for images. I attempted several other sites and file formats, but hit many errors.


# Areas for improvment.
- Figure out why wikimedia is the only functioning source for images
- Figure out why youtube is the only functioning source for playing movies.

#enterainment_center
- import media2 for class formatting
- import fresh_tomatoes for launching the webpage

- list out your favorite movies and follow the formating from media2 file.
- 'movies' is a variable for an array of the favorite movies
- fresh_tomatoes.open_movies_page is the function launging the website.

# Areas for improvement.
- this is fine for a small list, but a larger list should be in our sourced from a more comprehensive database.

# fresh_tomatoes
Provided code from Udacity to launch the website.

I made changes the to header by adding a little spanish lingo
Also added the details from entertainment_center.py to be included in the web page. This includes the inhereted instance variables which shows the code is working throughout the environment


Finally I wrote this README cause, you know...I'm having fun with this and want to practice how I plan to play:)
54 changes: 54 additions & 0 deletions entertainment_center2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#media2 is the formating module for classes
import media2
#fresh_tomatoes is the module to run the web page
import fresh_tomatoes

toy_story = media2.Movie(
"Toy Story",
"A story of a boy and his toys that come to life",
"http://upload.wikimedia.org/wikipedia/en/1/13/Toy_Story.jpg",
"https://www.youtube.com/watch?v=4KPTXpQehio",
"160",
"4.5 of 5!"
)
#print(toy_story.storyline)

avatar = media2.Movie(
"Avatar",
"A marine on an alien planet fights and has alien sex",
#"https://ep01.epimg.net/cultura/imagenes/2017/04/23/actualidad/1492982810_329408_1492984569_noticia_normal_recorte1.jpg"
"https://upload.wikimedia.org/wikipedia/en/thumb/5/5c/Avatar_picture.jpg/220px-Avatar_picture.jpg",
#"https://zardra.deviantart.com/art/Feel-the-peace-Avatar-148548255",
#"http://james-camerons-avatar.wikia.com/wiki/File:Main_Wallpaper.png",
"http://www.youtube.com/watch?v=-9ceBgWV8io",
"150",
"4 of 5!"
)
#print(avatar.poster_image_url)

dirty_girl = media2.Movie (
"Dirty Girl",
"A young girl who is stereotyped goes on a road trip with her overweight alternative lifesyle male friend to discover herself. Really its a movie about teenage stereo typyes.",
"https://media.npr.org/assets/img/2011/10/03/dg_d008_00183r_wide-ea07d599e9d17ee9820019a037a4e635d1e5a785-s900-c85.jpg",
#"https://youtu.be/Qy3eAiB5UPo"
"https://www.youtube.com/watch?v=3DylhbVj8DY",
"139",
"0.5 of 5!"
)

million_dolar = media2.Movie (
"Million Dollar Baby",
"A young girl learns how to fight, kicks ass, and breaks her neck because Client Eastwood is slow and lazy",
"https://images-na.ssl-images-amazon.com/images/M/MV5BMTkxNzA1NDQxOV5BMl5BanBnXkFtZTcwNTkyMTIzMw@@._V1_UY1200_CR92,0,630,1200_AL_.jpg",
"https://www.youtube.com/watch?v=4B0zmj0-Iac",
"Not Enough",
"25 of 5!"
)
#list of movies from above
movies = [toy_story, avatar, dirty_girl, million_dolar]
#fresh_tomatoes is the script running webpage
fresh_tomatoes.open_movies_page(movies)


#dirty_girl.show_trailer()
#dirty_girl.show_poster()
141 changes: 141 additions & 0 deletions fresh_tomatoes.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Fresh Tomatoes!</title>

<!-- Bootstrap 3 -->
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap-theme.min.css">
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script>
<style type="text/css" media="screen">
body {
padding-top: 80px;
}
#trailer .modal-dialog {
margin-top: 200px;
width: 640px;
height: 480px;
}
.hanging-close {
position: absolute;
top: -12px;
right: -12px;
z-index: 9001;
}
#trailer-video {
width: 100%;
height: 100%;
}
.movie-tile {
margin-bottom: 20px;
padding-top: 20px;
}
.movie-tile:hover {
background-color: #EEE;
cursor: pointer;
}
.scale-media {
padding-bottom: 56.25%;
position: relative;
}
.scale-media iframe {
border: none;
height: 100%;
position: absolute;
width: 100%;
left: 0;
top: 0;
background-color: white;
}
</style>
<script type="text/javascript" charset="utf-8">
// Pause the video when the modal is closed
$(document).on('click', '.hanging-close, .modal-backdrop, .modal', function (event) {
// Remove the src so the player itself gets removed, as this is the only
// reliable way to ensure the video stops playing in IE
$("#trailer-video-container").empty();
});
// Start playing the video whenever the trailer modal is opened
$(document).on('click', '.movie-tile', function (event) {
var trailerYouTubeId = $(this).attr('data-trailer-youtube-id')
var sourceUrl = 'http://www.youtube.com/embed/' + trailerYouTubeId + '?autoplay=1&html5=1';
$("#trailer-video-container").empty().append($("<iframe></iframe>", {
'id': 'trailer-video',
'type': 'text-html',
'src': sourceUrl,
'frameborder': 0
}));
});
// Animate in the movies when the page loads
$(document).ready(function () {
$('.movie-tile').hide().first().show("fast", function showNext() {
$(this).next("div").show("fast", showNext);
});
});
</script>
</head>

<body>
<!-- Trailer Video Modal -->
<div class="modal" id="trailer">
<div class="modal-dialog">
<div class="modal-content">
<a href="#" class="hanging-close" data-dismiss="modal" aria-hidden="true">
<img src="https://lh5.ggpht.com/v4-628SilF0HtHuHdu5EzxD7WRqOrrTIDi_MhEG6_qkNtUK5Wg7KPkofp_VJoF7RS2LhxwEFCO1ICHZlc-o_=s0#w=24&h=24"/>
</a>
<div class="scale-media" id="trailer-video-container">
</div>
</div>
</div>
</div>

<!-- Main Page Content -->
<div class="container">
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">Los Tomatoes Frescas y Linda Trailers</a>
</div>
</div>
</div>
</div>
<div class="container">

<div class="col-md-6 col-lg-4 movie-tile text-center" data-trailer-youtube-id="4KPTXpQehio" data-toggle="modal" data-target="#trailer">
<img src="http://upload.wikimedia.org/wikipedia/en/1/13/Toy_Story.jpg" width="220" height="342">
<h2>Toy Story</h2>
<h5>A story of a boy and his toys that come to life</h5>
<h5>160 Minutes long</h5>
<h5>4.5 of 5! Tomatoes</h5>
</div>

<div class="col-md-6 col-lg-4 movie-tile text-center" data-trailer-youtube-id="-9ceBgWV8io" data-toggle="modal" data-target="#trailer">
<img src="https://upload.wikimedia.org/wikipedia/en/thumb/5/5c/Avatar_picture.jpg/220px-Avatar_picture.jpg" width="220" height="342">
<h2>Avatar</h2>
<h5>A marine on an alien planet fights and has alien sex</h5>
<h5>150 Minutes long</h5>
<h5>4 of 5! Tomatoes</h5>
</div>

<div class="col-md-6 col-lg-4 movie-tile text-center" data-trailer-youtube-id="3DylhbVj8DY" data-toggle="modal" data-target="#trailer">
<img src="https://media.npr.org/assets/img/2011/10/03/dg_d008_00183r_wide-ea07d599e9d17ee9820019a037a4e635d1e5a785-s900-c85.jpg" width="220" height="342">
<h2>Dirty Girl</h2>
<h5>A young girl who is stereotyped goes on a road trip with her overweight alternative lifesyle male friend to discover herself. Really its a movie about teenage stereo typyes.</h5>
<h5>139 Minutes long</h5>
<h5>0.5 of 5! Tomatoes</h5>
</div>

<div class="col-md-6 col-lg-4 movie-tile text-center" data-trailer-youtube-id="4B0zmj0-Iac" data-toggle="modal" data-target="#trailer">
<img src="https://images-na.ssl-images-amazon.com/images/M/MV5BMTkxNzA1NDQxOV5BMl5BanBnXkFtZTcwNTkyMTIzMw@@._V1_UY1200_CR92,0,630,1200_AL_.jpg" width="220" height="342">
<h2>Million Dollar Baby</h2>
<h5>A young girl learns how to fight, kicks ass, and breaks her neck because Client Eastwood is slow and lazy</h5>
<h5>Not Enough Minutes long</h5>
<h5>25 of 5! Tomatoes</h5>
</div>

</div>
</body>
</html>
10 changes: 8 additions & 2 deletions fresh_tomatoes.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">Fresh Tomatoes Movie Trailers</a>
<a class="navbar-brand" href="#">Los Tomatoes Frescas y Linda Trailers</a>
</div>
</div>
</div>
Expand All @@ -125,6 +125,9 @@
<div class="col-md-6 col-lg-4 movie-tile text-center" data-trailer-youtube-id="{trailer_youtube_id}" data-toggle="modal" data-target="#trailer">
<img src="{poster_image_url}" width="220" height="342">
<h2>{movie_title}</h2>
<h5>{storyline}</h5>
<h5>{length} Minutes long</h5>
<h5>{rating} Tomatoes</h5>
</div>
'''

Expand All @@ -145,7 +148,10 @@ def create_movie_tiles_content(movies):
content += movie_tile_content.format(
movie_title=movie.title,
poster_image_url=movie.poster_image_url,
trailer_youtube_id=trailer_youtube_id
trailer_youtube_id=trailer_youtube_id,
length=movie.length,
rating=movie.rating,
storyline=movie.storyline
)
return content

Expand Down
Binary file added fresh_tomatoes.pyc
Binary file not shown.
33 changes: 33 additions & 0 deletions media2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import webbrowser
import fresh_tomatoes

#This is the parent class in case we wanted to add a new sction like TV shows or something
class Video():
"""This is the inhereted variables for all classes"""
def __init__(self, length, rating):
print ("Duration and Rating Score Constructor")
self.length = length
self.rating = rating

VALID_RATINGS = ["G", "PG", "PG-13", "R"]
#Added 'Video' as the partent so 'Movie' could inheret.
class Movie(Video):
"""This class provides a way to store movie related information"""
VALID_RATINGS = ["G", "PG", "PG-13", "R"]

def __init__(self, movie_title, movie_storyline, poster_image, trailer_youtube, length, rating):
print("Chiled contstructor movie")
self.title = movie_title
self.storyline = movie_storyline
self.poster_image_url = poster_image
self.trailer_youtube_url = trailer_youtube
Video.__init__(self, length, rating)

def show_trailer(self):
webbrowser.open(self.trailer_youtube_url)

def show_poster(self):
webbrowser.open(self.poster_image_url)



Binary file added media2.pyc
Binary file not shown.