Spaces:
Sleeping
Sleeping
shubhendu-ghosh
commited on
Commit
•
d72a444
1
Parent(s):
77da343
Delete app.py
Browse files
app.py
DELETED
@@ -1,111 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
import pickle
|
3 |
-
import requests
|
4 |
-
import streamlit.components.v1 as components
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
def recommend(movie):
|
9 |
-
index = movies[movies['title'] == movie].index[0]
|
10 |
-
distances = sorted(list(enumerate(similarity[index])),reverse=True,key = lambda x: x[1])
|
11 |
-
recommended_movie_names = []
|
12 |
-
recommended_movie_posters = []
|
13 |
-
for i in distances[1:8]:
|
14 |
-
movie_id = movies.iloc[i[0]].movie_id
|
15 |
-
recommended_movie_posters.append(fetch_poster(movie_id))
|
16 |
-
recommended_movie_names.append(movies.iloc[i[0]].title)
|
17 |
-
|
18 |
-
return recommended_movie_names,recommended_movie_posters
|
19 |
-
|
20 |
-
|
21 |
-
H = ['Action', 'Adventure', 'Fantasy', 'ScienceFiction', 'Crime', 'Drama', 'Thriller', 'Animation', 'Family', 'Western', 'Comedy', 'Romance', 'Horror',
|
22 |
-
'Mystery', 'History', 'War', 'Music', 'Documentary', 'Foreign', 'TVMovie']
|
23 |
-
|
24 |
-
def suggest(gen):
|
25 |
-
gen = gen.lower()
|
26 |
-
url = "https://www.imdb.com/search/title/?genres={}&sort=user_rating,desc".format(gen)
|
27 |
-
return url
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
def fetch_poster(movie_id):
|
32 |
-
url = "https://api.themoviedb.org/3/movie/{}?api_key=8265bd1679663a7ea12ac168da84d2e8&language=en-US".format(movie_id)
|
33 |
-
data = requests.get(url)
|
34 |
-
data = data.json()
|
35 |
-
poster_path = data['poster_path']
|
36 |
-
full_path = "https://image.tmdb.org/t/p/w500/" + poster_path
|
37 |
-
return full_path
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
st.markdown("""<p style="color: #3a02ab;font-size: 70px;font-family: sans-serif;"><b>FILM</b><span style="color: #f75e05;font-size: 70px;font-family: sans-serif;"><b>ISH</b></span></p>""", unsafe_allow_html=True)
|
42 |
-
|
43 |
-
|
44 |
-
movies = pickle.load(open('/movie_list.pkl', 'rb'))
|
45 |
-
similarity = pickle.load(open('/similarity.pkl', 'rb'))
|
46 |
-
movie_list = movies['title'].values
|
47 |
-
|
48 |
-
st.markdown(""" <span style="font-size: 30px; font-family: Arial, Helvetica, sans-serif; color: #040330;"> Enter or select a Movie</span>""", unsafe_allow_html=True)
|
49 |
-
|
50 |
-
selected_movie = st.selectbox("", movie_list)
|
51 |
-
if st.button('Show Recommendation'):
|
52 |
-
recommended_movie_names,recommended_movie_posters = recommend(selected_movie)
|
53 |
-
col1, col2, col3, col4, col5 , col6, col7 = st.columns(7)
|
54 |
-
with col1:
|
55 |
-
st.text(recommended_movie_names[0])
|
56 |
-
st.image(recommended_movie_posters[0])
|
57 |
-
with col2:
|
58 |
-
st.text(recommended_movie_names[1])
|
59 |
-
st.image(recommended_movie_posters[1])
|
60 |
-
|
61 |
-
with col3:
|
62 |
-
st.text(recommended_movie_names[2])
|
63 |
-
st.image(recommended_movie_posters[2])
|
64 |
-
with col4:
|
65 |
-
st.text(recommended_movie_names[3])
|
66 |
-
st.image(recommended_movie_posters[3])
|
67 |
-
with col5:
|
68 |
-
st.text(recommended_movie_names[4])
|
69 |
-
st.image(recommended_movie_posters[4])
|
70 |
-
with col6:
|
71 |
-
st.text(recommended_movie_names[5])
|
72 |
-
st.image(recommended_movie_posters[5])
|
73 |
-
with col7:
|
74 |
-
st.text(recommended_movie_names[6])
|
75 |
-
st.image(recommended_movie_posters[6])
|
76 |
-
|
77 |
-
components.html("<html> <br /> <br /><br /> </html>")
|
78 |
-
components.html(
|
79 |
-
"""
|
80 |
-
<style type="text/css">
|
81 |
-
#block {
|
82 |
-
height: 100px;
|
83 |
-
width: 100%;
|
84 |
-
background-color: #f002a5;
|
85 |
-
border-radius: 20px;
|
86 |
-
position: relative;
|
87 |
-
}
|
88 |
-
</style>
|
89 |
-
<body>
|
90 |
-
<br />
|
91 |
-
<div id="block">
|
92 |
-
<span style="font-size: 42px; color: white; font-family: Arial, Helvetica, sans-serif;"> You will be redirected to IMDB best movies page </span>
|
93 |
-
</div>
|
94 |
-
</body>
|
95 |
-
|
96 |
-
"""
|
97 |
-
)
|
98 |
-
|
99 |
-
#components.html("<html> <br /> <br /><br /> </html>")
|
100 |
-
st.markdown(""" <span style="font-size: 30px; font-family: Arial, Helvetica, sans-serif; color: #040330;"> Enter or select a Genre</span>""", unsafe_allow_html=True)
|
101 |
-
selected_genre = st.selectbox("", H)
|
102 |
-
if st.button("show movies"):
|
103 |
-
link = "[List of movies]("+ suggest(selected_genre)+")"
|
104 |
-
st.markdown(link, unsafe_allow_html=True)
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|