Ejemplo n.º 1
0
def main():
    if type(sys.argv) and len(sys.argv) > 1:
        # an option is given
        option = sys.argv[1].strip()
        if option == "-sw":
            # switches database option. If enabled then creates a db file. Else deletes if any exists.
            if MMDB.movie_db_exists():
                # if already exists disable db options.
                delete = input(
                    "DB option is enabled (All the movies added will be lost). "
                    "Do you want to disable it and hence delete the db file? Press Y/N"
                )
                if delete.lower().startswith("y"):
                    #         user wants to continue to delete db
                    MMDB.delete_db()
            else:
                # enable db options.
                MMDB.save_movie_dict()
        elif option == "-a":
            print("Interactive mode!!! add your favourite movie to MMDB.")
            while True:
                title = input("Movie title: ")
                story = input("Story line: ")
                poster = input("URL to poster image: ")
                trailer = input("URL to youtube trailer: ")
                MMDB.movies[title] = Movie(title, story, poster, trailer)
                more = input(
                    "%s is added to MMDB. Do you want to add more? Press Y/N "
                    % (title))
                if more.lower().startswith("n"): break
            MMDB.save_movie_dict()
        #
        # elif option == "-e":
        #     # fixme have to add edit option
        #     print("Interactive mode!!! edit your favourite movie in the MMDB.")
        elif option == "-d":
            print("Interactive mode!!! delete your favourite movie from MMDB.")
            while True:
                print("ID: Movie Title")
                movie_titles = sorted(MMDB.movies.keys())
                for idx, title in enumerate(movie_titles):
                    print("%s : %s " % (idx + 1, title))
                # id of the movie to delete
                idx = eval(
                    input(
                        "Enter the id of the movie that you want to delete: "))
                if type(idx) == int and idx <= len(MMDB.movies):
                    MMDB.movies.pop(movie_titles[idx - 1])
                    more = input(
                        "%s is deleted from MMDB. Do you want to delete more? Press Y/N "
                        % (movie_titles[idx - 1]))
                    # exit interactive mode
                    if more.lower().startswith("n"): break

    # generate html code and display that to user.
    fresh_tomato.open_movies_page(MMDB.get_movies_as_list())
Ejemplo n.º 2
0
def main():
    if type(sys.argv) and len(sys.argv) > 1:
        # an option is given
        option = sys.argv[1].strip()
        if option == "-sw":
            # switches database option. If enabled then creates a db file. Else deletes if any exists.
            if MMDB.movie_db_exists():
                # if already exists disable db options.
                delete = input(
                    "DB option is enabled (All the movies added will be lost). "
                    "Do you want to disable it and hence delete the db file? Press Y/N")
                if delete.lower().startswith("y"):
                    #         user wants to continue to delete db
                    MMDB.delete_db()
            else:
                # enable db options.
                MMDB.save_movie_dict()
        elif option == "-a":
            print("Interactive mode!!! add your favourite movie to MMDB.")
            while True:
                title = input("Movie title: ")
                story = input("Story line: ")
                poster = input("URL to poster image: ")
                trailer = input("URL to youtube trailer: ")
                MMDB.movies[title] = Movie(title, story, poster, trailer)
                more = input("%s is added to MMDB. Do you want to add more? Press Y/N " % (title))
                if more.lower().startswith("n"): break
            MMDB.save_movie_dict()
        #
        # elif option == "-e":
        #     # fixme have to add edit option
        #     print("Interactive mode!!! edit your favourite movie in the MMDB.")
        elif option == "-d":
            print("Interactive mode!!! delete your favourite movie from MMDB.")
            while True:
                print("ID: Movie Title")
                movie_titles = sorted(MMDB.movies.keys())
                for idx, title in enumerate(movie_titles):
                    print("%s : %s " % (idx + 1, title))
                # id of the movie to delete
                idx = eval(input("Enter the id of the movie that you want to delete: "))
                if type(idx) == int and idx <= len(MMDB.movies):
                    MMDB.movies.pop(movie_titles[idx - 1])
                    more = input(
                        "%s is deleted from MMDB. Do you want to delete more? Press Y/N " % (movie_titles[idx - 1]))
                    # exit interactive mode
                    if more.lower().startswith("n"): break

    # generate html code and display that to user.
    fresh_tomato.open_movies_page(MMDB.get_movies_as_list())
Ejemplo n.º 3
0
the_hunger_games = MovieProject.Movie("The Hunger Games",
                            "An economically divided society craves violence that is set as a distraction.",
                            "http://t2.gstatic.com/images?q=tbn:ANd9GcS58mYVyiI3LTihImFjn6QBLU_mcHXZP3LaGoWN9u5bzuvW3lvC",
                            "https://www.youtube.com/watch?v=LrXIG4oK7Ew")

the_dark_knight = MovieProject.Movie("The Dark Knight",
                                     "Batman must save Gotham from Joker",
                                     "https://usercontent2.hubstatic.com/13349231_f520.jpg",
                                     "https://www.youtube.com/watch?v=_PZpmTj1Q8Q")

good_will_hunting = MovieProject.Movie("Good Will Hunting",
                                       "A young adult discovers his true potential",
                                       "https://upload.wikimedia.org/wikipedia/en/thumb/5/52/Good_Will_Hunting.png/220px-Good_Will_Hunting.png",
                                       "https://www.youtube.com/watch?v=z02M3NRtkAA")

lion_king = MovieProject.Movie("Lion King",
                               "A cub becomes a Lion",
                               "https://upload.wikimedia.org/wikipedia/en/thumb/3/3d/The_Lion_King_poster.jpg/220px-The_Lion_King_poster.jpg",
                               "https://www.youtube.com/watch?v=4sj1MT05lAA")

forrest_gump = MovieProject.Movie("Forrest Gump",
                                  "Meet Forrest, Forrest Gump",
                                  "https://upload.wikimedia.org/wikipedia/en/thumb/6/67/Forrest_Gump_poster.jpg/220px-Forrest_Gump_poster.jpg",
                                  "https://www.youtube.com/watch?v=bLvqoHBptjg")
#print(the_dark_knight.storyline)                                     
#the_dark_knight.show_trailer()
movies =[a_bronx_tale, the_hunger_games, the_dark_knight, good_will_hunting, lion_king, forrest_gump]
fresh_tomato.open_movies_page(movies)
#print(MovieProject.Movie.VALID_RATINGS)
print(MovieProject.Movie.__doc__)
Ejemplo n.º 4
0
# added new Movie instances
jurassic_park = media.Movie("Jurassic Park", "https://www.youtube.com/watch?v=lc0UehYemQA")
the_matrix = media.Movie("The Matrix", "https://www.youtube.com/watch?v=qEXv-rVWAu8")
interstellar = media.Movie("Interstellar", "https://www.youtube.com/watch?v=2LqzF5WauAw")
blade_runnder = media.Movie("Blade Runner", "https://www.youtube.com/watch?v=gCcx85zbxz4")
alien = media.Movie("Alien", "https://www.youtube.com/watch?v=LjLamj-b0I8")
the_martian = media.Movie("The Martian", "https://www.youtube.com/watch?v=ej3ioOneTy8")
avatar = media.Movie("Avatar", "https://www.youtube.com/watch?v=d1_JBMrrYw8")
# toy_story = media.Movie("Toy Story", "A story of a boy and his toys come to life", "https://upload.wikimedia.org/wikipedia/en/1/13/Toy_Story.jpg", "https://www.youtube.com/watch?v=ZZv1vki4ou4")
# avatar = media.Movie("Avatar", "A marine on an alien planet",
# 	"https://upload.wikimedia.org/wikipedia/en/b/b0/Avatar-Teaser-Poster.jpg",
# 	"https://www.youtube.com/watch?v=d1_JBMrrYw8")

# school_of_rock = media.Movie("School of Rock", "Using rock music to learn","https://upload.wikimedia.org/wikipedia/en/1/11/School_of_Rock_Poster.jpg", "https://www.youtube.com/watch?v=XCwy6lW5Ixc")
# ratatouille = media.Movie("Ratatouille", "A rat is a chef in Paris", "https://static.rogerebert.com/uploads/movie/movie_poster/ratatouille-2007/large_taAPNsf6G4EXBYSG7Jyvd9HHKnH.jpg", "https://www.youtube.com/watch?v=c3sBBRxDAqk")
# midnight_in_paris = media.Movie("Midnight in Paris", "An author meets historical figures in Paris", "https://upload.wikimedia.org/wikipedia/en/9/9f/Midnight_in_Paris_Poster.jpg", "https://www.youtube.com/watch?v=dtiklALGz20")
# hunger_games = media.Movie("Hunger Games", "A survival story in a futuristic universe", "https://upload.wikimedia.org/wikipedia/en/3/39/The_Hunger_Games_cover.jpg", "https://www.youtube.com/watch?v=mfmrPu43DF8")

# movies list
# movies = [toy_story, avatar, school_of_rock, ratatouille, midnight_in_paris, hunger_games]

# appending movie instances to a list
sci_fi_movies = [jurassic_park, the_matrix, interstellar, blade_runnder, alien, the_martian, avatar]

# call open_movies_page
fresh_tomato.open_movies_page(sci_fi_movies)

# print(media.Movie.VALID_RATINGS)
# print(media.Movie.__doc__)
import media
import fresh_tomato
import csv
from media import Movie

# read movie informations from movies_info.csv, and store in a list movies
with open("db/movies_info.csv", "rb") as csvfiles:
    movies = map(lambda entry: Movie.make_movie(entry), csv.reader(csvfiles, delimiter=","))

fresh_tomato.open_movies_page(movies)