-
Notifications
You must be signed in to change notification settings - Fork 5
/
client.py
188 lines (174 loc) · 5.9 KB
/
client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
import requests, json, time
from tmdbv3api import TMDb, Movie
tmdb = TMDb()
tmdb.api_key = '<YOUR API KEY>'
type = input("What do you want to search for? Movie or Show: (m/s) (leave blank for None): ")
if type.lower() == "m":
type = "movie"
elif type.lower() == "s":
type = "show"
else:
type = None
name = input("Enter name: ")
movie = Movie()
search = movie.search(name)
di = {}
for i, res in enumerate(search):
di[i+1] = res
print(f"{i+1}\t{res}")
if len(di.keys()) == 0:
raise Exception("No movies found..")
num = input("\nSelect the movie number: ")
try:
name = di[int(num)]
except KeyError:
raise Exception("Please select valid number from above.")
url = f'http://localhost:8000/api/data/?name={name}&type={type}'
curr = time.time()
response = requests.get(url)
result = response.text
result = json.loads(result)
hotstar_movies, hotstar_series = [], []
airtel_movies, airtel_series = [], []
eros_movies, eros_series = [], []
idea_movies, idea_series = [], []
voda_movies, voda_series = [], []
zee5_movies, zee5_series = [], []
jio_movies, jio_series = [], []
mx_movies, mx_series = [], []
alt_balaji_movies, alt_balaji_series = [], []
if not result:
print("No result found")
for res in result:
if res['provider'] is None:
print("No result found")
break
if res['movie']:
if res['provider'] == "hotstar":
hotstar_movies.append(res)
elif res['provider'] == "airtel":
airtel_movies.append(res)
elif res['provider'] == "eros_now":
eros_movies.append(res)
elif res['provider'] == "idea":
idea_movies.append(res)
elif res['provider'] == "vodafone":
voda_movies.append(res)
elif res['provider'] == "zee5":
zee5_movies.append(res)
elif res['provider'] == "jio_cinema":
jio_movies.append(res)
elif res['provider'] == "mx_player":
mx_movies.append(res)
elif res['provider'] == "alt_balaji":
alt_balaji_movies.append(res)
elif not res['movie']:
if res['provider'] == "hotstar":
hotstar_series.append(res)
elif res['provider'] == "airtel":
airtel_series.append(res)
elif res['provider'] == "eros_now":
eros_series.append(res)
elif res['provider'] == "idea":
idea_series.append(res)
elif res['provider'] == "vodafone":
voda_series.append(res)
elif res['provider'] == "zee5":
zee5_series.append(res)
elif res['provider'] == "jio_cinema":
jio_series.append(res)
elif res['provider'] == "mx_player":
mx_series.append(res)
elif res['provider'] == "alt_balaji":
alt_balaji_series.append(res)
if hotstar_movies or hotstar_series:
print("\nHotstar\n")
if hotstar_movies:
print("Movies\n")
for i, val in enumerate(hotstar_movies):
print(val['name'] + "\t" + val['link'])
if hotstar_series:
print("\nTV Shows\n")
for i, val in enumerate(hotstar_series):
print(val['name'] + "\t" + val['link'])
if airtel_movies or airtel_series:
print("\nAirtel\n")
if airtel_movies:
print("Movies\n")
for i, val in enumerate(airtel_movies):
print(val['name'] + "\t" + val['link'])
if airtel_series:
print("\nTV Shows\n")
for i, val in enumerate(airtel_series):
print(val['name'] + "\t" + val['link'])
if eros_movies or eros_series:
print("\nEros Now\n")
if eros_movies:
print("Movies\n")
for i, val in enumerate(eros_movies):
print(val['name'] + "\t" + val['link'])
if eros_series:
print("\nTV Shows\n")
for i, val in enumerate(eros_series):
print(val['name'] + "\t" + val['link'])
if idea_movies or idea_series:
print("\nIdea Movies & TV\n")
if idea_movies:
print("Movies\n")
for i, val in enumerate(idea_movies):
print(val['name'] + "\t" + val['link'])
if idea_series:
print("\nTV Shows\n")
for i, val in enumerate(idea_series):
print(val['name'] + "\t" + val['link'])
if voda_movies or voda_series:
print("\nVodafone Play\n")
if voda_movies:
print("Movies\n")
for i, val in enumerate(voda_movies):
print(val['name'] + "\t" + val['link'])
if voda_series:
print("\nTV Shows\n")
for i, val in enumerate(voda_series):
print(val['name'] + "\t" + val['link'])
if zee5_movies or zee5_series:
print("\nZee5\n")
if zee5_movies:
print("Movies\n")
for i, val in enumerate(zee5_movies):
print(val['name'] + "\t" + val['link'])
if zee5_series:
print("\nTV Shows\n")
for i, val in enumerate(zee5_series):
print(val['name'] + "\t" + val['link'])
if jio_movies or jio_series:
print("\nJio Cinema\n")
if jio_movies:
print("Movies\n")
for i, val in enumerate(jio_movies):
print(val['name'] + "\t" + val['link'])
if jio_series:
print("\nTV Shows\n")
for i, val in enumerate(jio_series):
print(val['name'] + "\t" + val['link'])
if mx_movies or mx_series:
print("\nMX Player\n")
if mx_movies:
print("Movies\n")
for i, val in enumerate(mx_movies):
print(val['name'] + "\t" + val['link'])
if mx_series:
print("\nTV Shows\n")
for i, val in enumerate(mx_series):
print(val['name'] + "\t" + val['link'])
if alt_balaji_movies or alt_balaji_series:
print("\nAlt Balaji\n")
if alt_balaji_movies:
print("Movies\n")
for i, val in enumerate(alt_balaji_movies):
print(val['name'] + "\t" + val['link'])
if alt_balaji_series:
print("\nTV Shows\n")
for i, val in enumerate(alt_balaji_series):
print(val['name'] + "\t" + val['link'])
print(time.time()-curr)