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 0000000..465ae28 Binary files /dev/null and b/fresh_tomatoes.pyc differ diff --git a/media.py b/media.py new file mode 100644 index 0000000..6ee3b74 --- /dev/null +++ b/media.py @@ -0,0 +1,12 @@ +import webbrowser + +class Movie(): + + def __init__(self,movie_title,movie_story_line,movie_image,movie_video): + self.title=movie_title + self.storyline=movie_story_line + self.poster_image_url=movie_image + self.trailer_youtube_url=movie_video + + def show_trailer(self): + webbrowser.open(self.trailer_youtube_url) diff --git a/media.pyc b/media.pyc new file mode 100644 index 0000000..6c2cd7e Binary files /dev/null and b/media.pyc differ