From 86b8449b09d43dba1568d992c7c04e0af7d432fd Mon Sep 17 00:00:00 2001 From: Sangram Chavan Date: Wed, 11 Jan 2017 01:02:11 +0530 Subject: [PATCH] # --- entertainment.py | 49 +++++++++++++ fresh_tomatoes.html | 137 ++++++++++++++++++++++++++++++++++++ fresh_tomatoes.py | 165 ++++++++++++++++++++++++++++++++++++++++++++ fresh_tomatoes.pyc | Bin 0 -> 5352 bytes media.py | 12 ++++ media.pyc | Bin 0 -> 721 bytes 6 files changed, 363 insertions(+) create mode 100644 entertainment.py create mode 100644 fresh_tomatoes.html create mode 100644 fresh_tomatoes.py create mode 100644 fresh_tomatoes.pyc create mode 100644 media.py create mode 100644 media.pyc diff --git a/entertainment.py b/entertainment.py new file mode 100644 index 0000000..dc16b82 --- /dev/null +++ b/entertainment.py @@ -0,0 +1,49 @@ +import media +import fresh_tomatoes + +chakras = media.Movie("7 Chakras", + "How To Open Your 7 Chakras Explained", + "https://images-na.ssl-images-amazon.com/images/M/MV5BMTM3MTc3OTc0NF5BMl5BanBnXkFtZTcwOTQ0OTM1MQ@@._V1._CR34,0,295,440_UX182_CR0,0,182,268_AL__QL50.jpg", + "https://www.youtube.com/watch?v=StrbppmsZJw" + ) +#print(chakras.storyline) + +chakras1 = media.Movie("7 Chakras", + "How To Open Your 7 Chakras Explained", + "https://images-na.ssl-images-amazon.com/images/M/MV5BMTM3MTc3OTc0NF5BMl5BanBnXkFtZTcwOTQ0OTM1MQ@@._V1._CR34,0,295,440_UX182_CR0,0,182,268_AL__QL50.jpg", + "https://www.youtube.com/watch?v=StrbppmsZJw" + ) +#print(chakras1.storyline) + +chakras2 = media.Movie("7 Chakras", + "How To Open Your 7 Chakras Explained", + "https://images-na.ssl-images-amazon.com/images/M/MV5BMTM3MTc3OTc0NF5BMl5BanBnXkFtZTcwOTQ0OTM1MQ@@._V1._CR34,0,295,440_UX182_CR0,0,182,268_AL__QL50.jpg", + "https://www.youtube.com/watch?v=StrbppmsZJw" + ) +#print(chakras2.storyline) + +chakras3 = media.Movie("7 Chakras", + "How To Open Your 7 Chakras Explained", + "https://images-na.ssl-images-amazon.com/images/M/MV5BMTM3MTc3OTc0NF5BMl5BanBnXkFtZTcwOTQ0OTM1MQ@@._V1._CR34,0,295,440_UX182_CR0,0,182,268_AL__QL50.jpg", + "https://www.youtube.com/watch?v=StrbppmsZJw" + ) +#print(chakras3.storyline) + +chakras4 = media.Movie("7 Chakras", + "How To Open Your 7 Chakras Explained", + "https://images-na.ssl-images-amazon.com/images/M/MV5BMTM3MTc3OTc0NF5BMl5BanBnXkFtZTcwOTQ0OTM1MQ@@._V1._CR34,0,295,440_UX182_CR0,0,182,268_AL__QL50.jpg", + "https://www.youtube.com/watch?v=StrbppmsZJw" + ) + +chakras5 = media.Movie("7 Chakras", + "How To Open Your 7 Chakras Explained", + "https://images-na.ssl-images-amazon.com/images/M/MV5BMTM3MTc3OTc0NF5BMl5BanBnXkFtZTcwOTQ0OTM1MQ@@._V1._CR34,0,295,440_UX182_CR0,0,182,268_AL__QL50.jpg", + "https://www.youtube.com/watch?v=StrbppmsZJw" + ) + +movies = [chakras, chakras1, chakras2, chakras3, chakras4, chakras5] +fresh_tomatoes.open_movies_page(movies) +#chakras.show_trailer() + + + diff --git a/fresh_tomatoes.html b/fresh_tomatoes.html new file mode 100644 index 0000000..5402f59 --- /dev/null +++ b/fresh_tomatoes.html @@ -0,0 +1,137 @@ + + + + + + Videos !! + + + + + + + + + + + + + +
+ +
+
+ +
+ +

7 Chakras

+
+ +
+ +

7 Chakras

+
+ +
+ +

7 Chakras

+
+ +
+ +

7 Chakras

+
+ +
+ +

7 Chakras

+
+ +
+ +

7 Chakras

+
+ +
+ + diff --git a/fresh_tomatoes.py b/fresh_tomatoes.py new file mode 100644 index 0000000..3a5cf9d --- /dev/null +++ b/fresh_tomatoes.py @@ -0,0 +1,165 @@ +import webbrowser +import os +import re + + +# Styles and scripting for the page +main_page_head = ''' + + + + + Videos ! + + + + + + + + +''' + + +# The main page layout and title bar +main_page_content = ''' + + + + +
+ +
+
+ {movie_tiles} +
+ + +''' + + +# A single movie entry html template +movie_tile_content = ''' +
+ +

{movie_title}

+
+''' + + +def create_movie_tiles_content(movies): + # The HTML content for this section of the page + content = '' + for movie in movies: + # Extract the youtube ID from the url + youtube_id_match = re.search( + r'(?<=v=)[^&#]+', movie.trailer_youtube_url) + youtube_id_match = youtube_id_match or re.search( + r'(?<=be/)[^&#]+', movie.trailer_youtube_url) + trailer_youtube_id = (youtube_id_match.group(0) if youtube_id_match + else None) + + # Append the tile for the movie with its content filled in + content += movie_tile_content.format( + movie_title=movie.title, + poster_image_url=movie.poster_image_url, + trailer_youtube_id=trailer_youtube_id + ) + return content + + +def open_movies_page(movies): + # Create or overwrite the output file + output_file = open('fresh_tomatoes.html', 'w') + + # Replace the movie tiles placeholder generated content + rendered_content = main_page_content.format( + movie_tiles=create_movie_tiles_content(movies)) + + # Output the file + output_file.write(main_page_head + rendered_content) + output_file.close() + + # 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..465ae28eb74f3a81efe3a64a0992470f6c942d4a GIT binary patch literal 5352 zcmcIoUvJyU5nox36T8W!*CGg7;D8OCMlupgvSKHxYvry@oF=`Cb8vD=&&5@s$dyQi z;ws#gWnJQjHhu1EKS94qfqs&{7w89Qf3qY-Qg+ZQaCJgzxjUSlKfjrsVf9~^);{^$ zKVG^l{aeECXSmcCxOwagjZIW zw_*n8iOKW&c`ywAjlX^M_cg}WcCS5r_Ta_WU+!^VkHY(FyY$0DCmM7t5m_`L9Pj=b z$KUQqXotJL6Dy%R);LM$&Ua8{9)VSl~2r;z1B4jM}Xd zC)#Wpc-r6LceYNg_#znidWUa)X#0i_Op}mqD3w^)b}Ut(0~zgbr>A5%(IVG?_BD#x zo9&`zG#@9Mp0V<+9Ymfu-r+xQwKj8Rr_Es>1)h)#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