-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
305 lines (238 loc) · 13.6 KB
/
app.py
File metadata and controls
305 lines (238 loc) · 13.6 KB
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
from flask import Flask, render_template, request, redirect
import mysql.connector
from textblob import TextBlob
app = Flask(__name__)
class dbmini:
@app.route('/')
@app.route('/index.html')
def student2():
return render_template("index.html")
@app.route('/single.html')
@app.route('/single')
def student1():
return render_template("single.html")
global search
@app.route('/',methods = ['POST', 'GET'])
def search():
global p
p=0
if request.method == 'POST' and request.form.get('searchbar')=="":
connection = mysql.connector.connect(host='localhost',user='aparna879',password='password',database='movie2')
cursor = connection.cursor()
result = request.form.get("s")
#TO GET MOV_ID
cursor.execute("select mov_id from movies where lower(name)=%s;",[result])
global mov
mov= cursor.fetchall()
connection.commit()
cursor.execute("select md.link from movie_details md, movies m where m.mov_id = md.mov_id AND m.name=%s;",[result])
row0= cursor.fetchall()
connection.commit()
cursor.execute("select name from movies where lower(name)=%s;",[result])
row1= cursor.fetchall()
connection.commit()
cursor.execute("select md.description from movie_details md, movies m where m.mov_id = md.mov_id AND m.name=%s;",[result])
row2= cursor.fetchall()
connection.commit()
cursor.execute("select md.running_time from movie_details md, movies m where m.mov_id = md.mov_id AND m.name=%s;",[result])
row3= cursor.fetchall()
connection.commit()
cursor.execute("select md.genre from movie_details md, movies m where m.mov_id = md.mov_id AND m.name=%s;",[result])
row4= cursor.fetchall()
connection.commit()
cursor.execute("select md.director from movie_details md, movies m where m.mov_id = md.mov_id AND m.name=%s;",[result])
row5= cursor.fetchall()
connection.commit()
cursor.execute("select md.writer from movie_details md, movies m where m.mov_id = md.mov_id AND m.name=%s;",[result])
row6= cursor.fetchall()
connection.commit()
cursor.execute("select md.release_date from movie_details md, movies m where m.mov_id = md.mov_id AND m.name=%s;",[result])
row7= cursor.fetchall()
connection.commit()
cursor.execute("SELECT ROUND(avg(polarity),1) from rating where mov_id=%s;",[mov[0][0]])
rows= cursor.fetchall()
connection.commit()
#Movie_Cast
cursor.execute("select mc.cast_id from movie_cast mc, movies m where m.mov_id = mc.mov_id AND m.name=%s;",[result])
rowid= cursor.fetchall()
connection.commit()
row8 = []
for i in range(len(rowid)):
cursor.execute("select mc.photo from movie_cast mc where cast_id=%s;",[rowid[i][0]])
pic= cursor.fetchall()
row8.insert(i,pic[0][0])
connection.commit()
row9 = []
for i in range(len(rowid)):
cursor.execute("select mc.actor_name from movie_cast mc where cast_id=%s;",[rowid[i][0]])
aname= cursor.fetchall()
row9.insert(i,aname[0][0])
connection.commit()
row10 = []
for i in range(len(rowid)):
cursor.execute("select mc.alternate_name from movie_cast mc where cast_id=%s;",[rowid[i][0]])
altname= cursor.fetchall()
row10.insert(i,altname[0][0])
connection.commit()
return render_template("single.html",p=p,rows=rows, row0=row0, row1=row1, row2=row2, row3=row3, row4=row4, row5=row5, row6=row6, row7=row7, row8=row8, row9=row9, row10=row10)
@app.route('/single', methods = ['POST', 'GET'])
def result():
p=1
search()
if request.method == 'POST' and request.form.get('submit1')=="submit":
connection = mysql.connector.connect(host='localhost',user='aparna879',password='password',database='movie2')
cursor = connection.cursor()
result = request.form.get("comment")
param =(mov[0][0],result)
cursor.execute("INSERT INTO movie_review(mov_id,content) values(%s,%s)",param)
connection.commit()
#TO GET REV_ID
cursor = connection.cursor()
cursor.execute("select rev_id from movie_review where content=%s;",[result])
rev= cursor.fetchall()
connection.commit()
global value
#SENTIMENT_ANALYSIS
obj = TextBlob(result)
sentiment = obj.sentiment.polarity
value=(sentiment+1)/0.2
cursor.execute("INSERT into rating(rev_id,mov_id,polarity) values(%s,%s,%s)",(rev[0][0],mov[0][0],value))
connection.commit()
cursor.execute("SELECT ROUND(avg(polarity),1) from rating where mov_id=%s;",[mov[0][0]])
rows= cursor.fetchall()
connection.commit()
#STORED PROCEDURE
args = [mov[0][0],rev[0][0],'@best','@worst']
result= cursor.callproc('proc',args)
connection.commit()
pos=result[2]
neg=result[3]
# args = [mov[0][0],rev[0][0],'@best','@worst']
# result= cursor.execute("call proc(args)")
# pos=result[2]
# neg=result[3]
#DEBUGGED REFRESHING PROBLEM
cursor.execute("select link from movie_details where mov_id=%s;",[mov[0][0]])
row0= cursor.fetchall()
connection.commit()
cursor.execute("select name from movies where mov_id=%s;",[mov[0][0]])
row1= cursor.fetchall()
connection.commit()
cursor.execute("select description from movie_details where mov_id =%s;",[mov[0][0]])
row2= cursor.fetchall()
connection.commit()
cursor.execute("select running_time from movie_details where mov_id =%s;",[mov[0][0]])
row3= cursor.fetchall()
connection.commit()
cursor.execute("select genre from movie_details where mov_id =%s;",[mov[0][0]])
row4= cursor.fetchall()
connection.commit()
cursor.execute("select director from movie_details where mov_id =%s;",[mov[0][0]])
row5= cursor.fetchall()
connection.commit()
cursor.execute("select writer from movie_details where mov_id =%s;",[mov[0][0]])
row6= cursor.fetchall()
connection.commit()
cursor.execute("select release_date from movie_details where mov_id =%s;",[mov[0][0]])
row7= cursor.fetchall()
connection.commit()
cursor.execute("select cast_id from movie_cast where mov_id =%s;",[mov[0][0]])
rowid= cursor.fetchall()
connection.commit()
#Movie_Cast
row8 = []
for i in range(len(rowid)):
cursor.execute("select mc.photo from movie_cast mc where cast_id=%s;",[rowid[i][0]])
pic= cursor.fetchall()
row8.insert(i,pic[0][0])
connection.commit()
print(row8)
row9 = []
for i in range(len(rowid)):
cursor.execute("select mc.actor_name from movie_cast mc where cast_id=%s;",[rowid[i][0]])
aname= cursor.fetchall()
row9.insert(i,aname[0][0])
connection.commit()
print(row9)
row10 = []
for i in range(len(rowid)):
cursor.execute("select mc.alternate_name from movie_cast mc where cast_id=%s;",[rowid[i][0]])
altname= cursor.fetchall()
row10.insert(i,altname[0][0])
connection.commit()
print(row10)
return render_template("single.html",pos=pos,neg=neg,p=p,value=value, rows=rows, row0=row0, row1=row1, row2=row2, row3=row3, row4=row4, row5=row5, row6=row6, row7=row7, row8=row8, row9=row9, row10=row10)
if request.method == 'POST' and request.form.get('searchbar')=="":
connection = mysql.connector.connect(host='localhost',user='aparna879',password='password',database='movie')
cursor = connection.cursor()
result = request.form.get("s")
#TO GET MOV_ID
cursor.execute("select mov_id from movies where lower(name)=%s;",[result])
global mov
mov= cursor.fetchall()
connection.commit()
#print(mov)
cursor.execute("select md.link from movie_details md, movies m where m.mov_id = md.mov_id AND m.name=%s;",[result])
row0= cursor.fetchall()
connection.commit()
cursor.execute("select name from movies where lower(name)=%s;",[result])
row1= cursor.fetchall()
connection.commit()
cursor.execute("select md.description from movie_details md, movies m where m.mov_id = md.mov_id AND m.name=%s;",[result])
row2= cursor.fetchall()
connection.commit()
cursor.execute("select md.running_time from movie_details md, movies m where m.mov_id = md.mov_id AND m.name=%s;",[result])
row3= cursor.fetchall()
connection.commit()
cursor.execute("select md.genre from movie_details md, movies m where m.mov_id = md.mov_id AND m.name=%s;",[result])
row4= cursor.fetchall()
connection.commit()
cursor.execute("select md.director from movie_details md, movies m where m.mov_id = md.mov_id AND m.name=%s;",[result])
row5= cursor.fetchall()
connection.commit()
cursor.execute("select md.writer from movie_details md, movies m where m.mov_id = md.mov_id AND m.name=%s;",[result])
row6= cursor.fetchall()
connection.commit()
cursor.execute("select md.release_date from movie_details md, movies m where m.mov_id = md.mov_id AND m.name=%s;",[result])
row7= cursor.fetchall()
connection.commit()
cursor.execute("SELECT ROUND(avg(polarity),1) from rating where mov_id=%s;",[mov[0][0]])
rows= cursor.fetchall()
connection.commit()
cursor.execute("select mc.cast_id from movie_cast mc, movies m where m.mov_id = mc.mov_id AND m.name=%s;",[result])
rowid= cursor.fetchall()
connection.commit()
row8 = []
for i in range(len(rowid)):
cursor.execute("select mc.photo from movie_cast mc where cast_id=%s;",[rowid[i][0]])
pic= cursor.fetchall()
row8.insert(i,pic[0][0])
connection.commit()
print(row8)
row9 = []
for i in range(len(rowid)):
cursor.execute("select mc.actor_name from movie_cast mc where cast_id=%s;",[rowid[i][0]])
aname= cursor.fetchall()
row9.insert(i,aname[0][0])
connection.commit()
row9 = []
for i in range(len(rowid)):
cursor.execute("select mc.actor_name from movie_cast mc where cast_id=%s;",[rowid[i][0]])
aname= cursor.fetchall()
row9.insert(i,aname[0][0])
connection.commit()
row10 = []
for i in range(len(rowid)):
cursor.execute("select mc.alternate_name from movie_cast mc where cast_id=%s;",[rowid[i][0]])
altname= cursor.fetchall()
row10.insert(i,altname[0][0])
connection.commit()
row10 = []
for i in range(len(rowid)):
cursor.execute("select mc.alternate_name from movie_cast mc where cast_id=%s;",[rowid[i][0]])
altname= cursor.fetchall()
row10.insert(i,altname[0][0])
connection.commit()
return render_template("single.html",rows=rows, row0=row0, row1=row1, row2=row2, row3=row3, row4=row4, row5=row5, row6=row6, row7=row7, row8=row8, row9=row9, row10=row10)
if __name__ == '__main__':
app.run(debug = True)