From a8ac24b022a86014002b31da27156afd349679b8 Mon Sep 17 00:00:00 2001 From: Mateusz Kamer Date: Thu, 8 Mar 2018 17:10:10 +0200 Subject: [PATCH 1/4] Add files via upload Movie Trailer Website Project. Full Stack Web Developer Nano degree Program --- README.md | 26 +++++++- entertainment_center.py | 37 +++++++++++ findPoster&etc.py | 31 +++++++++ fresh_tomatoes.py | 142 ++++++++++++++++++++++++++++++++++++++-- fresh_tomatoes.pyc | Bin 0 -> 7505 bytes media.py | 13 ++++ media.pyc | Bin 0 -> 719 bytes 7 files changed, 242 insertions(+), 7 deletions(-) create mode 100644 entertainment_center.py create mode 100644 findPoster&etc.py create mode 100644 fresh_tomatoes.pyc create mode 100644 media.py create mode 100644 media.pyc 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&etc.py b/findPoster&etc.py new file mode 100644 index 000000000..916a45a58 --- /dev/null +++ b/findPoster&etc.py @@ -0,0 +1,31 @@ +import json +import tmdbsimple as tmdb + +tmdb.API_KEY = 'your api here' + +''' + 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) 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 0000000000000000000000000000000000000000..168719877283a1a45704bee277a855b8bb9e6afc GIT binary patch literal 7505 zcmcIp>vG%16<$iVVzGA8wByM%Go4veiAf~_Nl`b4CKbn$9J`6_jO-+h>XZW#OA-=@ zrLjvXG}gXbc17TM7i=3HS%SDAB_{S{l5n6qRW?+}n@ zrFQ_({Wm^O)V1F*mT%nJf4cYlhi?veUk|+9e1m?tXZyWoLHGq45Vo_M=lC=RLfgF4 zw*w_~voO+K>kd|!DeY=c>^=yD>htGvU~4JVtwtpr&WCGmSr)%9rB*tyhkS!uRIJsr3SXC2Hme)=H@{fpD+fCV zpWVN|dUp!&V%l1Pp}3w1czGZl+p|EACwnuv2X@eN{SbAnYH-J7(eK!GbidBGH!scf zh1=`vI^PTljyEOf%YC>3vDNXU5;JIrQn}idex2KGCB2ar2?qqqh{9U0kt|}+^c#do z=gjin~6bv@aX&=Z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4obO2yRGs<>K4 zVkt_iWs|evm-3xbp^K~rlA8jd(I*f@DGQ9kLTEcaO%@#Y6dsWQ5${ZK$a$LIxSbRi zmh+8DSl&@zUqLa5Qv%nZ`#ps{!*hd*HqRrc`Oe%sAJbhtDc*n-gfQfe&4O{N0(Tvh z5yCA|;RR44JGn$omn$QfsivjtWC7h`S-$%r(8hjbGs$AGj%+?7+3HFtsP* zMj`_gVBJA4Db!Gb#p`dCd%a;_8}~Zhw6<$^p1IzG>O=i-^w1e?9sG2*zw`a!%cnu` z{L#MKdfY$wa=Z2NUh1Bk5p`G>-+B6YL|jGMYOw7L4HKi^*Y@l*9~G}0E8Xvn3N z`d4_w#s;?auhE}Xj>fADcG);eBn(Y2Qv#uv@S{+J?)3F<=d6Z`!3<+mupVlhhU^JS zcm{Bc-4iYH0-Q(&m?^4gv&p>XI3z?Rf?=l3E~V*(OT3Hb%&=i1G2#|#Af5i#jJF723OemPV=+gU_7OJ)8{Y!Z` z(H{Z`Rf4o=C2XjekE^g6MN8PiQtk%6@8z!Jdo#DRcs;j_zjqgmVUalKYYZzu14@K# z!HUR!U;)8DqW}yGBdb z(J@M<^k2V^-T)_EixR$AHivnP9+I^g6^{c5Sd)<^E9rzWljaI%3=L6(1U0mE->4p! zVAG~SALU|AP*Hwt2XYL>mT3IYP(yZ(OTciXTST%k5fn|KWZ}d#875$s}He*jYXGavu} literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..4f0a505cb2d23b509dca3798f6c3701cf3ace60e GIT binary patch literal 719 zcmbVJ!A{#i5FN)5NLr*y9D3|ZTztyCRaI4lYdHk&f4?*W<2v|b~k@M8UKCyH(%1*%JKaP<1;{oH=~+p4l92Sf{C~9!k#iV-26*V82neZ6b>=zEu8M&sd>Qvv0Xv$8{_(Jg+5g%GPtYD3c@y@nz$y;3k`$9HYeAa2v$h5jblr z%0_tlnfioV*LZ7XoU)r(b+x)j$*tnj+L`91DfaM=d1g>a$Ip5e!+bdC<@7dE_pM(n c+PK9IQ|i81V(;jfPT+gLr5}2ati3+wufyi0wEzGB literal 0 HcmV?d00001 From 9c184a0c83eee77c4a436ec60fb279026c6b09de Mon Sep 17 00:00:00 2001 From: Matthew Kamer Date: Tue, 20 Mar 2018 18:23:13 +0200 Subject: [PATCH 2/4] Changed name and added exit command --- findPoster.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 findPoster.py diff --git a/findPoster.py b/findPoster.py new file mode 100644 index 000000000..c2451eb1f --- /dev/null +++ b/findPoster.py @@ -0,0 +1,33 @@ +import json +import tmdbsimple as tmdb + +tmdb.API_KEY = 'bb55ad7fd47a1eb21f426a7636d528ca' + +''' + 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') From 66356924f6cf7201e1d3f33f0b61fe8cb2d1a00b Mon Sep 17 00:00:00 2001 From: Mateusz Kamer Date: Tue, 20 Mar 2018 18:29:02 +0200 Subject: [PATCH 3/4] Update findPoster.py --- findPoster.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/findPoster.py b/findPoster.py index c2451eb1f..01f26f116 100644 --- a/findPoster.py +++ b/findPoster.py @@ -1,7 +1,7 @@ import json import tmdbsimple as tmdb -tmdb.API_KEY = 'bb55ad7fd47a1eb21f426a7636d528ca' +tmdb.API_KEY = '' ''' function that finds movie with the phrase From 958339148558ec0bfecb09f5a0253d86f3f8e4bb Mon Sep 17 00:00:00 2001 From: Mateusz Kamer Date: Tue, 20 Mar 2018 18:30:06 +0200 Subject: [PATCH 4/4] Delete findPoster&etc.py --- findPoster&etc.py | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 findPoster&etc.py diff --git a/findPoster&etc.py b/findPoster&etc.py deleted file mode 100644 index 916a45a58..000000000 --- a/findPoster&etc.py +++ /dev/null @@ -1,31 +0,0 @@ -import json -import tmdbsimple as tmdb - -tmdb.API_KEY = 'your api here' - -''' - 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)