1
+ from kivy .app import App
2
+ from kivy .uix .button import Button
3
+ from kivy .uix .textinput import TextInput
4
+ from kivy .uix .label import Label
5
+ from kivy .uix .boxlayout import BoxLayout
6
+ from kivy .uix .gridlayout import GridLayout
7
+ from kivy .lang import Builder
8
+ from kivy .uix .popup import Popup
9
+ from kivy .uix .image import AsyncImage
10
+
11
+ import requests
12
+ from bs4 import BeautifulSoup
13
+
14
+ Builder .load_string (
15
+ '''
16
+ <PopupScreen>:
17
+ orientation: 'vertical'
18
+ Label:
19
+ text: "Enter Your movie name buddy"
20
+ TextInput:
21
+ id: name
22
+ font_size: 40
23
+ multiline: False
24
+ Button:
25
+ text: "show details"
26
+ on_press: root.detail(name.text)
27
+
28
+ ''' )
29
+ global writer
30
+ writer = "Writers:"
31
+ global actor
32
+ actor = "Actors:"
33
+ global director
34
+ director = "Directors:"
35
+ class PopupScreen (BoxLayout ):
36
+ def error (self ):
37
+ popup = Popup (title = "ERROR" ,content = Label (text = "Bro, Check your movie name" ),size_hint = (0.8 ,0.8 ))
38
+ popup .open ()
39
+
40
+ def Pop (self ,movie ,imdb ,actor ,director ,writer ,url ):
41
+ wid1 = GridLayout (cols = 2 ,rows = 1 )
42
+ lb = AsyncImage (source = url )
43
+ wid1 .add_widget (lb )
44
+ wid2 = GridLayout (rows = 4 )
45
+ lb = Label (text = imdb )
46
+ wid2 .add_widget (lb )
47
+
48
+ lb = Label (text = actor )
49
+ wid2 .add_widget (lb )
50
+ lb = Label (text = director )
51
+ wid2 .add_widget (lb )
52
+ lb = Label (text = writer )
53
+ wid2 .add_widget (lb )
54
+
55
+ wid1 .add_widget (wid2 )
56
+ popup = Popup (title = movie ,content = wid1 ,size_hint = (0.8 ,0.8 ))
57
+ popup .open ()
58
+
59
+ def detail (self , title ):
60
+
61
+ global writer
62
+ writer = "Writers:"
63
+ global actor
64
+ actor = "Actors:"
65
+ global director
66
+ director = "Directors:"
67
+
68
+ s = "+" .join (title .split ())
69
+
70
+
71
+ f_url = 'http://www.imdb.com/find?q='
72
+ url = f_url + s + '&s=all'
73
+ try :
74
+ var = requests .get (url )
75
+ soup = BeautifulSoup (var .content )
76
+
77
+ x = soup .find ("td" , {"class" : "result_text" })
78
+ m = x .find ("a" )['href' ]
79
+
80
+ new_url = 'http://www.imdb.com' + m
81
+ content = requests .get (new_url )
82
+ soup = BeautifulSoup (content .content )
83
+
84
+ img = soup .find ("div" , {"class" :"poster" })
85
+ url = img .findChildren ()[1 ]['src' ]
86
+
87
+ x = soup .find ("div" , {"class" : "title_wrapper" })
88
+
89
+ c = x .findChildren ()[0 ]
90
+
91
+ movie = c .text
92
+
93
+ c = soup .find ("div" , {"class" :"ratingValue" })
94
+
95
+ imdb = c .text
96
+
97
+
98
+
99
+ for tag in soup .find_all ("span" , {"itemprop" :"director" }):
100
+
101
+
102
+ director += tag .text
103
+
104
+
105
+ for tag in soup .find_all ("span" , {"itemprop" :"creator" }):
106
+
107
+ writer += tag .text
108
+
109
+
110
+
111
+ for tag in soup .find_all ("span" , {"itemprop" :"actors" }):
112
+
113
+ actor += tag .text
114
+
115
+
116
+
117
+ self .Pop (movie ,imdb ,actor ,director ,writer ,url )
118
+
119
+ except Exception :
120
+
121
+ self .error ()
122
+
123
+
124
+ class MovieApp (App ):
125
+ def build (self ):
126
+ return PopupScreen ()
127
+
128
+ MovieApp ().run ()
0 commit comments