File size: 74,977 Bytes
4f47ec7
 
 
 
 
 
 
 
89672dc
4f47ec7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89672dc
4f47ec7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89672dc
4f47ec7
 
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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
import streamlit as st
import boto3
import json
import chromadb
import pandas as pd
import time
import re
from datetime import datetime

# Sample Bollywood movies data (simplified for demo)
SAMPLE_MOVIES = [
    {"title": "Mughal-e-Azam",        "year": 1960, "genre": "Epic Romance", "director": "K. Asif",
     "plot": "Crown prince Salim’s forbidden love for a court dancer sparks war with Emperor Akbar."},
    {"title": "Junglee",              "year": 1961, "genre": "Rom-Com",      "director": "Subodh Mukherjee",
     "plot": "A prim aristocrat learns to live and love after meeting a free-spirited girl in Kashmir."},
    {"title": "Bees Saal Baad",       "year": 1962, "genre": "Mystery Thriller", "director": "Biren Nag",
     "plot": "A young heir returns to his haunted village to break a 20-year-old curse and prove his sanity."},
    {"title": "Bandini",              "year": 1963, "genre": "Social Drama", "director": "Bimal Roy",
     "plot": "In pre-Independence India, a female convict must choose between duty, love and freedom."},
    {"title": "Sangam",               "year": 1964, "genre": "Romance",      "director": "Raj Kapoor",
     "plot": "A love triangle tests lifelong friendship when an air-force pilot marries the woman both men adore."},
    {"title": "Guide",                "year": 1965, "genre": "Romantic Drama","director": "Vijay Anand",
     "plot": "A tour guide becomes spiritual guru while helping a dancer escape an oppressive marriage."},
    {"title": "Teesri Manzil",        "year": 1966, "genre": "Musical Mystery","director": "Vijay Anand",
     "plot": "Suave drummer Rocky helps a young woman hunt the killer behind her sister’s fatal fall."},
    {"title": "Upkar",                "year": 1967, "genre": "Patriotic Drama","director": "Manoj Kumar",
     "plot": "A farmer-soldier embodies ‘Jai Jawan Jai Kisan’, sacrificing for family and nation."},
    {"title": "Jewel Thief",          "year": 1967, "genre": "Heist Thriller","director": "Vijay Anand",
     "plot": "A look-alike is hired by police to trap an elusive jewel smuggler, only to be ensnared himself."},
    {"title": "Aradhana",             "year": 1969, "genre": "Musical Romance","director": "Shakti Samanta",
     "plot": "An unwed mother survives social stigma while her son grows up to become an Air-Force pilot."},

    # ---- 1970s ------------------------------------------------------------
    {"title": "Purab Aur Paschim",    "year": 1970, "genre": "Patriotic Drama","director": "Manoj Kumar",
     "plot": "An idealistic Indian visits London and battles cultural cynicism with traditional values."},
    {"title": "Johny Mera Naam",      "year": 1970, "genre": "Crime Thriller","director": "Vijay Anand",
     "plot": "Separated brothers collide years later—one a suave con-man, the other a cop on his trail."},
    {"title": "Anand",                "year": 1971, "genre": "Slice-of-Life","director": "Hrishikesh Mukherjee",
     "plot": "A terminally-ill but exuberant man teaches his cynical doctor how to celebrate life."},
    {"title": "Haathi Mere Saathi",   "year": 1971, "genre": "Family Adventure","director": "M. A. Thirumugham",
     "plot": "Orphan Raju’s circus empire and elephant family face a ruthless hunter and marital rift."},
    {"title": "Seeta Aur Geeta",      "year": 1972, "genre": "Action Comedy","director": "Ramesh Sippy",
     "plot": "Separated twins—one timid, one feisty—swap places to defeat oppressive relatives."},
    {"title": "Pakeezah",             "year": 1972, "genre": "Classic Romance","director": "Kamal Amrohi",
     "plot": "A courtesan’s dream of respectability kindles when a nobleman admires her henna-stained feet."},
    {"title": "Bombay to Goa",        "year": 1972, "genre": "Road Comedy",  "director": "S. Ramanathan",
     "plot": "A motley bus ride from Bombay to Goa turns perilous after a witness boards with gangsters on her heels."},
    {"title": "Bobby",                "year": 1973, "genre": "Teen Romance", "director": "Raj Kapoor",
     "plot": "Rich boy, poor girl defy class barriers in a coming-of-age love story that redefined youth cinema."},
    {"title": "Zanjeer",              "year": 1973, "genre": "Action Crime", "director": "Prakash Mehra",
     "plot": "An angry police inspector hunts a crime baron who ruined his childhood."},
    {"title": "Yaadon Ki Baraat",     "year": 1973, "genre": "Musical Action","director": "Nasir Hussain",
     "plot": "Three brothers separated in childhood reunite through a signature family song."},
    {"title": "Roti Kapda Aur Makaan","year": 1974, "genre": "Social Drama", "director": "Manoj Kumar",
     "plot": "An honest man fights poverty, corruption and political betrayal to secure basic needs for loved ones."},
    {"title": "Deewar",               "year": 1975, "genre": "Crime Drama",  "director": "Yash Chopra",
     "plot": "Brothers on opposite sides of the law clash over morality, mother and money."},
    {"title": "Sholay",               "year": 1975, "genre": "Action Adventure","director": "Ramesh Sippy",
     "plot": "Two small-time crooks are hired by a retired cop to capture a ruthless bandit in a lawless village."},
    {"title": "Chupke Chupke",        "year": 1975, "genre": "Comedy",       "director": "Hrishikesh Mukherjee",
     "plot": "A botany professor pranks his in-laws with an elaborate masquerade as a driver."},
    {"title": "Kabhi Kabhie",         "year": 1976, "genre": "Romantic Drama","director": "Yash Chopra",
     "plot": "Unfulfilled lovers meet years later, entangling two generations in poetic nostalgia."},
    {"title": "Do Anjaane",           "year": 1976, "genre": "Thriller",     "director": "Dulal Guha",
     "plot": "An amnesiac man returns to confront his wife’s betrayal and claim his lost identity."},
    {"title": "Amar Akbar Anthony",   "year": 1977, "genre": "Action Comedy","director": "Manmohan Desai",
     "plot": "Three brothers raised in different faiths unite to defeat the crime lord who tore them apart."},
    {"title": "Dharam Veer",          "year": 1977, "genre": "Fantasy Adventure","director": "Manmohan Desai",
     "plot": "Royal twins separated at birth grow up as best friends unaware of their lineage."},
    {"title": "Hum Kisise Kum Naheen", "year": 1977, "genre": "Musical Romance","director": "Nasir Hussain",
     "plot": "Suitors clash over a rare diamond and the heart of a wealthy heiress."},
    {"title": "Trishul",              "year": 1978, "genre": "Revenge Drama","director": "Yash Chopra",
     "plot": "An illegitimate son builds a business empire to destroy the estranged father who wronged his mother."},
    {"title": "Don",                  "year": 1978, "genre": "Gangster Action","director": "Chandra Barot",
     "plot": "When dreaded Don is killed, his look-alike infiltrates the cartel to help police."},
    {"title": "Muqaddar Ka Sikandar", "year": 1978, "genre": "Melodrama",    "director": "Prakash Mehra",
     "plot": "An orphan rises to wealth yet pines for unrequited love while a courtesan silently adores him."},
    {"title": "Satyam Shivam Sundaram","year": 1978, "genre": "Romantic Drama","director": "Raj Kapoor",
     "plot": "A man obsessed with physical beauty marries a village girl scarred by fire, discovering inner divinity."},
    {"title": "Gol Maal",             "year": 1979, "genre": "Comedy",       "director": "Hrishikesh Mukherjee",
     "plot": "A young man invents a mustachioed twin to keep a job with his disciplinarian boss."},
    {"title": "Kaala Patthar",        "year": 1979, "genre": "Disaster Drama","director": "Yash Chopra",
     "plot": "Coal-mine workers fight greed and nature when flooding threatens hundreds underground."},
    {"title": "Suhaag",               "year": 1979, "genre": "Action Drama", "director": "Manmohan Desai",
     "plot": "Brothers raised apart—one cop, one outlaw—discover blood ties while battling a crime ring."},

    # ---- 1980s ------------------------------------------------------------
    {"title": "Qurbani",              "year": 1980, "genre": "Action Thriller","director": "Feroz Khan",
     "plot": "Two friends fall for the same singer while plotting a high-stakes diamond heist."},
    {"title": "Karz",                 "year": 1980, "genre": "Reincarnation Thriller","director": "Subhash Ghai",
     "plot": "A pop star recalls a past life and seeks justice from the wife who murdered him."},
    {"title": "Kranti",               "year": 1981, "genre": "Historical Action","director": "Manoj Kumar",
     "plot": "Freedom fighters unite diverse Indians against British rule in the 19th century."},
    {"title": "Chashme Buddoor",      "year": 1981, "genre": "College Comedy","director": "Sai Paranjpye",
     "plot": "Three Delhi students vie for a girl; prank wars end in unexpected romance."},
    {"title": "Naseeb",               "year": 1981, "genre": "Masala Drama", "director": "Manmohan Desai",
     "plot": "A lottery ticket triggers betrayal; years later, sons cross paths in a glamorous hotel."},
    {"title": "Laawaris",             "year": 1981, "genre": "Melodrama",    "director": "Prakash Mehra",
     "plot": "An illegitimate boy seeks his true parentage, armed only with a torn photograph."},
    {"title": "Namak Halaal",         "year": 1982, "genre": "Comedy",       "director": "Prakash Mehra",
     "plot": "Village bumpkin Arjun joins a five-star hotel, foiling an assassination with naïve heroism."},
    {"title": "Vidhaata",             "year": 1982, "genre": "Action Drama", "director": "Subhash Ghai",
     "plot": "A grandfather turns underworld kingpin to avenge his son, but fears for his grandson’s soul."},
    {"title": "Arth",                 "year": 1982, "genre": "Relationship Drama","director": "Mahesh Bhatt",
     "plot": "A filmmaker’s wife rebuilds her identity after her husband’s affair with an actress."},
    {"title": "Coolie",               "year": 1983, "genre": "Action Drama", "director": "Manmohan Desai",
     "plot": "Railway porters revolt to save their leader’s mother abducted by a wealthy smuggler."},
    {"title": "Hero",                 "year": 1983, "genre": "Romantic Action","director": "Subhash Ghai",
     "plot": "A goon posing as cop to kidnap a police chief’s daughter falls genuinely in love."},
    {"title": "Himmatwala",           "year": 1983, "genre": "Masala Action", "director": "K. Raghavendra Rao",
     "plot": "An engineering graduate returns to his village to avenge his father and woo a feisty heiress."},
    {"title": "Ardh Satya",           "year": 1983, "genre": "Police Drama", "director": "Govind Nihalani",
     "plot": "An honest cop wrestles with systemic corruption and his own violent rage."},
    {"title": "Mashaal",              "year": 1984, "genre": "Crime Drama",  "director": "Yash Chopra",
     "plot": "An idealistic editor becomes a dreaded don to topple the gangster who ruined him."},
    {"title": "Saaransh",             "year": 1984, "genre": "Social Drama", "director": "Mahesh Bhatt",
     "plot": "Elderly parents grapple with grief and bureaucracy after their only son dies abroad."},
    {"title": "Utsav",                "year": 1984, "genre": "Period Rom-Com","director": "Girish Karnad",
     "plot": "In ancient Ujjain, a courtesan hides from a lustful king while romancing a poor poet."},
    {"title": "Ram Teri Ganga Maili", "year": 1985, "genre": "Romantic Drama","director": "Raj Kapoor",
     "plot": "Innocent Ganga searches for her lover in a corrupt city as the sacred river is defiled."},
    {"title": "Arjun",                "year": 1985, "genre": "Action Drama", "director": "Rahul Rawail",
     "plot": "An unemployed youth becomes political pawn while fighting local goons to protect slum dwellers."},
    {"title": "Meri Jung",            "year": 1985, "genre": "Courtroom Drama","director": "Subhash Ghai",
     "plot": "A lawyer seeks justice against the ruthless advocate who framed his father."},
    {"title": "Karma",                "year": 1986, "genre": "Action Patriotic","director": "Subhash Ghai",
     "plot": "A jailer forms a rogue commando squad of convicts to capture a terror mastermind."},
    {"title": "Naam",                 "year": 1986, "genre": "Crime Drama",  "director": "Mahesh Bhatt",
     "plot": "Two brothers in Dubai choose starkly different paths of smuggling and righteousness."},
    {"title": "Nagina",               "year": 1986, "genre": "Fantasy Thriller","director": "K. Raghavendra Rao",
     "plot": "Shape-shifting serpent woman avenges her husband’s murder in rustic Rajasthan."},
    {"title": "Janbaaz",              "year": 1986, "genre": "Action Romance","director": "Feroz Khan",
     "plot": "Two brothers—cop and playboy—confront drug mafia after a lover’s overdose."},
    {"title": "Mr India",             "year": 1987, "genre": "Sci-Fi Adventure","director": "Shekhar Kapur",
     "plot": "A genial caretaker turns invisible to defeat a megalomaniac threatening orphaned children."},
    {"title": "Khoon Bhari Maang",    "year": 1988, "genre": "Revenge Thriller","director": "Rakesh Roshan",
     "plot": "A betrayed wife returns from crocodile jaws with a new face to ruin her greedy husband."},
    {"title": "Qayamat Se Qayamat Tak","year": 1988, "genre": "Tragic Romance","director": "Mansoor Khan",
     "plot": "Star-crossed lovers from feuding families choose death over separation."},
    {"title": "Tezaab",               "year": 1988, "genre": "Action Drama", "director": "N. Chandra",
     "plot": "Ex-army man turned criminal fights to save his childhood sweetheart from a lecherous gangster."},
    {"title": "Chandni",              "year": 1989, "genre": "Romantic Drama","director": "Yash Chopra",
     "plot": "A woman torn between wheelchair-bound fiancé and charming friend finds her true calling."},
    {"title": "Maine Pyar Kiya",      "year": 1989, "genre": "Rom-Com",      "director": "Sooraj Barjatya",
     "plot": "Rich boy and mechanic’s daughter swear platonic friendship that blossoms into epic love."},
    {"title": "Tridev",               "year": 1989, "genre": "Action Masala", "director": "Rajiv Rai",
     "plot": "A cop, an assassin and a playboy unite to destroy an arms kingpin."},
    {"title": "Parinda",              "year": 1989, "genre": "Crime Noir",   "director": "Vidhu Vinod Chopra",
     "plot": "Two brothers’ bond shatters when one becomes a don’s henchman, the other joins police."},
    {"title": "Ram Lakhan",           "year": 1989, "genre": "Action Drama", "director": "Subhash Ghai",
     "plot": "Brothers—honest cop and flamboyant rogue—avenge parents’ murder while clashing over methods."},

    # ---- 1990s (hits & super-hits) ---------------------------------------
    {"title": "Dil",                  "year": 1990, "genre": "Campus Rom-Com","director": "Indra Kumar",
     "plot": "Sparring college rivals from rival families fall hilariously in love."},
    {"title": "Ghayal",               "year": 1990, "genre": "Action Drama", "director": "Rajkumar Santoshi",
     "plot": "An amateur boxer seeks vengeance on the tycoon who framed him for murder."},
    {"title": "Aashiqui",             "year": 1990, "genre": "Musical Romance","director": "Mahesh Bhatt",
     "plot": "Two lovers brave societal odds; soulful soundtrack became cultural phenomenon."},
    {"title": "Agneepath",            "year": 1990, "genre": "Gangster Drama","director": "Mukul Anand",
     "plot": "A wronged boy grows into ruthless don Vijay Dinananath Chauhan to reclaim his mother’s honour."},
    {"title": "Saajan",               "year": 1991, "genre": "Romantic Drama","director": "Lawrence D’Souza",
     "plot": "Poet in hiding lets his orphaned friend woo the woman who loves his verses."},
    {"title": "Hum",                  "year": 1991, "genre": "Action Drama", "director": "Mukul Anand",
     "plot": "Dock-worker Tiger fights drug lord while protecting three younger siblings."},
    {"title": "Lamhe",                "year": 1991, "genre": "Romantic Drama","director": "Yash Chopra",
     "plot": "Man falls for a girl who later dies; years later her look-alike daughter loves him."},
    {"title": "Jo Jeeta Wohi Sikandar","year": 1992, "genre": "Sports Coming-of-Age","director": "Mansoor Khan",
     "plot": "Underachiever Sanju trains for inter-collegiate cycle race to salvage pride."},
    {"title": "Beta",                 "year": 1992, "genre": "Family Drama", "director": "Indra Kumar",
     "plot": "Devoted son’s wife battles scheming step-mother for household supremacy."},
    {"title": "Khuda Gawah",          "year": 1992, "genre": "Epic Action",  "director": "Mukesh Bhatta??","plot": "Afghan warrior Badshah Khan vows lifelong love after a sporting bet leads him to India."},
    {"title": "Deewana",              "year": 1992, "genre": "Romantic Drama","director": "Raj Kanwar",
     "plot": "Newly-widowed singer finds love again, unaware her first husband lives."},
    {"title": "Raju Ban Gaya Gentleman","year": 1992, "genre": "Rom-Com","director": "Aziz Mirza",
     "plot": "Idealistic engineer from Darjeeling navigates Mumbai’s ruthless construction world."},
    {"title": "Baazigar",             "year": 1993, "genre": "Revenge Thriller","director": "Abbas-Mustan",
     "plot": "A charming psychopath woos two sisters to destroy their crooked tycoon father."},
    {"title": "Khalnayak",            "year": 1993, "genre": "Action Thriller","director": "Subhash Ghai",
     "plot": "Daring policeman and girlfriend-officer chase flamboyant outlaw Ballu."},
    {"title": "Darr",                 "year": 1993, "genre": "Psychological Thriller","director": "Yash Chopra",
     "plot": "Obsessive stalker terrorizes the woman he loves and her naval-officer fiancé."},
    {"title": "Hum Hain Rahi Pyar Ke","year": 1993, "genre": "Family Rom-Com","director": "Mahesh Bhatt",
     "plot": "Guardian of three orphans hires a runaway heiress as nanny; chaos ensues."},
    {"title": "Hum Aapke Hain Koun..!", "year": 1994, "genre": "Family Romance","director": "Sooraj Barjatya",
     "plot": "Two large families celebrate 14 songs of love until tragedy tests duty versus desire."},
    {"title": "Mohra",                "year": 1994, "genre": "Action Thriller","director": "Rajiv Rai",
     "plot": "Jailed ex-commando becomes pawn in journalist’s crusade against drug syndicate."},
    {"title": "1942: A Love Story",   "year": 1994, "genre": "Period Romance","director": "Vidhu Vinod Chopra",
     "plot": "Lovers from opposing sides of Quit India movement confront betrayal and British might."},
    {"title": "Krantiveer",           "year": 1994, "genre": "Social Drama", "director": "Mehul Kumar",
     "plot": "Happy-go-lucky wastrel becomes fiery crusader against communal riots and corruption."},
    {"title": "Main Khiladi Tu Anari","year": 1994, "genre": "Buddy Action Comedy","director": "Sameer Malkan",
     "plot": "Method actor shadows tough cop to prepare for role; both chase deadly gangster."},
    {"title": "Dilwale Dulhania Le Jayenge","year": 1995, "genre": "Rom-Com","director": "Aditya Chopra",
     "plot": "NRIs Raj and Simran fall in Europe; Raj travels to Punjab to win her stern father."},
    {"title": "Rangeela",             "year": 1995, "genre": "Musical Rom-Com","director": "Ram Gopal Varma",
     "plot": "Tapori Munnabhai loves aspiring actress Mili, but her film-star co-actor woos her too."},
    {"title": "Karan Arjun",          "year": 1995, "genre": "Reincarnation Action","director": "Rakesh Roshan",
     "plot": "Murdered brothers reincarnate to avenge killing and protect their mother."},
    {"title": "Coolie No. 1",         "year": 1995, "genre": "Comic Capers","director": "David Dhawan",
     "plot": "A porter poses as tycoon to marry a rich man’s daughter, mayhem follows."},
    {"title": "Baazi",                "year": 1995, "genre": "Action Thriller","director": "Ashutosh Gowariker",
     "plot": "Honest cop battles corrupt chief minister unleashing plague on Mumbai."},
    {"title": "Ghatak",               "year": 1996, "genre": "Action Drama", "director": "Rajkumar Santoshi",
     "plot": "Kashi fights a tyrant don enslaving Varanasi’s impoverished neighbourhood."},
    {"title": "Raja Hindustani",      "year": 1996, "genre": "Rom-Drama",   "director": "Dharmesh Darshan",
     "plot": "Small-town cabbie and heiress elope; class divide threatens marriage."},
    {"title": "Khamoshi: The Musical","year": 1996, "genre": "Musical Drama","director": "Sanjay Leela Bhansali",
     "plot": "Hearing daughter of deaf-mute couple struggles between passion for music and filial duty."},
    {"title": "Border",               "year": 1997, "genre": "War Drama",   "director": "J. P. Dutta",
     "plot": "Outnumbered Indian soldiers hold Longewala post during the 1971 Indo-Pak war."},
    {"title": "Pardes",               "year": 1997, "genre": "Family Romance","director": "Subhash Ghai",
     "plot": "NRI businessman’s son and foster-son clash over desi bride engaged in small-town India."},
    {"title": "Dil To Pagal Hai",     "year": 1997, "genre": "Musical Romance","director": "Yash Chopra",
     "plot": "Dance troupe’s director discovers his dream girl while his best friend silently loves him."},
    {"title": "Ishq",                 "year": 1997, "genre": "Screwball Comedy","director": "Indra Kumar",
     "plot": "Rich-poor lovers’ parents scheme to break bonds using mistaken identities and slapstick."},
    {"title": "Kuch Kuch Hota Hai",   "year": 1998, "genre": "Campus Rom-Com","director": "Karan Johar",
     "plot": "Eight years after college, a widower’s daughter reunites him with tomboy best friend."},
    {"title": "Pyaar To Hona Hi Tha", "year": 1998, "genre": "Rom-Com",     "director": "Anees Bazmee",
     "plot": "Pet-thief helps jilted fiancée win back ex in Paris but falls himself."},
    {"title": "Satya",                "year": 1998, "genre": "Crime Drama", "director": "Ram Gopal Varma",
     "plot": "An innocent migrant descends into Mumbai underworld, ruining love and life."},
    {"title": "Ghulam",               "year": 1998, "genre": "Action Drama", "director": "Vikram Bhatt",
     "plot": "Street boxer rebels against local don after witnessing brother’s complicity."},
    {"title": "Soldier",              "year": 1998, "genre": "Revenge Thriller","director": "Abbas-Mustan",
     "plot": "Undercover officer poses as crook to expose army weapons scandal."},
    {"title": "Hum Dil De Chuke Sanam","year": 1999, "genre": "Romantic Drama","director": "Sanjay Leela Bhansali",
     "plot": "New bride’s husband takes her to Italy to reunite with her true love."},
    {"title": "Taal",                 "year": 1999, "genre": "Musical Romance","director": "Subhash Ghai",
     "plot": "Village singer’s love with NRI crumbles; she rises as pop diva guided by another suitor."},
    {"title": "Biwi No. 1",           "year": 1999, "genre": "Comedy",      "director": "David Dhawan",
     "plot": "Neglected wife transforms into glam model to teach philandering husband a lesson."},
    {"title": "Hum Saath-Saath Hain", "year": 1999, "genre": "Family Drama", "director": "Sooraj Barjatya",
     "plot": "Joint-family unity is tested by inheritance politics and scheming relatives."},
    {"title": "Sarfarosh",            "year": 1999, "genre": "Action Thriller","director": "John Mathew Matthan",
     "plot": "ACP Ajay fights cross-border arms smuggling aided by a ghazal singer with secrets."},
    {"title": "Vaastav",              "year": 1999, "genre": "Crime Drama", "director": "Mahesh Manjrekar",
     "plot": "Young man’s accidental killing thrusts him into the brutal Mumbai underworld."},
    {"title": "Dil Se..",             "year": 1998, "genre": "Romantic Thriller","director": "Mani Ratnam",
     "plot": "Radio journalist obsesses over mysterious woman tied to insurgency in Northeast."},
    {"title": "Akele Hum Akele Tum",  "year": 1995, "genre": "Relationship Drama","director": "Mansoor Khan",
     "plot": "Estranged artist parents battle for son’s custody while rediscovering love."},
    {"title": "Judaai",               "year": 1997, "genre": "Family Drama","director": "Raj Kanwar",
     "plot": "Greedy wife sells her husband to rich girl; regret follows riches."},
    {"title": "Virasat",              "year": 1997, "genre": "Rural Drama", "director": "Priyadarshan",
     "plot": "Foreign-educated heir returns to feuding village, inherits mantle of benevolent chief."},
    {"title": "Pyaar Kiya To Darna Kya","year": 1998,"genre": "Rom-Com","director": "Sohail Khan",
     "plot": "Rowdy college boy seeks farm-girl’s brother’s approval, battling bullies and buffalos."},

    # ---- 2000 – 2009 (60 titles) -----------------------------------------
    {"title": "Kaho Naa... Pyaar Hai", "year": 2000, "genre": "Musical Rom-Thriller","director": "Rakesh Roshan",
     "plot": "After her lover is killed, a woman meets his look-alike and uncovers a conspiracy."},
    {"title": "Mohabbatein",          "year": 2000, "genre": "Musical Drama","director": "Aditya Chopra",
     "plot": "A violinist confronts authoritarian principal over three blossoming campus romances."},
    {"title": "Dhadkan",              "year": 2000, "genre": "Romantic Drama","director": "Dharmesh Darshan",
     "plot": "Arranged-marriage bride’s ex-lover returns, now millionaire, intent on winning her back."},
    {"title": "Hera Pheri",           "year": 2000, "genre": "Situational Comedy","director": "Priyadarshan",
     "plot": "Broke tenants and landlord kidnap wrong girl in bid to repay debts."},
    {"title": "Lagaan",               "year": 2001, "genre": "Sports Epic", "director": "Ashutosh Gowariker",
     "plot": "Villagers challenge British officers to cricket match to abolish unjust tax."},
    {"title": "Dil Chahta Hai",       "year": 2001, "genre": "Buddy Drama", "director": "Farhan Akhtar",
     "plot": "Three privileged friends mature through love, heartbreak and art from Goa to Sydney."},
    {"title": "Gadar: Ek Prem Katha", "year": 2001, "genre": "Partition Action Romance","director": "Anil Sharma",
     "plot": "Sikh trucker crosses borders during 1947 carnage to rescue his Muslim wife."},
    {"title": "Kabhi Khushi Kabhie Gham","year": 2001, "genre": "Family Drama","director": "Karan Johar",
     "plot": "Adopted son marries poor girl, is disowned; younger brother reunites estranged family."},
    {"title": "Chandni Bar",          "year": 2001, "genre": "Social Drama", "director": "Madhur Bhandarkar",
     "plot": "Bar dancer’s struggle for dignity traps her children in Mumbai’s underbelly."},
    {"title": "Devdas",               "year": 2002, "genre": "Epic Romance", "director": "Sanjay Leela Bhansali",
     "plot": "Alcoholic aristocrat pines for childhood love, finds solace with courtesan."},
    {"title": "Raaz",                 "year": 2002, "genre": "Horror Thriller","director": "Vikram Bhatt",
     "plot": "Crisis-hit couple visits Ooty; wife haunted by spirit linked to husband’s affair."},
    {"title": "Humraaz",              "year": 2002, "genre": "Musical Thriller","director": "Abbas-Mustan",
     "plot": "Stage partners plot to swindle tycoon via marriage but love derails plan."},
    {"title": "Kaante",               "year": 2002, "genre": "Heist Action", "director": "Sanjay Gupta",
     "plot": "Six NRIs rob LA bank but suspect a mole during bloody standoff."},
    {"title": "Saathiya",             "year": 2002, "genre": "Urban Romance","director": "Shaad Ali",
     "plot": "Young lovers elope; mundane married life brings ego clashes and accident."},
    {"title": "Kal Ho Naa Ho",        "year": 2003, "genre": "Rom-Drama",   "director": "Nikkhil Advani",
     "plot": "Terminally-ill Aman teaches pessimistic Naina to love, pairing her with friend Rohit."},
    {"title": "Koi... Mil Gaya",      "year": 2003, "genre": "Sci-Fi Drama","director": "Rakesh Roshan",
     "plot": "Mentally-disabled man befriends stranded alien; gains super-human abilities."},
    {"title": "Tere Naam",            "year": 2003, "genre": "Tragic Romance","director": "Satish Kaushik",
     "plot": "Rowdy lover’s head injury leads to insanity, dooming his pure romance."},
    {"title": "Munna Bhai M.B.B.S.",  "year": 2003, "genre": "Comedy Drama","director": "Rajkumar Hirani",
     "plot": "Lovable goon fakes medical degree, heals hospital with ‘jadoo ki jhappi’."},
    {"title": "Baghban",              "year": 2003, "genre": "Family Drama", "director": "Ravi Chopra",
     "plot": "Elderly couple separated by selfish sons find refuge with adopted boy."},
    {"title": "LOC Kargil",           "year": 2003, "genre": "War Epic",    "director": "J. P. Dutta",
     "plot": "Multi-star chronicle of Indian Army’s 1999 Kargil mountain battles."},
    {"title": "Veer-Zaara",           "year": 2004, "genre": "Cross-Border Romance","director": "Yash Chopra",
     "plot": "Indian pilot imprisoned in Pakistan re-unites with lover after 22 years."},
    {"title": "Swades",               "year": 2004, "genre": "Drama",       "director": "Ashutosh Gowariker",
     "plot": "NASA engineer returns home, electrifies village, rediscovers rooted identity."},
    {"title": "Dhoom",                "year": 2004, "genre": "Action Heist","director": "Sanjay Gadhvi",
     "plot": "Mumbai cop teams up with racer to nab a biker gang of thieves."},
    {"title": "Main Hoon Na",         "year": 2004, "genre": "Action Comedy","director": "Farah Khan",
     "plot": "Army major goes undercover in college to protect general’s daughter from militant."},
    {"title": "Hum Tum",              "year": 2004, "genre": "Rom-Com",     "director": "Kunal Kohli",
     "plot": "Cartoonist and spirited woman meet over a decade, falling in love late."},
    {"title": "Mujhse Shaadi Karogi","year": 2004, "genre": "Rom-Com",     "director": "David Dhawan",
     "plot": "Short-tempered man’s room-mate sabotages his romance with neighbour."},
    {"title": "Lakshya",              "year": 2004, "genre": "War Drama",   "director": "Farhan Akhtar",
     "plot": "Aimless youth becomes Kargil war hero scaling impossible cliff."},
    {"title": "Black",                "year": 2005, "genre": "Inspirational Drama","director": "Sanjay Leela Bhansali",
     "plot": "Blind-deaf girl’s turbulent bond with eccentric teacher unlocks sightless horizons."},
    {"title": "Bunty Aur Babli",      "year": 2005, "genre": "Con-Comedy",  "director": "Shaad Ali",
     "plot": "Small-town dreamers become Bonnie-and-Clyde scammers tailed by weary cop."},
    {"title": "Parineeta",            "year": 2005, "genre": "Period Romance","director": "Pradeep Sarkar",
     "plot": "Childhood sweethearts battle class prejudice in 1960s Calcutta."},
    {"title": "No Entry",             "year": 2005, "genre": "Adult Comedy", "director": "Anees Bazmee",
     "plot": "Philandering husbands, suspicious wives and a call-girl cause door-slamming confusion."},
    {"title": "Salaam Namaste",       "year": 2005, "genre": "Rom-Com",     "director": "Siddharth Anand",
     "plot": "Live-in couple in Melbourne navigate career, commitment and unplanned pregnancy."},
    {"title": "Rang De Basanti",      "year": 2006, "genre": "Youth Drama", "director": "Rakyesh Omprakash Mehra",
     "plot": "Delhi slackers portray freedom fighters, awaken to fight corruption after friend’s death."},
    {"title": "Krrish",               "year": 2006, "genre": "Superhero",   "director": "Rakesh Roshan",
     "plot": "Gifted youngster dons mask to thwart evil scientist reviving alien tech."},
    {"title": "Fanaa",                "year": 2006, "genre": "Romantic Thriller","director": "Kunal Kohli",
     "plot": "Blind Kashmiri tourist loves Delhi guide who’s actually a terrorist."},
    {"title": "Kabhi Alvida Naa Kehna","year": 2006,"genre": "Relationship Drama","director": "Karan Johar",
     "plot": "Two unhappy spouses confront taboo love and choices in NYC."},
    {"title": "Lage Raho Munna Bhai", "year": 2006, "genre": "Comedy Drama","director": "Rajkumar Hirani",
     "plot": "Lovable don adopts Gandhi’s ideals to woo radio jockey and reform society."},
    {"title": "Dhoom 2",              "year": 2006, "genre": "Action Heist","director": "Sanjay Gadhvi",
     "plot": "Charismatic thief ‘A’ raids global treasures; cat-and-mouse with cool cop."},
    {"title": "Om Shanti Om",         "year": 2007, "genre": "Reincarnation Masala","director": "Farah Khan",
     "plot": "Junior artist reborn as superstar avenges actress burned alive by producer."},
    {"title": "Chak De! India",       "year": 2007, "genre": "Sports Drama","director": "Shimit Amin",
     "plot": "Disgraced hockey captain coaches Indian women’s team to World Cup glory."},
    {"title": "Taare Zameen Par",     "year": 2007, "genre": "Inspirational Drama","director": "Aamir Khan",
     "plot": "Dyslexic boy’s art teacher reveals hidden brilliance to skeptical parents."},
    {"title": "Jab We Met",           "year": 2007, "genre": "Rom-Com",     "director": "Imtiaz Ali",
     "plot": "Depressed tycoon meets talkative Sikh girl; accidental journey transforms both."},
    {"title": "Bhool Bhulaiyaa",      "year": 2007, "genre": "Horror-Comedy","director": "Priyadarshan",
     "plot": "Psychiatrist investigates palace hauntings linked to dissociative identity."},
    {"title": "Partner",              "year": 2007, "genre": "Rom-Com",     "director": "David Dhawan",
     "plot": "Love guru helps awkward man woo boss while bungling his own romance."},
    {"title": "Jodhaa Akbar",         "year": 2008, "genre": "Historical Epic","director": "Ashutosh Gowariker",
     "plot": "Political marriage between Mughal emperor Akbar and Rajput princess blooms into love."},
    {"title": "Ghajini",              "year": 2008, "genre": "Action Thriller","director": "A. R. Murugadoss",
     "plot": "Tycoon with 15-minute memory hunts gang lord who murdered his fiancée."},
    {"title": "Rock On!!",            "year": 2008, "genre": "Musical Drama","director": "Abhishek Kapoor",
     "plot": "Estranged college band reunites years later to reclaim lost dreams."},
    {"title": "Dostana",              "year": 2008, "genre": "Rom-Com",     "director": "Tarun Mansukhani",
     "plot": "Two men pretend to be gay roommates to rent Miami flat; both love landlady."},
    {"title": "Rab Ne Bana Di Jodi",  "year": 2008, "genre": "Rom-Com",     "director": "Aditya Chopra",
     "plot": "Shy husband dons funky alter-ego to win vivacious wife in dance contest."},
    {"title": "Fashion",              "year": 2008, "genre": "Drama",       "director": "Madhur Bhandarkar",
     "plot": "Small-town girl’s meteoric modeling rise and devastating fall in glamour world."},
    {"title": "Singh Is Kinng",       "year": 2008, "genre": "Action Comedy","director": "Anees Bazmee",
     "plot": "Bumbling Punjabi becomes Australia’s gangster king and spreads goodness."},
    {"title": "3 Idiots",             "year": 2009, "genre": "Coming-of-Age Comedy","director": "Rajkumar Hirani",
     "plot": "Engineering roommates rebel against rote system, search for maverick friend ‘Rancho’."},
    {"title": "Love Aaj Kal",         "year": 2009, "genre": "Rom-Drama",   "director": "Imtiaz Ali",
     "plot": "Modern couple dissect love via flashbacks to 1970s Sikh romance."},
    {"title": "Wanted",               "year": 2009, "genre": "Action",      "director": "Prabhu Deva",
     "plot": "Gritty hit-man Inspector Radhe infiltrates city gang to eliminate crime lord."},
    {"title": "Kaminey",              "year": 2009, "genre": "Crime Thriller","director": "Vishal Bhardwaj",
     "plot": "Twin brothers—one lisps, one stammers—tangle with cops, dons and a guitar case of cocaine."},
    {"title": "Dev.D",                "year": 2009, "genre": "Experimental Drama","director": "Anurag Kashyap",
     "plot": "Modern ‘Devdas’ spirals into drugs and neon brothels after heartbreak."},
    {"title": "Ajab Prem Ki Ghazab Kahani","year": 2009,"genre": "Rom-Com","director": "Rajkumar Santoshi",
     "plot": "Happy-go-lucky boy helps stammering girl unite with true love but wins her heart instead."},
    {"title": "Paa",                  "year": 2009, "genre": "Emotional Drama","director": "R. Balki",
     "plot": "12-year-old with progeria bonds with estranged politician father."},
    {"title": "Race",                 "year": 2008, "genre": "Stylish Thriller","director": "Abbas-Mustan",
     "plot": "Plot twists galore as step-brothers plot double-crosses over insurance fortune."},
    {"title": "Wake Up Sid",          "year": 2009, "genre": "Coming-of-Age", "director": "Ayan Mukerji",
     "plot": "Spoiled Mumbai boy mentors under indie writer, discovers passion for photography."},

    # ---- 2010 – 2019 (70 titles) -----------------------------------------
    {"title": "Dabangg",              "year": 2010, "genre": "Action Masala","director": "Abhinav Kashyap",
     "plot": "Fearless cop Chulbul Pandey battles corrupt politician and half-brother."},
    {"title": "My Name Is Khan",      "year": 2010, "genre": "Drama",       "director": "Karan Johar",
     "plot": "Autistic Muslim man crosses post-9/11 America to tell President he is not a terrorist."},
    {"title": "Raajneeti",            "year": 2010, "genre": "Political Drama","director": "Prakash Jha",
     "plot": "Modern Mahabharata in electoral battlefield of a powerful dynasty."},
    {"title": "Housefull",            "year": 2010, "genre": "Ensemble Comedy","director": "Sajid Khan",
     "plot": "Unlucky-in-love man fakes marriage, triggering a domino of mistaken identities."},
    {"title": "Band Baaja Baaraat",   "year": 2010, "genre": "Rom-Com",     "director": "Maneesh Sharma",
     "plot": "Street-smart Delhiites start wedding-planning biz, fall in love amid marigolds."},
    {"title": "Zindagi Na Milegi Dobara","year": 2011,"genre": "Buddy Road Film","director": "Zoya Akhtar",
     "plot": "Three friends confront fears on a bachelor trip across scenic Spain."},
    {"title": "Bodyguard",            "year": 2011, "genre": "Action Romance","director": "Siddique",
     "plot": "Loyal bodyguard unknowingly romances boss’s daughter over secret calls."},
    {"title": "Singham",              "year": 2011, "genre": "Action",      "director": "Rohit Shetty",
     "plot": "Straight-arrow village cop takes on swaggering Goa don-politician nexus."},
    {"title": "Rockstar",             "year": 2011, "genre": "Musical Drama","director": "Imtiaz Ali",
     "plot": "Heartbreak propels shy guitarist into self-destructive stardom."},
    {"title": "Delhi Belly",          "year": 2011, "genre": "Black Comedy","director": "Abhinay Deo",
     "plot": "Journalist roommates dodge gangsters after mis-delivered smuggled diamonds and food poisoning."},
    {"title": "Agneepath",            "year": 2012, "genre": "Action Drama","director": "Karan Malhotra",
     "plot": "Vijay Chauhan destroys sadistic Kancha controlling Mandwa island."},
    {"title": "Barfi!",               "year": 2012, "genre": "Rom-Com Drama","director": "Anurag Basu",
     "plot": "Deaf-mute boy, autistic girl and journalist weave bittersweet love triangle in 1970s Darjeeling."},
    {"title": "Ek Tha Tiger",         "year": 2012, "genre": "Spy Action",  "director": "Kabir Khan",
     "plot": "RAW agent Tiger falls for ISI rival during Irish assignment."},
    {"title": "Kahaani",              "year": 2012, "genre": "Thriller",    "director": "Sujoy Ghosh",
     "plot": "Pregnant woman hunts missing husband in Kolkata; nothing is as it seems."},
    {"title": "Student of the Year",  "year": 2012, "genre": "Campus Rom-Com","director": "Karan Johar",
     "plot": "Three rich students compete for love and coveted trophy."},
    {"title": "Gangs of Wasseypur",   "year": 2012, "genre": "Crime Saga",  "director": "Anurag Kashyap",
     "plot": "70-year revenge between coal mafia families in Bihar’s badlands."},
    {"title": "Chennai Express",      "year": 2013, "genre": "Action Comedy","director": "Rohit Shetty",
     "plot": "Man’s Goa plan derails when he helps runaway south-Indian bride on train."},
    {"title": "Dhoom 3",              "year": 2013, "genre": "Heist Thriller","director": "Vijay Krishna Acharya",
     "plot": "Illusionist twins rob Chicago bank to avenge father; biker cops pursue."},
    {"title": "Bhaag Milkha Bhaag",   "year": 2013, "genre": "Biopic Sports","director": "Rakyesh O. Mehra",
     "plot": "Trauma-scarred refugee becomes India’s flying Sikh sprinter Milkha Singh."},
    {"title": "Yeh Jawaani Hai Deewani","year": 2013,"genre": "Rom-Com","director": "Ayan Mukerji",
     "plot": "Free-spirited backpacker reunites with studious classmate on Himalayan trek."},
    {"title": "Kai Po Che!",          "year": 2013, "genre": "Coming-of-Age","director": "Abhishek Kapoor",
     "plot": "Three friends open cricket academy; Gujarat riots alter destinies."},
    {"title": "Aashiqui 2",           "year": 2013, "genre": "Musical Romance","director": "Mohit Suri",
     "plot": "Fading rockstar mentors bar singer who eclipses his stardom while he spirals."},
    {"title": "PK",                   "year": 2014, "genre": "Satire Drama","director": "Rajkumar Hirani",
     "plot": "Alien questions religious dogma while searching for remote to contact spaceship."},
    {"title": "Queen",                "year": 2014, "genre": "Comedy Drama","director": "Vikas Bahl",
     "plot": "Dumped bride embarks on solo Europe honeymoon, discovering independence."},
    {"title": "Kick",                 "year": 2014, "genre": "Action Masala","director": "Sajid Nadiadwala",
     "plot": "Thrill-seeker Devil robs corrupt tycoons to fund sick children’s surgeries."},
    {"title": "Haider",               "year": 2014, "genre": "Political Drama","director": "Vishal Bhardwaj",
     "plot": "Kashmiri student returns to find father missing, mother with uncle; Hamlet ensues."},
    {"title": "Highway",              "year": 2014, "genre": "Road Drama",  "director": "Imtiaz Ali",
     "plot": "Kidnapped heiress finds freedom on rustic journey with abductors."},
    {"title": "2 States",             "year": 2014, "genre": "Rom-Com",     "director": "Abhishek Varman",
     "plot": "Punjabi boy, Tamil girl battle cross-cultural parents for marriage approval."},
    {"title": "Baahubali: The Beginning (Hindi)","year": 2015,"genre": "Mythic Action","director": "S. S. Rajamouli",
     "plot": "Raised by villagers, Shivudu discovers royal lineage and vows to rescue captive queen."},
    {"title": "Bajrangi Bhaijaan",    "year": 2015, "genre": "Adventure Drama","director": "Kabir Khan",
     "plot": "Devout Indian escorts mute Pakistani girl home through perilous borders."},
    {"title": "Tanu Weds Manu Returns","year": 2015,"genre": "Rom-Com","director": "Aanand L. Rai",
     "plot": "Estranged couple’s divorce detours when husband meets wife’s spunky doppelgänger."},
    {"title": "Dil Dhadakne Do",      "year": 2015, "genre": "Ensemble Dramedy","director": "Zoya Akhtar",
     "plot": "Dysfunctional rich family’s cruise exposes marital and business cracks."},
    {"title": "Piku",                 "year": 2015, "genre": "Slice-of-Life","director": "Shoojit Sircar",
     "plot": "Road-trip with constipated father deepens bond with stressed architect daughter."},
    {"title": "Airlift",              "year": 2016, "genre": "Historical Thriller","director": "Raja Menon",
     "plot": "Kuwait-based Indian tycoon leads world’s largest civilian evacuation during 1990 invasion."},
    {"title": "Dangal",               "year": 2016, "genre": "Sports Biopic","director": "Nitesh Tiwari",
     "plot": "Wrestler trains daughters to win India’s first female world wrestling gold."},
    {"title": "Sultan",               "year": 2016, "genre": "Sports Drama","director": "Ali Abbas Zafar",
     "plot": "Washed-up wrestler stages MMA comeback and redeems love life."},
    {"title": "Udta Punjab",          "year": 2016, "genre": "Crime Drama", "director": "Abhishek Chaubey",
     "plot": "Drug epidemic intertwines rockstar, migrant, cop and doctor in Punjab."},
    {"title": "Neerja",               "year": 2016, "genre": "Biopic Thriller","director": "Ram Madhvani",
     "plot": "23-year-old flight purser sacrifices life saving passengers from hijackers."},
    {"title": "M.S. Dhoni: The Untold Story","year": 2016,"genre": "Sports Biopic","director": "Neeraj Pandey",
     "plot": "Ticket collector’s rise to World-Cup-winning Indian cricket captain."},
    {"title": "Ae Dil Hai Mushkil",   "year": 2016, "genre": "Romantic Drama","director": "Karan Johar",
     "plot": "Unrequited love, heartbreak and friendship across London, Paris and Vienna."},
    {"title": "Baahubali 2: The Conclusion (Hindi)", "year": 2017, "genre": "Mythic Action", "director": "S. S. Rajamouli",
     "plot": "Son of slain prince returns to overthrow cruel cousin and reunite kingdom."},
    {"title": "Tiger Zinda Hai",      "year": 2017, "genre": "Spy Action",  "director": "Ali Abbas Zafar",
     "plot": "RAW agent Tiger and ISI wife rescue nurses from Iraqi terrorist."},
    {"title": "Hindi Medium",         "year": 2017, "genre": "Social Satire","director": "Saket Chaudhary",
     "plot": "Chandni Chowk couple pretends poverty to secure daughter’s elite school admission."},
    {"title": "Secret Superstar",     "year": 2017, "genre": "Musical Drama","director": "Advait Chandan",
     "plot": "Burqa-clad YouTuber defies abusive father to pursue singing dream."},
    {"title": "Toilet: Ek Prem Katha","year": 2017, "genre": "Social Comedy","director": "Shree Narayan Singh",
     "plot": "New bride leaves rural home lacking toilet; husband fights tradition to build one."},
    {"title": "Raees",                "year": 2017, "genre": "Crime Drama", "director": "Rahul Dholakia",
     "plot": "Bootlegger in 1980s Gujarat clashes with righteous cop."},
    {"title": "Padmaavat",            "year": 2018, "genre": "Historical Epic","director": "Sanjay Leela Bhansali",
     "plot": "Alauddin Khilji obsesses over Rajput queen leading to fiery jauhar."},
    {"title": "Sanju",                "year": 2018, "genre": "Biopic Drama","director": "Rajkumar Hirani",
     "plot": "Roller-coaster life of controversial actor Sanjay Dutt."},
    {"title": "Andhadhun",            "year": 2018, "genre": "Black Comedy Thriller","director": "Sriram Raghavan",
     "plot": "Blind pianist (or is he?) trapped in murder plot of aging star."},
    {"title": "Badhaai Ho",           "year": 2018, "genre": "Comedy Drama","director": "Amit Ravindernath Sharma",
     "plot": "Middle-aged mother’s unexpected pregnancy embarrasses grown sons and nosy neighbours."},
    {"title": "Stree",                "year": 2018, "genre": "Horror-Comedy","director": "Amar Kaushik",
     "plot": "Male-abducting witch haunts small town; tailor and pals investigate."},
    {"title": "Raazi",                "year": 2018, "genre": "Spy Thriller","director": "Meghna Gulzar",
     "plot": "Kashmiri girl marries Pakistani officer as Indian undercover agent in 1971."},
    {"title": "Sonu Ke Titu Ki Sweety","year": 2018,"genre": "Bromance Comedy","director": "Luv Ranjan",
     "plot": "Serial dater’s fiancée locks horns with his possessive best friend."},
    {"title": "Simmba",               "year": 2018, "genre": "Action Masala","director": "Rohit Shetty",
     "plot": "Corrupt cop reforms after sister-figure’s assault; wreaks vengeance on rapists."},
    {"title": "Uri: The Surgical Strike","year": 2019,"genre": "War Action","director": "Aditya Dhar",
     "plot": "Indian commandos execute covert retaliation inside PoK after 2016 terror attack."},
    {"title": "Gully Boy",            "year": 2019, "genre": "Hip-Hop Drama","director": "Zoya Akhtar",
     "plot": "Slum youth channels angst into rap, rises from Dharavi to world stage."},
    {"title": "Kabir Singh",          "year": 2019, "genre": "Romantic Drama","director": "Sandeep Reddy Vanga",
     "plot": "Brilliant surgeon’s self-destruction after lover’s arranged marriage."},
    {"title": "War",                  "year": 2019, "genre": "Action Thriller","director": "Siddharth Anand",
     "plot": "Rogue agent Kabir challenges protégé in globe-trotting stunt spectacle."},
    {"title": "Article 15",           "year": 2019, "genre": "Social Thriller","director": "Anubhav Sinha",
     "plot": "IPS officer confronts caste atrocities while investigating missing Dalit girls."},
    {"title": "Dream Girl",           "year": 2019, "genre": "Comedy",      "director": "Raaj Shaandilyaa",
     "plot": "Man with female voice impersonation becomes crisis-hotline star, chaos follows."},
    {"title": "Bala",                 "year": 2019, "genre": "Comedy Drama","director": "Amar Kaushik",
     "plot": "Young man’s premature balding tests vanity and relationships."},
    {"title": "Chhichhore",           "year": 2019, "genre": "Comedy Drama","director": "Nitesh Tiwari",
     "plot": "Middle-aged friends recall hostel misadventures to heal suicidal son."},
    {"title": "Good Newwz",           "year": 2019, "genre": "Comedy",      "director": "Raj Mehta",
     "plot": "Sperm-mix-up at IVF clinic swaps two very different couples’ pregnancies."},
    {"title": "Housefull 2",          "year": 2012, "genre": "Slapstick Comedy","director": "Sajid Khan",
     "plot": "Con-men pose as billionaires; four brides, four grooms, double chaos."},
    {"title": "Total Dhamaal",        "year": 2019, "genre": "Adventure Comedy","director": "Indra Kumar",
     "plot": "Eccentric groups race across country to grab hidden 50-crore loot."},
    {"title": "Kedarnath",            "year": 2018, "genre": "Romantic Drama","director": "Abhishek Kapoor",
     "plot": "Muslim porter and Hindu pilgrim’s love tested by 2013 Uttarakhand floods."},
    {"title": "Judwaa 2",             "year": 2017, "genre": "Action Comedy","director": "David Dhawan",
     "plot": "Separated twins reunite to defeat smuggling kingpin, woo girlfriends."},
    {"title": "Bharat",               "year": 2019, "genre": "Epic Drama",  "director": "Ali Abbas Zafar",
     "plot": "Everyman’s 70-year journey mirrors India’s post-Partition history."},
    {"title": "Luka Chuppi",          "year": 2019, "genre": "Rom-Com",     "director": "Laxman Utekar",
     "plot": "Live-in couple hide relationship from conservative families in Mathura."},
    {"title": "Baaghi 2",             "year": 2018, "genre": "Action",      "director": "Ahmed Khan",
     "plot": "Army officer rescues ex-lover’s kidnapped child, unearthing trafficking ring."},

    # ---- 2020 – 2025 (51 titles) -----------------------------------------
    {"title": "Tanhaji: The Unsung Warrior","year": 2020,"genre": "Historical Action","director": "Om Raut",
     "plot": "Maratha warrior Tanaji storms Kondhana fort from Mughals in 17th century."},
    {"title": "Baaghi 3",             "year": 2020, "genre": "Action",      "director": "Ahmed Khan",
     "plot": "Fearless Ronnie wreaks havoc in Syria to rescue kidnapped brother."},
    {"title": "Malang",               "year": 2020, "genre": "Action Thriller","director": "Mohit Suri",
     "plot": "Drug-fuelled beach romance turns into vengeful night of killings."},
    {"title": "Shubh Mangal Zyada Saavdhan","year": 2020,"genre": "Gay Rom-Com","director": "Hitesh Kewalya",
     "plot": "Gay couple fight family prejudice in small-town wedding chaos."},
    {"title": "Dil Bechara",          "year": 2020, "genre": "Rom-Drama",   "director": "Mukesh Chhabra",
     "plot": "Terminal teens in Jamshedpur live big love inspired by ‘TFIOS’."},
    {"title": "Ludo",                 "year": 2020, "genre": "Dark Comedy Anthology","director": "Anurag Basu",
     "plot": "Four intersecting tales of crime, fate and board-game chance."},
    {"title": "Sooryavanshi",         "year": 2021, "genre": "Action",      "director": "Rohit Shetty",
     "plot": "ATS chief thwarts massive sleeper-cell terror attack in Mumbai."},
    {"title": "Shershaah",            "year": 2021, "genre": "War Biopic",  "director": "Vishnuvardhan",
     "plot": "Captain Vikram Batra’s heroic sacrifice in 1999 Kargil war."},
    {"title": "Mimi",                 "year": 2021, "genre": "Drama Comedy","director": "Laxman Utekar",
     "plot": "Small-town dancer becomes surrogate for US couple; raises baby alone."},
    {"title": "Chandigarh Kare Aashiqui","year": 2021,"genre": "Rom-Drama","director": "Abhishek Kapoor",
     "plot": "Bodybuilder loves Zumba instructor, struggles after learning she’s trans woman."},
    {"title": "83",                   "year": 2021, "genre": "Sports Drama","director": "Kabir Khan",
     "plot": "India’s underdog cricket team lifts 1983 World Cup at Lord’s."},
    {"title": "Bell Bottom",          "year": 2021, "genre": "Spy Thriller","director": "Ranjit Tewari",
     "plot": "RAW officer leads covert mission to rescue hijacked plane in Dubai."},
    {"title": "Gangubai Kathiawadi",  "year": 2022, "genre": "Biopic Drama","director": "Sanjay Leela Bhansali",
     "plot": "Teen girl sold to brothel becomes powerful champion of sex-workers."},
    {"title": "RRR (Hindi)",          "year": 2022, "genre": "Mythic Action","director": "S. S. Rajamouli",
     "plot": "Fictionalised Telugu freedom fighters unite against British Raj."},
    {"title": "Brahmāstra Part One: Shiva","year": 2022,"genre": "Fantasy Adventure","director": "Ayan Mukerji",
     "plot": "DJ with fire astrā powers protects universe-splitting Brahmāstra fragment."},
    {"title": "Drishyam 2",           "year": 2022, "genre": "Crime Thriller","director": "Abhishek Pathak",
     "plot": "Goa family’s perfect cover-up faces reopened police investigation seven years later."},
    {"title": "Bhool Bhulaiyaa 2",    "year": 2022, "genre": "Horror-Comedy","director": "Anees Bazmee",
     "plot": "Con-man kid reawakens vengeful spirit Manjulika in ancestral haveli."},
    {"title": "The Kashmir Files",    "year": 2022, "genre": "Historical Drama","director": "Vivek Agnihotri",
     "plot": "Exposes exodus of Kashmiri Pandits through survivor professor and inquisitive student."},
    {"title": "Kantara (Hindi)",      "year": 2022, "genre": "Folklore Action","director": "Rishab Shetty",
     "plot": "Village guardian clashes with forest department over sacred land and deities."},
    {"title": "Pathaan",              "year": 2023, "genre": "Spy Action",  "director": "Siddharth Anand",
     "plot": "Exiled agent Pathaan thwarts bioweapon attack by rogue RAW officer."},
    {"title": "Jawan",                "year": 2023, "genre": "Vigilante Action","director": "Atlee",
     "plot": "Masked crusader hijacks metro; mission ties to vendetta against corrupt politician."},
    {"title": "Gadar 2",              "year": 2023, "genre": "War Drama",   "director": "Anil Sharma",
     "plot": "Truck driver Tara Singh enters 1971 Pakistan to rescue captured son."},
    {"title": "Animal",               "year": 2023, "genre": "Gangster Saga","director": "Sandeep Reddy Vanga",
     "plot": "Violent son’s obsession with distant father drives bloody underworld ascent."},
    {"title": "Rocky Aur Rani Kii Prem Kahaani","year": 2023,"genre": "Rom-Com","director": "Karan Johar",
     "plot": "Culture-clash lovers swap families for three months to prove compatibility."},
    {"title": "OMG 2",                "year": 2023, "genre": "Social Satire","director": "Amit Rai",
     "plot": "Messenger of Shiva guides teen in masturbation scandal and court crusade for sex-ed."},
    {"title": "12th Fail",            "year": 2023, "genre": "Biopic Drama","director": "Vidhu Vinod Chopra",
     "plot": "Village boy who failed class XII cracks India’s toughest UPSC exam."},
    {"title": "Tu Jhoothi Main Makkaar","year": 2023,"genre": "Rom-Com","director": "Luv Ranjan",
     "plot": "Break-up artist falls for commitment-phobic girl; families complicate split."},
    {"title": "Zara Hatke Zara Bachke","year": 2023,"genre": "Family Rom-Com","director": "Laxman Utekar",
     "plot": "Small-town couple fake divorce to qualify for government housing quota."},
    {"title": "The Kerala Story",     "year": 2023, "genre": "Drama Thriller","director": "Sudipto Sen",
     "plot": "Woman recounts radicalisation and trafficking of Kerala girls to ISIS."},
    {"title": "Fukrey 3",             "year": 2023, "genre": "Comedy Caper","director": "Mrighdeep Lamba",
     "plot": "Delhi slackers battle corrupt politician via water-theft scheme."},
    {"title": "Satyaprem Ki Katha",   "year": 2023, "genre": "Rom-Drama",  "director": "Sameer Vidwans",
     "plot": "Small-town dreamer marries survivor of assault; healing love blossoms."},
    {"title": "Dream Girl 2",         "year": 2023, "genre": "Comedy",      "director": "Raaj Shaandilyaa",
     "plot": "Karam’s female call-voice alters life again when debts force bigger charade."},
    {"title": "Tiger 3",              "year": 2023, "genre": "Spy Action",  "director": "Maneesh Sharma",
     "plot": "Aging agents Tiger & Zoya race against ex-RAW chief’s conspiracy."},
    {"title": "Fighter",              "year": 2024, "genre": "Aerial Action","director": "Siddharth Anand",
     "plot": "Elite Indian Air-Force unit counters cross-border terror in high-octane dogfights."},
    {"title": "Dunki",                "year": 2024, "genre": "Dramedy",     "director": "Rajkumar Hirani",
     "plot": "Illegal immigrations via ‘donkey route’ explored with humour and heart."},
    {"title": "Article 370",          "year": 2024, "genre": "Political Thriller","director": "Aditya Suhas Jambhale",
     "plot": "Agent involved in covert manoeuvres behind abrogation of Kashmir’s special status."},
    {"title": "Crew",                 "year": 2024, "genre": "Heist Comedy","director": "Rajesh A. Krishnan",
     "plot": "Debt-ridden air-hostesses stumble upon smuggling ring of gold bars."},
    {"title": "Shaitaan",             "year": 2024, "genre": "Supernatural Thriller","director": "Vikas Bahl",
     "plot": "Family battles eerie stranger who hypnotises teen daughter via occult."},
    {"title": "Teri Baaton Mein Aisa Uljha Jiya","year": 2024,"genre": "Sci-Fi Rom-Com","director": "Amit Joshi",
     "plot": "Robotics engineer falls for humanoid android intended for uncle’s US project."},
    {"title": "Bade Miyan Chote Miyan","year": 2024,"genre": "Action Buddy","director": "Ali Abbas Zafar",
     "plot": "Two elite soldiers retrieve stolen AI weapon from rogue scientist."},
    {"title": "Laapataa Ladies",      "year": 2024, "genre": "Comedy Drama","director": "Kiran Rao",
     "plot": "Groom loses veiled bride on rural train; mix-ups spark female agency."},
    {"title": "Premalu (Hindi)",      "year": 2024, "genre": "Rom-Com",     "director": "Girivinay Nair",
     "plot": "Malayali youth’s Bangalore crush turns into sweet comic pursuit."},
    {"title": "Crakk – Jeetegaa Toh Jiyegaa!", "year": 2024, "genre": "Sports Action","director": "Aditya Datt",
     "plot": "Slum freerunner enters deadly underground extreme-sports competition for glory."},
    {"title": "Kuch Khattaa Ho Jaay", "year": 2024, "genre": "Family Comedy","director": "Ashok Gahlot",
     "plot": "Newlyweds fake pregnancy for inheritance; real chaos follows."},
    {"title": "Yodha",                "year": 2024, "genre": "Action Thriller","director": "Sagar Ambre",
     "plot": "Disgraced commando boards hijacked flight to prove innocence."},
    {"title": "Swatantrya Veer Savarkar","year": 2024,"genre": "Biopic Drama","director": "Randeep Hooda",
     "plot": "Life of revolutionary Vinayak Damodar Savarkar from cellular jail to politics."},
    {"title": "Mr & Mrs Mahi",        "year": 2024, "genre": "Sports Rom-Drama","director": "Sharan Sharma",
     "plot": "Failed cricketer coaches his doctor-wife to live his dream on field."},
    {"title": "Sarfira",              "year": 2024, "genre": "Inspirational Drama","director": "Sudha Kongara",
     "plot": "Village dropout battles aviation establishment to launch low-cost airline."},
    {"title": "Stree 2",              "year": 2024, "genre": "Horror-Comedy","director": "Amar Kaushik",
     "plot": "Men of Chanderi again confront man-hunting witch’s chilling return."},
    {"title": "Singham Again",        "year": 2025, "genre": "Action",      "director": "Rohit Shetty",
     "plot": "DCP Bajirao Singham joins cop-verse to crush terrorist network in Varanasi."},
    {"title": "Bhool Bhulaiyaa 3",    "year": 2025, "genre": "Horror-Comedy","director": "Anees Bazmee",
     "plot": "Psychiatrist Rooh Baba faces new labyrinth of spirits in ancestral palace."}
]

# Simple function to connect to AWS Bedrock
def connect_to_bedrock():
    try:
        client = boto3.client('bedrock-runtime', region_name='us-east-1')
        return client
    except:
        st.error("⚠️ AWS Bedrock not configured. Using mock responses for demo.")
        return None

# Get embeddings from Bedrock
def get_embeddings(bedrock_client, text):
    if not bedrock_client:
        # Return dummy embedding for demo
        import random
        return [random.random() for _ in range(1536)]
    
    try:
        body = json.dumps({"inputText": text})
        response = bedrock_client.invoke_model(
            modelId="amazon.titan-embed-text-v1",
            body=body
        )
        result = json.loads(response['body'].read())
        return result['embedding']
    except:
        # Return dummy embedding if API fails
        import random
        return [random.random() for _ in range(1536)]

# Create movie documents and store in ChromaDB
def setup_movie_database(bedrock_client):
    st.write("🎬 Setting up Bollywood movies database...")
    
    # Create ChromaDB client
    chroma_client = chromadb.Client()
    
    # Create or recreate collection
    try:
        chroma_client.delete_collection("bollywood_movies")
    except:
        pass
    
    collection = chroma_client.create_collection("bollywood_movies")
    
    # Prepare data for ChromaDB
    ids = []
    documents = []
    metadatas = []
    embeddings = []
    
    progress_bar = st.progress(0)
    
    for i, movie in enumerate(SAMPLE_MOVIES):
        # Create document text
        doc_text = f"Title: {movie['title']}\nYear: {movie['year']}\nGenre: {movie['genre']}\nDirector: {movie['director']}\nPlot: {movie['plot']}"
        
        # Get embedding
        embedding = get_embeddings(bedrock_client, doc_text)
        
        # Prepare data
        ids.append(str(i))
        documents.append(doc_text)
        metadatas.append({
            'title': movie['title'],
            'year': movie['year'],
            'genre': movie['genre'].lower(),
            'director': movie['director'].lower(),
            'decade': f"{(movie['year'] // 10) * 10}s"
        })
        embeddings.append(embedding)
        
        progress_bar.progress((i + 1) / len(SAMPLE_MOVIES))
    
    # Add to ChromaDB
    collection.add(
        ids=ids,
        documents=documents,
        metadatas=metadatas,
        embeddings=embeddings
    )
    
    st.success(f"✅ Added {len(SAMPLE_MOVIES)} movies to database!")
    return collection

# Simple query filter detection
def detect_filters(query):
    query_lower = query.lower()
    filters = {}
    
    # Genre detection
    genres = ['action', 'comedy', 'drama', 'romance', 'sports', 'adventure']
    for genre in genres:
        if genre in query_lower:
            filters['genre'] = genre
            break
    
    # Decade detection
    decades = ['1960s', '1970s', '1980s', '1990s', '2000s', '2010s']
    for decade in decades:
        if decade in query_lower:
            filters['decade'] = decade
            break
    
    # Year detection
    years = re.findall(r'\b(19\d{2}|20\d{2})\b', query)
    if years:
        year = int(years[0])
        filters['decade'] = f"{(year // 10) * 10}s"
    
    # Director detection (simple)
    directors = ['hrishikesh mukherjee', 'rajkumar hirani', 'aamir khan', 'yash chopra']
    for director in directors:
        if director in query_lower:
            filters['director'] = director
            break
    
    return filters

# Retrieve without metadata filter
def retrieve_without_filter(collection, bedrock_client, query, top_k=5):
    start_time = time.time()
    
    # Get query embedding
    query_embedding = get_embeddings(bedrock_client, query)
    
    # Search without filters
    results = collection.query(
        query_embeddings=[query_embedding],
        n_results=top_k
    )
    
    end_time = time.time()
    
    # Format results
    movies = []
    for i in range(len(results['documents'][0])):
        movies.append({
            'document': results['documents'][0][i],
            'metadata': results['metadatas'][0][i],
            'distance': results['distances'][0][i]
        })
    
    return movies, end_time - start_time

# Retrieve with metadata filter
def retrieve_with_filter(collection, bedrock_client, query, filters, top_k=5):
    start_time = time.time()
    
    # Get query embedding
    query_embedding = get_embeddings(bedrock_client, query)
    
    # Create where clause for filtering
    where_clause = {}
    for key, value in filters.items():
        where_clause[key] = value
    
    # Search with filters
    try:
        results = collection.query(
            query_embeddings=[query_embedding],
            n_results=top_k,
            where=where_clause
        )
    except:
        # If filtering fails, fall back to no filter
        results = collection.query(
            query_embeddings=[query_embedding],
            n_results=top_k
        )
    
    end_time = time.time()
    
    # Format results
    movies = []
    for i in range(len(results['documents'][0])):
        movies.append({
            'document': results['documents'][0][i],
            'metadata': results['metadatas'][0][i],
            'distance': results['distances'][0][i]
        })
    
    return movies, end_time - start_time

# Generate answer using Bedrock
def generate_answer(bedrock_client, query, movies):
    if not bedrock_client:
        return "🎬 Based on the retrieved movies, here are some recommendations that match your query!"
    
    # Create context from movies
    context = "\n\n".join([movie['document'] for movie in movies])
    
    prompt = f"""
    Based on the following Bollywood movies information, please answer the user's question.
    
    Question: {query}
    
    Movies Information:
    {context}
    
    Please provide a helpful and informative answer about the movies.
    """
    
    try:
        body = json.dumps({
            "anthropic_version": "bedrock-2023-05-31",
            "max_tokens": 400,
            "messages": [{"role": "user", "content": prompt}]
        })
        
        response = bedrock_client.invoke_model(
            modelId="anthropic.claude-3-haiku-20240307-v1:0",
            body=body
        )
        
        result = json.loads(response['body'].read())
        return result['content'][0]['text']
    except:
        return "🎬 Based on the retrieved movies, here are some great recommendations that match your query!"

# Main app
def main():
    st.title("🎬 Bollywood Movies RAG with Metadata Filtering")
    st.write("Ask questions about Bollywood movies and see how metadata filtering speeds up retrieval!")
    
    # Initialize session state
    if 'collection' not in st.session_state:
        st.session_state.collection = None
    if 'setup_done' not in st.session_state:
        st.session_state.setup_done = False
    
    # Setup section
    if not st.session_state.setup_done:
        st.subheader("🛠️ Setup Movie Database")
        
        if st.button("🚀 Load Bollywood Movies Data"):
            try:
                bedrock_client = connect_to_bedrock()
                collection = setup_movie_database(bedrock_client)
                st.session_state.collection = collection
                st.session_state.bedrock_client = bedrock_client
                st.session_state.setup_done = True
                st.balloons()
            except Exception as e:
                st.error(f"❌ Setup failed: {str(e)}")
    
    else:
        st.success("✅ Movie database is ready!")
        
        # Sample queries
        st.subheader("🔍 Try These Sample Queries")
        sample_queries = [
            "What are some good action movies?",
            "Tell me a few comedy movies from the 1970s",
            "What is the movie Sholay about?",
            "Tell me a few movies directed by Hrishikesh Mukherjee",
            "What are some romantic movies from the 1990s?"
        ]
        
        query_option = st.radio("Choose a query:", ["Custom Query"] + sample_queries)
        
        if query_option == "Custom Query":
            query = st.text_input("Enter your question about Bollywood movies:")
        else:
            query = query_option
            st.write(f"Selected: **{query}**")
        
        if query:
            if st.button("🔍 Search Movies"):
                try:
                    bedrock_client = st.session_state.bedrock_client
                    collection = st.session_state.collection
                    
                    # Detect filters
                    filters = detect_filters(query)
                    
                    st.write("---")
                    
                    # Method 1: Without metadata filter
                    st.subheader("📊 Method 1: Without Metadata Filter")
                    movies_no_filter, time_no_filter = retrieve_without_filter(collection, bedrock_client, query)
                    
                    st.write(f"⏱️ **Time taken: {time_no_filter:.4f} seconds**")
                    st.write("**Retrieved Movies:**")
                    for i, movie in enumerate(movies_no_filter, 1):
                        with st.expander(f"{i}. {movie['metadata']['title']} ({movie['metadata']['year']})"):
                            st.write(f"**Genre:** {movie['metadata']['genre'].title()}")
                            st.write(f"**Director:** {movie['metadata']['director'].title()}")
                            st.write(f"**Distance:** {movie['distance']:.4f}")
                    
                    # Method 2: With metadata filter
                    st.subheader("🎯 Method 2: With Metadata Filter")
                    
                    if filters:
                        st.write(f"**Detected Filters:** {filters}")
                        movies_with_filter, time_with_filter = retrieve_with_filter(collection, bedrock_client, query, filters)
                        
                        st.write(f"⏱️ **Time taken: {time_with_filter:.4f} seconds**")
                        st.write("**Filtered Retrieved Movies:**")
                        for i, movie in enumerate(movies_with_filter, 1):
                            with st.expander(f"{i}. {movie['metadata']['title']} ({movie['metadata']['year']})"):
                                st.write(f"**Genre:** {movie['metadata']['genre'].title()}")
                                st.write(f"**Director:** {movie['metadata']['director'].title()}")
                                st.write(f"**Distance:** {movie['distance']:.4f}")
                        
                        # Performance comparison
                        st.subheader("⚡ Performance Comparison")
                        col1, col2, col3 = st.columns(3)
                        with col1:
                            st.metric("Without Filter", f"{time_no_filter:.4f}s")
                        with col2:
                            st.metric("With Filter", f"{time_with_filter:.4f}s")
                        with col3:
                            speedup = ((time_no_filter - time_with_filter) / time_no_filter) * 100 if time_no_filter > 0 else 0
                            st.metric("Speedup", f"{speedup:.1f}%")
                        
                        # Generate final answer
                        st.subheader("🤖 AI Generated Answer")
                        answer = generate_answer(bedrock_client, query, movies_with_filter)
                        st.success(answer)
                    
                    else:
                        st.write("**No specific filters detected** - using general retrieval")
                        st.write(f"⏱️ **Time taken: {time_no_filter:.4f} seconds**")
                        
                        # Generate answer with no filter results
                        st.subheader("🤖 AI Generated Answer")
                        answer = generate_answer(bedrock_client, query, movies_no_filter)
                        st.success(answer)
                    
                except Exception as e:
                    st.error(f"❌ Search failed: {str(e)}")
        
        # Show movie database
        if st.checkbox("📋 Show All Movies in Database"):
            st.subheader("Movie Database")
            df = pd.DataFrame(SAMPLE_MOVIES)
            st.dataframe(df)
        
        # Reset button
        if st.button("🔄 Reset Database"):
            st.session_state.collection = None
            st.session_state.setup_done = False
            st.rerun()

# Installation and deployment guide
def show_guides():
    col1, col2 = st.columns(2)
    
    with col1:
        with st.expander("📖 Installation Guide"):
            st.markdown("""
            **Step 1: Install Libraries**
            ```bash
            pip install streamlit boto3 chromadb pandas
            ```
            
            **Step 2: Setup AWS**
            ```bash
            aws configure
            ```
            
            **Step 3: Run Locally**
            ```bash
            streamlit run bollywood_rag.py
            ```
            """)
    
    with col2:
        with st.expander("🚀 Deploy to Hugging Face"):
            st.markdown("""
            **Step 1: Create files**
            - `app.py` (this code)
            - `requirements.txt`
            - `README.md`
            
            **Step 2: requirements.txt**
            ```
            streamlit
            boto3
            chromadb
            pandas
            ```
            
            **Step 3: Deploy**
            1. Push to GitHub
            2. Connect to Hugging Face Spaces
            3. Select Streamlit SDK
            4. Add AWS secrets in settings
            """)

# Run the app
if __name__ == "__main__":
    show_guides()
    main()