0% found this document useful (0 votes)
6 views12 pages

Movie Management System

Uploaded by

vinaysunder2008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views12 pages

Movie Management System

Uploaded by

vinaysunder2008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

#Vanakkam !

vanga vanga

import sqlite3

import matplotlib.pyplot as plt

# SQLite Database Connection

conn = sqlite3.connect("movie_data.db")

cursor = conn.cursor()

# Create users table

cursor.execute('''

CREATE TABLE IF NOT EXISTS users (

username TEXT PRIMARY KEY,

password TEXT NOT NULL,

watchlist TEXT

''')

# pudhusa varavanku

def register_user():

username = input("Choose a username: ")

cursor.execute("SELECT username FROM users WHERE username = ?", (username,))

if cursor.fetchone():

print("Username already exists. Please try a different one.")

return False

password = input("Choose a password: ")

cursor.execute("INSERT INTO users (username, password, watchlist) VALUES (?, ?, ?)",


(username, password, ""))

conn.commit()

print("Registration successful!")

return True

# Already namma programla sign in aanavanuku

def login_user():

username = input("Enter your username: ")

password = input("Enter your password: ")

cursor.execute("SELECT * FROM users WHERE username = ? AND password = ?", (username,

password))

user = cursor.fetchone()

if user:

print(f"Welcome back, {username}!")

return username

else:

print("Invalid username or password.")

return None

# Sambavame ingadhan(periya loop function for user login)took 3 days

logged_in_user = None

while not logged_in_user:

print("\n1. Login")

print("2. Register")

print("3. Exit")

choice = input("Enter your choice: ")

if choice == '1':
logged_in_user = login_user()

elif choice == '2':

if register_user():

logged_in_user = login_user() # indha dialougue succesfull-ah sign in ahna

varum:)*vinay

elif choice == '3':

print("Exiting the program.")

conn.close()

exit()

else:

print("Invalid choice. Please enter 1, 2, or 3.")

# --- Movie Management Code ---

movies = []

genres = []

ratings = []

reviews = []

box_office = []

# movie file store aagura edam

movie_file = "movies.txt"

# file correct ah load aaguthanu check panra loop

try:

file = open(movie_file, "r")

for line in file:

movie_data = line.strip().split(",")
if len(movie_data) == 5: # Ensure proper data format

movies.append(movie_data[0])

genres.append(movie_data[1])

ratings.append(movie_data[2])

reviews.append(movie_data[3])

box_office.append(movie_data[4])

file.close()

except FileNotFoundError:

print("No existing movie file found. A new file will be created when you save

data.")

# padatha thedurathuku

def search_movies():

print("\nSearch by:")

print("1. Title")

print("2. Genre")

print("3. Rating")

search_choice = input("Enter your choice (1-3): ")

if search_choice == '1':

search_query = input("Enter the movie title to search: ").lower()

results = [i for i in range(len(movies)) if search_query in movies[i].lower()]

elif search_choice == '2':

search_query = input("Enter the genre to search: ").lower()

results = [i for i in range(len(genres)) if search_query in genres[i].lower()]

elif search_choice == '3':

try:
min_rating = float(input("Enter the minimum rating: "))

results = [i for i in range(len(ratings)) if float(ratings[i]) >=

min_rating]

except ValueError:

print("Invalid input. Please enter a numeric value for the rating.")

return

else:

print("Invalid choice. Please select 1, 2, or 3.")

return

# search panna padathoda rseults da deii :)

if results:

print("\nSearch Results:")

for i in results:

print(f"Title: {movies[i]}, Genre: {genres[i]}, Rating: {ratings[i]},

Review: {reviews[i]}, Box Office: {box_office[i]}M")

else:

print("No matching movies found.")

# main sambavam..inga dhan motha core processum iruku

while True:

print("\nWhat would you like to do?")

print("1. Add a movie")

print("2. View movies")

print("3. Compare two movies")

print("4. Edit a movie")

print("5. Search for movies")


print("6. Logout")

print("7. Exit")

choice = input("Enter your choice (1-7): ")

if choice == '1':

# pudhusa padatha add panna

title = input("Enter movie title: ")

genre = input("Enter genre: ")

rating = input("Enter rating (1-10): ")

review = input("Enter review: ")

collection = input("Enter box office collection (in millions): ")

# Append details to the respective lists

movies.append(title)

genres.append(genre)

ratings.append(rating)

reviews.append(review)

box_office.append(collection)

print(f'Movie "{title}" added successfully!')

# datava file la save panrom

file = open(movie_file, "w")

for i in range(len(movies)):

file.write(f"{movies[i]},{genres[i]},{ratings[i]},{reviews[i]},{box_office[i]}\n")

file.close()
print("Movie saved to file.")

elif choice == '2':

# irukura ella padathoda detailsayum paakurathu da

if len(movies) == 0:

print("No movies found.")

else:

print("\nMovies List:")

for i in range(len(movies)):

print(f"{i + 1}. Title: {movies[i]}, Genre: {genres[i]}, Rating:

{ratings[i]}, Review: {reviews[i]}, Box Office: {box_office[i]}M")

elif choice == '3':

# idhu perusa ella adhu perusa..edhu perusunu adichu kaatu :)

if len(movies) < 2:

print("Not enough movies to compare. Please add more movies.")

else:

print("\nMovies available for comparison:")

for i in range(len(movies)):

print(f"{i + 1}. {movies[i]}")

movie1 = int(input("Select the first movie by number: ")) - 1

movie2 = int(input("Select the second movie by number: ")) - 1

if 0 <= movie1 < len(movies) and 0 <= movie2 < len(movies):

print("\nWhat would you like to compare?")

print("1. Ratings")
print("2. Box Office Collections")

comparison_choice = input("Enter your choice (1 or 2): ")

if comparison_choice == '1':

# ratings vechu compare panrathu

titles = [movies[movie1], movies[movie2]]

ratings_data = [float(ratings[movie1]), float(ratings[movie2])]

plt.figure(figsize=(8, 6))

plt.bar(titles, ratings_data, color='blue')

plt.xlabel("Movies")

plt.ylabel("Ratings (1-10)")

plt.title("Ratings Comparison")

plt.show()

elif comparison_choice == '2':

# box office vechu compare panrathu

titles = [movies[movie1], movies[movie2]]

box_office_data = [float(box_office[movie1]),

float(box_office[movie2])]

plt.figure(figsize=(8, 6))

plt.bar(titles, box_office_data, color='green')

plt.xlabel("Movies")

plt.ylabel("Box Office Collection (in millions)")

plt.title("Box Office Comparison")

plt.show()
else:

print("Invalid choice. Please select 1 or 2.")

else:

print("Invalid movie selection. Please try again.")

elif choice == '4':

# details ah edit panra edam

if len(movies) == 0:

print("No movies found. Add movies to edit.")

else:

print("\nMovies List:")

for i in range(len(movies)):

print(f"{i + 1}. Title: {movies[i]}")

movie_to_edit = int(input("Select the movie to edit by number: ")) - 1

if 0 <= movie_to_edit < len(movies):

print("\nEditing Movie Details:")

print(f"Current Title: {movies[movie_to_edit]}")

new_title = input("Enter new title (or press Enter to keep unchanged):

")

if new_title:

movies[movie_to_edit] = new_title

print(f"Current Genre: {genres[movie_to_edit]}")

new_genre = input("Enter new genre (or press Enter to keep unchanged):


")

if new_genre:

genres[movie_to_edit] = new_genre

print(f"Current Rating: {ratings[movie_to_edit]}")

new_rating = input("Enter new rating (or press Enter to keep unchanged):

")

if new_rating:

ratings[movie_to_edit] = new_rating

print(f"Current Review: {reviews[movie_to_edit]}")

new_review = input("Enter new review (or press Enter to keep unchanged):

")

if new_review:

reviews[movie_to_edit] = new_review

print(f"Current Box Office: {box_office[movie_to_edit]}M")

new_collection = input("Enter new box office collection (or press Enter

to keep unchanged): ")

if new_collection:

box_office[movie_to_edit] = new_collection

print("Movie details updated successfully.")

# edit pannatha save panra edam

file = open(movie_file, "w")

for i in range(len(movies)):
file.write(f"{movies[i]},{genres[i]},{ratings[i]},{reviews[i]},{box_office[i]}\n")

file.close()

else:

print("Invalid movie selection. Please try again.")

elif choice == '5':

# padatha thedura edam

search_movies()

elif choice == '6':

# account la irundhu logout panra function da

print("Logging out...")

conn.close()

break

elif choice == '7':

#mothama programah vitu veliya vara function

print("Exiting the program. Goodbye!")

conn.close()

exit()

else:

print("Invalid choice, please enter a number between 1 and 7.")

#avlodhan code mudinchiruchu but irundhalum innum sila functions or tasks add

panlamndra idea iruku ungalukum edhavudhu idea irundhu nerla paathu

solunga.Nandri.Vankkam

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy