diff --git a/README.md b/README.md index 36ae53b62..654cd2ce8 100644 --- a/README.md +++ b/README.md @@ -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/. + + diff --git a/entertainment_center.py b/entertainment_center.py new file mode 100644 index 000000000..2045416f3 --- /dev/null +++ b/entertainment_center.py @@ -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) + diff --git a/findPoster.py b/findPoster.py new file mode 100644 index 000000000..01f26f116 --- /dev/null +++ b/findPoster.py @@ -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') diff --git a/fresh_tomatoes.py b/fresh_tomatoes.py index 5cd75599c..3149b3d48 100644 --- a/fresh_tomatoes.py +++ b/fresh_tomatoes.py @@ -19,6 +19,7 @@ + ''' # The main page layout and title bar main_page_content = ''' + +
- {movie_tiles} -
+ {movie_tiles} ''' @@ -123,8 +247,13 @@ # A single movie entry html template movie_tile_content = '''
- -

{movie_title}

+
+ +
+
Click for Trailer
+
+
+

{movie_title}

''' @@ -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) + + + diff --git a/fresh_tomatoes.pyc b/fresh_tomatoes.pyc new file mode 100644 index 000000000..168719877 Binary files /dev/null and b/fresh_tomatoes.pyc differ diff --git a/media.py b/media.py new file mode 100644 index 000000000..4287541c3 --- /dev/null +++ b/media.py @@ -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 + diff --git a/media.pyc b/media.pyc new file mode 100644 index 000000000..4f0a505cb Binary files /dev/null and b/media.pyc differ