File size: 3,038 Bytes
3b47f92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68fec35
3b47f92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68fec35
 
3b47f92
68fec35
 
 
3b47f92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import recomender
import streamlit as st
import requests
import pandas as pd



df_cbf_Q = pd.read_csv('df_cbf_Q.csv', low_memory = False)
list_of_all_movies = list(df_cbf_Q['original_title'])
################################################################
def get_movie_information(movie_title):
    params={"apikey": "c176e26f", "t": movie_title, "plot": "full"}
    response = requests.get("http://www.omdbapi.com/", params=params)

    if response.status_code == 200:
        data = response.json()
    
        if data["Response"] == "False":
            print(data["Error"])
        else:
            return data
    else:
        print("Error:", response.status_code)

        
        
        
#######################################################################
def show_image(index):
    dict_movie =get_movie_information(list_of_movies[index])
    st.header(dict_movie["Title"])
    st.subheader(dict_movie["Year"])
    if dict_movie["Poster"] != "N/A":
        st.image(dict_movie["Poster"], use_column_width=False)
    else:
        st.write("Poster is not available!")
                        
    st.markdown(f"**IMDB Rating:** {dict_movie['imdbRating']} / 10")
    st.markdown(f"**Director:** {dict_movie['Director']}")
    st.markdown(f"**Actors:** {dict_movie['Actors']}")
    st.markdown(f"**Writer:** {dict_movie['Writer']}")
    st.markdown(f"**Genre:** {dict_movie['Genre']}")
    st.markdown(f"**Year:** {dict_movie['Year']}")
    st.markdown(f"**Country:** {dict_movie['Country']}")
    st.markdown(f"**Language:** {dict_movie['Language']}")
    st.write(f"**Plot:** {dict_movie['Plot']}")


#####################################################################################################



st.set_page_config(page_title="Movie Info", page_icon=":movie_camera:")
st.title("Movie Recommender Engine")

system_option = st.radio(" How would you like us to choose your next movie?"
    ,("Best Movies of all time","Trend Movies","Special for You:)", " People with similar tast like (CFR)"))

movies_watched = st.multiselect("What are your top three fovorite movies? (At least 3 movies)", list_of_all_movies)







###########################################################################################
suggest_button = st.button("Suggests me new movies to watch! ")

if suggest_button:
    if len(movies_watched) < 3:
        st.error(" You need to mention 3 movies!")
    
    else:
        if system_option == "Best Movies of all time":
            list_of_movies = recomender.final_recommender_hot_picks_of_all_time(movies_watched)

        elif  system_option == "Trend Movies":
            list_of_movies = recomender.final_recommender_hot_picks_now(movies_watched)

        elif  system_option == "Trend Movies","Special for You:)":
            list_of_movies = recomender.final_recommender_for_you(movies_watched)

        else:
            list_of_movies = recomender.recommender_svd(movies_watched)

        for i,_ in enumerate(list_of_movies):
            show_image(i)