-
Notifications
You must be signed in to change notification settings - Fork 2
/
Home.py
197 lines (157 loc) · 8.34 KB
/
Home.py
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
import streamlit as st
import time
import pandas as pd
import pickle
import nltk
import spacy
import numpy as np
from sklearn.metrics.pairwise import cosine_similarity
import requests
from streamlit_option_menu import option_menu
from streamlit_extras.switch_page_button import switch_page
from streamlit_card import card
movies_df = pd.read_csv('preprocessed_movies_data_tmdb.csv')
movies_full_df = pd.read_csv("tmdb_full_data.csv")
# movies_full_df = movies_full_df[['original_title', 'genres', 'release_date', 'vote_average']]
def process():
genres_ls = []
def get_genres_list(ls):
# ls = string.split()
genres_ls.append(ls)
return ls
#Getting the index of the movie enetred by the user
def idx_of_movie_in_dataframe(string):
idx = movies_full_df[movies_full_df['original_title'] == string].index.values
idx = idx.tolist()[0]
return idx
#Get movie id
def get_movie_id(idx):
index = movies_full_df.iloc[idx, 0]
return index
#Fetching the image of the movie
def fetch_image(movie_id):
url = "https://api.themoviedb.org/3/movie/{}?language=en-US".format(movie_id)
headers = {
"accept": "application/json",
"Authorization": "Bearer eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiI3ZjFlYTM2YTFjMmU0ZWM2OWI0NmFhYTg3YjVkMjRkNiIsInN1YiI6IjY0Y2UzNzFjNGQ2NzkxMDEzOWVkZjYyYiIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.Um8Newx2IqVQ_7vZMs4hBbZCqoz9uMuNgOX-7ERNPl4"
}
response = requests.get(url, headers=headers)
data = response.json()
# print(data['poster_path'])
image_url = 'https://image.tmdb.org/t/p/w780/' + data['poster_path']
# print(image_url)
return image_url
movie_names_list = list(movies_full_df.iloc[:, 9])
movie_id_for_image = []
for i in movie_names_list:
idx = idx_of_movie_in_dataframe(i)
movie_id_for_image.append(get_movie_id(idx))
count=0
count2=0
k=0
while(st.checkbox('Show More', key=count2)):
# if st.checkbox("Show More!", key=count):
columns = st.columns(2)
for j in range(len(columns)):
with columns[j]:
homepage_url = 'https://www.themoviedb.org/movie/{}'.format(movie_id_for_image[k+j])
# print(recommendations[i])
# st.image(fetch_image(movie_id_for_image[k+j] ))
# st.write(movie_names_list[k+j])
url = "https://www.streamlit.io"
# st.write("[Explore](%s)" % homepage_url)
hasClicked = card(
title=st.write(movie_names_list[k+j]),
text="Explore",
image=fetch_image(movie_id_for_image[k+j] ),
url=homepage_url,
on_click=lambda: print("Clicked!"),
styles={
"card": {
"width": "300px",
"height": "400px",
"border-radius": "60px",
"box-shadow": "0 0 10px rgba(0,0,0,0.5)",
},
"text": {
"font-family": "serif",
}
}
)
count2+=1
# count+=1
k += 6
st.set_page_config(
page_title = 'MoviesMania'
)
st.markdown("<h1 style='text-align: center; color: white;'>Movies Mania</h1>", unsafe_allow_html=True)
st.divider()
genres_ls = []
def get_genres_list(string):
ls = string.split()
genres_ls.append(ls)
return ls
selected = option_menu(
menu_title = "Getting Started!",
options=["Welcome", "For starters", "Instructions for Use of features"],
orientation='horizontal',
# menu_icon='cast',
default_index=0,
)
st.divider()
if selected == "For starters":
col1, col2 = st.columns([6,2])
with col1:
# pass
st.markdown("<h3 style='text-align: center; color: white;'>Take a look through our movies collection!</h3>", unsafe_allow_html=True)
with col2:
# movies_df['genres'] = movies_df['genres'].apply(get_genres_list)
# final_genres_ls =list(set(genres_ls))
# selected_genres = st.multiselect("Select genres:", options=final_genres_ls)
# st.divider()
# st.markdown("<h2 style='text-align: center; color: white;'>Select five movies of your choice!</h2>", unsafe_allow_html=True)
# movie_names_list = list(set(list(movies_df.iloc[:, 4])))
# name = st.multiselect("Choose five movies", options=movie_names_list)
# final_movies_ls =list(set(movies_ls))
# if st.checkbox("Select through option menu?"):
# selected_movies = st.multiselect("Select some movies!:", options=final_movies_ls)
# st.divider()
if st.button("Show all movies"):
switch_page("All Movies")
st.divider()
col3, col4 = st.columns([6,2])
with col3:
# pass
st.markdown("<h3 style='text-align: center; color: white;'>Looking for specific movies?</h3>", unsafe_allow_html=True)
with col4:
if st.button("Choose"):
switch_page("All Movies")
if selected == "Instructions for Use of features":
st.markdown("<h3 style='text-align: center; font-weight:bold; font-style:italic; color: white;'>For 'Recommend through Videos' </h3>", unsafe_allow_html=True)
st.divider()
st.markdown('''
1. Go to Upload a Video page and upload either through your local machine or Download through YT Shorts page'
2. Then visit the Recommend through Video page and input the plot and genres either on your own or thorugh the drop-own menus'
3. Once downloaded/uploaded, visit the Upload Here! page and select your particular option to proceed. If you want to use our special feature, please select so beofre proceeding with selecting your option.'
4. Please wait for 8-10 min for whole process to be finished. Meanwhile you can make use of our special feature of viewing Reviews for the movie of your choice, if selected.'
5. Voila! The Top 10 Recommended Movies are live!
'''
)
st.markdown("<h3 style='text-align: center; font-weight:bold; font-style:italic; color: white;'>For 'Recommend through Plot' </h3>", unsafe_allow_html=True)
st.divider()
st.markdown('''
1. Visit the 'Recommnd through Plot' page and enter your preferred plot and genre
2. For better recommendations, try to atleast input 50-60 words worth of meaningful sentences of your plot and as specific as possible genres. You can also provide meaningful keywords.
3. Voila! The Top 10 Recommended Movies are live!
'''
)
st.markdown("<h3 style='text-align: center; font-weight:bold; font-style:italic; color: white;'>For 'Recommend through Title' </h3>", unsafe_allow_html=True)
st.divider()
st.markdown('''
1. Visit the 'Recommnd through Title' page and select your preferred movie title from the dropdown menu, if available(More will be added!).
2. Select 'Show Top 10 Similar Movies' button.
3. Voila! The Top 10 Recommended Movies are live!
'''
)
if selected == "Welcome":
process()