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

Program in Python that use fresh_tomatoes for generating site that provides posters and
trailers for your favorite movies. If you want to add your favorite movies you have to
put them in entertainment_center like I did(you can see my movies there),in parenthesis
you have to put title, link to the poster and link to trailer. Then just put your movies
in brackets at the bottom movies=[yourmovie1, yourmovie2, ....]. When you put all your
favorite movies there simply save the file, and run entertainment_center.
It should generate site with your favorite movies. You can find url's of movie data manually
or use my findPoster&etc if you are more advanced user.

This program is in python. You should download python 2.7.14 from https://www.python.org/downloads/
for running this program.


For finding movie data I used API https://www.themoviedb.org/documentation/api.
There are comments on how it works in the file called findPoster&etc.
This was my first time with API and Im sure that there are better ways for getting the movie data.
If you want to use this code first you need register on https://www.themoviedb.org and get
API-KEY from there. And simply past it in findPoster&etc - tmdb.API_KEY = 'your-key-here'.
I found this tmdbsimple wraper on github it hellped me a lot to understand how can i use API.
Special effect on movie site word found on http://freefrontend.com/css-text-effects/.


37 changes: 37 additions & 0 deletions entertainment_center.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import media
import fresh_tomatoes
'''
This script produce movie site.
Includes instances of the class Movie with movie data,
list of movies that is used by fresh_tomatoes,
function open_movies_page from fresh_tomatoes
that creates html webpage with our movies.
'''
# Blade Runner 2049
blade_runner_2049 = media.Movie("BladeRunner2049",
"https://image.tmdb.org/t/p/w500/c0jCZGc0XMW1TpRP2nRCrwY3Tex.jpg", # NOQA
"https://www.youtube.com/watch?v=gCcx85zbxz4")
# Goodfellas
goodfellas = media.Movie("Goodfellas",
"https://image.tmdb.org/t/p/w500/pwpGfTImTGifEGgLb3s6LRPd4I6.jpg", # NOQA
"https://www.youtube.com/watch?v=qo5jJpHtI1Y")
# Godfather
godfather = media.Movie("The Godfather",
"https://image.tmdb.org/t/p/w500/rPdtLWNsZmAtoZl9PK7S2wE3qiS.jpg", # NOQA
"https://www.youtube.com/watch?v=w0VGcWHkNeA")
# Apocalypse Now
apocalypse_now = media.Movie("Apocalypse Now",
"https://image.tmdb.org/t/p/w500/jcvJ2xcVWU9Wh0hZAxcs103s8nN.jpg", # NOQA
"https://www.youtube.com/watch?v=IkrhkUeDCdQ")
# The Departed
departed = media.Movie("The Departed", "https://image.tmdb.org/t/p/w500/tGLO9zw5ZtCeyyEWgbYGgsFxC6i.jpg", # NOQA
"https://www.youtube.com/watch?v=n4O3x5BH18E")
# The Shawshank Redemption
shawshank = media.Movie("The Shawshank Redemption", "https://image.tmdb.org/t/p/w500/9O7gLzmreU0nGkIB6K3BsJbzvNv.jpg", # NOQA
"https://www.youtube.com/watch?v=K_tLp7T6U1c")
# list of movies
movies = [blade_runner_2049, goodfellas, godfather,
apocalypse_now, departed, shawshank]
# function from fresh_tomatoes for creating webpage
fresh_tomatoes.open_movies_page(movies)

33 changes: 33 additions & 0 deletions findPoster.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import json
import tmdbsimple as tmdb

tmdb.API_KEY = ''

'''
function that finds movie with the phrase
and prints url of poster and trailer
just write title in title
This function also prints other movies that have
phrase that is in the title.
So you can find posters and trailers of other movies.
'''

title = "The Godfather"
search = tmdb.Search()


def get_movie(title):

dataBase = search.movie(query=title)
number = dataBase['results'][0]['id']
movie = tmdb.Movies(number)
print ('https://www.youtube.com/watch?v=' +
movie.videos()['results'][0]['key'])
print ('https://image.tmdb.org/t/p/w500' +
dataBase['results'][0]['poster_path'])
for s in search.results:
print(s['title'])

get_movie(title)
#Adding closing option on enter#
input('Press Enter to exit')
142 changes: 137 additions & 5 deletions fresh_tomatoes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<style type="text/css" media="screen">
body {
padding-top: 80px;
background: linear-gradient(#403B4A, #E7E9BB);
}
#trailer .modal-dialog {
margin-top: 200px;
Expand Down Expand Up @@ -56,6 +57,109 @@
top: 0;
background-color: white;
}
.navbar-inverse{
background:#403B4A;
}
.word {
text-align:center;
background:transparent;
color:#D4AF37;
font-family:'Roboto';
font-weight:300;
font-size:32px;
padding-top:0px;;
height:12vh;
overflow:hidden;
-webkit-backface-visibility: hidden;
-webkit-perspective: 1000;
-webkit-transform: translate3d(0,0,0);
top:0;
}

.word {
display:inline-block;
overflow:hidden;
white-space:nowrap;
}

.word:first-of-type { /* For increasing performance
ID/Class should've been used.
For a small demo
it's okaish for now */
animation: showup 7s infinite;

}

.word:last-of-type {
width:0px;
animation: reveal 7s infinite;
}

.word:last-of-type span {
margin-left:-355px;
animation: slidein 7s infinite;
}

@keyframes showup {
0% {opacity:0;}
20% {opacity:1;}
80% {opacity:1;}
100% {opacity:0;}
}

@keyframes slidein {
0% { margin-left:-800px; }
20% { margin-left:-800px; }
35% { margin-left:0px; }
100% { margin-left:0px; }
}

@keyframes reveal {
0% {opacity:0;width:0px;}
20% {opacity:1;width:0px;}
30% {width:355px;}
80% {opacity:1;}
100% {opacity:0;width:355px;}
}
.container1 {
position: relative;
}

.image1 {
display: block;
width: 100%;
height: auto;
}

.overlay1 {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
opacity: 0;
transition: .5s ease;
background: transparent;
}
.container1:hover .overlay1 {
opacity: 1;
}

.text1 {
color: gold;
font-size: 20px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
text-align: center;
background:linear-gradient(#6D6027, #D3CBB8);

}

</style>
<script type="text/javascript" charset="utf-8">
// Pause the video when the modal is closed
Expand All @@ -82,13 +186,16 @@
});
});
</script>

</head>
'''


# The main page layout and title bar
main_page_content = '''

<body>

<!-- Trailer Video Modal -->
<div class="modal" id="trailer">
<div class="modal-dialog">
Expand All @@ -107,14 +214,31 @@
<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="#">
<div class="word">


<span>M</span>
<span>O</span>
<span>V</span>
<span>I</span>
<span>E</span>
<span>-</span>
<span>S</span>
<span>I</span>
<span>T</span>
<span>E</span>
</div>

</a>

</div>
</div>
</div>
</div>
</div>
<div class="container">
{movie_tiles}
</div>
{movie_tiles}
</body>
</html>
'''
Expand All @@ -123,8 +247,13 @@
# A single movie entry html template
movie_tile_content = '''
<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>
<div class="container1">
<img src="{poster_image_url}" width="220" height="342" quality:40>
<div class="overlay1">
<div class="text1">Click for Trailer</div>
</div>
</div>
<h2>{movie_title}</h2>
</div>
'''

Expand Down Expand Up @@ -165,3 +294,6 @@ 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)



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


class Movie():
"""
Class that gives a way to store movie data.
"""
# constructor of the class Movie
def __init__(self, movie_title, poster, movie_trailer):
self.title = movie_title
self.poster_image_url = poster
self.trailer_youtube_url = movie_trailer

Binary file added media.pyc
Binary file not shown.