diff --git a/Code/recommenderapp/app.py b/Code/recommenderapp/app.py index dc94f4631..4b9b50fa6 100644 --- a/Code/recommenderapp/app.py +++ b/Code/recommenderapp/app.py @@ -63,7 +63,7 @@ def feedback(): Handles user feedback submission and mails the results. """ data = json.loads(request.data) - user_email = "adipai16@gmail.com" + user_email = "11rishi.singhal@gmail.com" send_email_to_user(user_email, beautify_feedback_data(data)) return data diff --git a/Code/recommenderapp/constants.py b/Code/recommenderapp/constants.py index 31a92b464..3ea96a895 100644 --- a/Code/recommenderapp/constants.py +++ b/Code/recommenderapp/constants.py @@ -2,30 +2,30 @@ This module contains all the constants """ -EMAIL_HTML_CONTENT = """ - - - -

Movie Recommendations from PopcornPicks

-

Dear Movie Enthusiast,

-

We hope you're having a fantastic day!

-
-

Your Movie Recommendations:

-

Movies Liked:

- -

Movies Disliked:

- -

Movies Yet to Watch:

- -
-

Enjoy your movie time with PopcornPicks!

-

Best regards,
PopcornPicks Team 🍿

- - - """ +EMAIL_HTML_CONTENT =""" + + + +

Movie Recommendations from PopcornPicks

+

Dear Movie Enthusiast,

+

We hope you're having a fantastic day!

+
+

Your Movie Recommendations:

+

Movies Liked:

+ +

Movies Disliked:

+ +

Movies Yet to Watch:

+ +
+

Enjoy your movie time with PopcornPicks!

+

Best regards,
PopcornPicks Team 🍿

+ + + """ diff --git a/Code/recommenderapp/utils.py b/Code/recommenderapp/utils.py index 7858f4244..3b588d3e7 100644 --- a/Code/recommenderapp/utils.py +++ b/Code/recommenderapp/utils.py @@ -6,7 +6,42 @@ from email.mime.multipart import MIMEMultipart import constants as c +import pandas as pd +def create_colored_tags(genres): + """ + Utility function for creating colored tags for movie genres + """ + # Define colors for specific genres + genre_colors = { + 'Musical': '#FF1493', # DeepPink + 'Sci-Fi': '#00CED1', # DarkTurquoise + 'Mystery': '#8A2BE2', # BlueViolet + 'Thriller': '#FF4500', # OrangeRed + 'Horror': '#FF0000', # Red + 'Documentary': '#228B22', # ForestGreen + 'Fantasy': '#FF8C00', # DarkOrange + 'Adventure': '#FFD700', # Gold + 'Children': '#32CD32', # LimeGreen + 'Film-Noir': '#000000', # Black + 'Comedy': '#FFD700', # Gold + 'Crime': '#8B0000', # DarkRed + 'Drama': '#8B008B', # DarkMagenta + 'Western': '#FF6347', # Tomato + 'IMAX': '#7FFFD4', # Aquamarine + 'Action': '#FF4500', # OrangeRed + 'War': '#B22222', # FireBrick + '(no genres listed)': '#A9A9A9', # DarkGray + 'Romance': '#FF69B4', # HotPink + 'Animation': '#20B2AA' # LightSeaGreen + } + tags = [] + for genre in genres: + color = genre_colors.get(genre, '#CCCCCC') # Default color if not found + tag = f'{genre}' + tags.append(tag) + + return ' '.join(tags) def beautify_feedback_data(data): """ @@ -52,12 +87,24 @@ def send_email_to_user(recipient_email, categorized_data): message['From'] = sender_email message['To'] = recipient_email message['Subject'] = subject + + # Load the CSV file into a DataFrame + movie_genre_df = pd.read_csv('../../data/movies.csv') + + # Create a dictionary to map movies to their genres + movie_to_genres = {} + + for index, row in movie_genre_df.iterrows(): + movie = row['title'] + genres = row['genres'].split('|') + movie_to_genres[movie] = genres # Create the email message with HTML content - html_content = c.EMAIL_HTML_CONTENT.format('\n'.join(f'
  • {movie}
  • ' for movie in categorized_data['Liked']), - '\n'.join( - f'
  • {movie}
  • ' for movie in categorized_data['Disliked']), - '\n'.join(f'
  • {movie}
  • ' for movie in categorized_data['Yet to Watch'])) + html_content = c.EMAIL_HTML_CONTENT.format( + '\n'.join(f'
  • {movie} {create_colored_tags(movie_to_genres.get(movie, ["Unknown Genre"]))}

  • ' for movie in categorized_data['Liked']), + '\n'.join(f'
  • {movie} {create_colored_tags(movie_to_genres.get(movie, ["Unknown Genre"]))}

  • ' for movie in categorized_data['Disliked']), + '\n'.join(f'
  • {movie} {create_colored_tags(movie_to_genres.get(movie, ["Unknown Genre"]))}

  • ' for movie in categorized_data['Yet to Watch'])) + # Attach the HTML email body message.attach(MIMEText(html_content, 'html'))