예제 #1
0
def prompt_review_movie():
    """giving a film a review"""

    username = input("Username: "******"Movie ID# ")
    review = input("Enter your review of the movie: ")
    with get_connection() as connection:
        movie_database.review_movie(connection, username, movie_id, review)
예제 #2
0
def menu_movie():
    with get_connection() as connection:
        movie_database.create_tables(connection)

    while len(selection := input(MOVIE_MENU)) != 0:
        try:
            MENU_OPTIONS[selection]()       # turns the menu mapped value into a function()
        except KeyError:
            print("Invalid command. Please try again.")
예제 #3
0
def prompt_add_movie():
    """Release date is important so we can search upcoming films"""

    title = input("Movie Title: ")
    release_date = input("Release Date (dd-mm-yyyy): ")
    parsed_date = datetime.datetime.strptime(release_date, "%d-%m-%Y")
    timestamp = parsed_date.timestamp()
    trailer_url = input("Paste full trailer URL: ")
    with get_connection() as connection:
        movie_database.add_movie(connection, title, timestamp, trailer_url)
예제 #4
0
def prompt_get_reviewed():
    """returns multiple reviews of films the user has done"""

    username = input("username: "******"{username} has no reviewed movies")
예제 #5
0
def prompt_trailer_url():
    """opens the movie trailer on the default computer browser"""

    with get_connection() as connection:
        title = input("Enter movie title: ")
        url = movie_database.get_trailer_url(connection, title)

        try:
            webbrowser.open(url[0], new=0, autoraise=True)
        except Exception as e:
            print(e)
예제 #6
0
def prompt_search_movie():
    """finds any matches in the movie database based on whole
    or part of words from user input"""

    search_input = input("Enter part of a movie title to search: ")
    with get_connection() as connection:
        movies = movie_database.search_movie(connection, search_input)
        if movies:
            print_movie_list("Found", movies)
        else:
            print(f"No movies found with '{search_input}'")
        print("\n")
예제 #7
0
def prompt_movie_reviews():
    """returns all reviews for a movie from different users"""

    movie_id = input("Enter the Movie ID# ")
    with get_connection() as connection:
        movies = movie_database.get_movie_reviews(connection, movie_id)
        if movies:
            title = movies[0][0]
            print(f"Reviews for '{title}':")
            for _, username, review in movies:
                print(f'{username}: "{review}"')
        else:
            print(f"There are no reviews found")
        print("\n")
예제 #8
0
 def vote(self, username: str):
     with get_connection() as connection:
         database.add_poll_vote(connection, username, self.id)
예제 #9
0
    def get_votes(self) -> List['database.Vote']:
        with get_connection() as connection:
            votes = database.get_votes(connection, self.id)

            return votes
예제 #10
0
 def save(self):
     with get_connection() as connection:
         option_id = database.create_option(connection, self.poll_id,
                                            self.option_text)
         self.id = option_id
예제 #11
0
 def latest(cls) -> "Poll":
     """retrieves latest poll created"""
     with get_connection() as connection:
         poll = poll_database.get_latest_poll(connection)
         return cls(poll[1], poll[2], poll[0])
예제 #12
0
 def all(cls) -> List["Poll"]:
     """retrieves all polls created, in multiple rows"""
     with get_connection() as connection:
         polls = poll_database.get_polls(connection)
         return [cls(poll[1], poll[2], poll[0]) for poll in polls]