-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBMS.py
More file actions
150 lines (92 loc) · 5.51 KB
/
BMS.py
File metadata and controls
150 lines (92 loc) · 5.51 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
import time
from selenium import webdriver
from settings import API_KEY, URL, movie_url, chatId1, chatId2
from selenium. common. exceptions import NoSuchElementException
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from telebot import types, apihelper
import telebot
API_KEY = API_KEY
bot = telebot.TeleBot(API_KEY)
apihelper.SESSION_TIME_TO_LIVE = 60 * 5
capabilities = {
"browserName": "chrome",
"version": "80.0",
"enableVNC": True,
"enableVideo": False
}
driver = webdriver.Remote(
command_executor= URL,
desired_capabilities=capabilities)
def startbms():
theatre_list = ['Bhramaramba 70MM A/C Dts: Kukatpally', 'Mallikarjuna 70mm A/C DTS: Kukatpally', 'Sandhya 35mm: RTC X Road', 'Sandhya 70MM 4K Dolby Atmos: RTC X Roads', 'Sudarshan 35MM 4k Laser & Dolby Atmos: RTC X Roads', 'Devi 70MM 4K Laser & Dolby Atmos: RTC X Roads']
dict_theatre = {}
for theatre in theatre_list:
dict_theatre[theatre] = 0
url = movie_url
url_string = url.split('/')
movie_name = url_string[4].split('-')
movie_name.remove('hyderabad')
driver.get(url)
i = 1
extracted = 0
theatreDone = False
isDone = False
while not isDone:
time.sleep(1)
while not theatreDone:
try:
theatre_name = driver.find_element(By.XPATH, '//*[@id="venuelist"]/li[' + str(i) + ']/div[1]/div[2]/div/div[1]/a').text
for theatre in theatre_list:
if theatre == theatre_name:
dict_theatre[theatre] = i
extracted += 1
i += 1
if extracted == 6:
theatreDone = True
except NoSuchElementException:
i = 1
theatreDone = True
for theatre in theatre_list:
j = 1
if dict_theatre[theatre] > 0:
theatre_name = driver.find_element(By.XPATH, '//*[@id="venuelist"]/li[' + str(dict_theatre[theatre]) + ']/div[1]/div[2]/div/div[1]/a').text
if theatre_name == theatre:
while j < 9:
try:
driver.find_element(By.XPATH, '//*[@id="wzrk-cancel"]').click()
except NoSuchElementException:
try:
show_button = driver.find_element(By.XPATH, '//*[@id="venuelist"]/li[' + str(dict_theatre[theatre]) + ']/div[2]/div[2]/div[' + str(j) + ']/a')
driver.execute_script("arguments[0].click();", show_button)
show_time = driver.find_element(By.XPATH, '//*[@id="venuelist"]/li[' + str(dict_theatre[theatre]) + ']/div[2]/div[2]/div[' + str(j) + ']/a').text
j += 1
time.sleep(0.5)
popup_button = driver.find_element(By.XPATH, '//*[@id="btnPopupCancel"]')
select_seat = driver.find_element(By.XPATH, '//*[@id="proceed-Qty"]')
back_button = driver.find_element(By.XPATH, '//*[@id="disback"]')
if popup_button.is_displayed():
driver.execute_script("arguments[0].click();", popup_button)
bot.send_message(chatId1, "For " + ' '.join(movie_name).upper() + " on " + url_string[6] + "\nTickets available at " + theatre_name + "\nShow time: " + show_time)
bot.send_message(chatId2, "For " + ' '.join(movie_name).upper() + " on " + url_string[6] + "\nTickets available at " + theatre_name + "\nShow time: " + show_time)
elif select_seat.is_displayed():
driver.execute_script("arguments[0].click();", select_seat)
back_button = driver.find_element(By.XPATH, '//*[@id="disback"]')
driver.execute_script("arguments[0].click();", back_button)
bot.send_message(chatId1, "For " + ' '.join(movie_name).upper() + " on " + url_string[6] + "\nTickets available at " + theatre_name + "\nShow time: " + show_time)
bot.send_message(chatId2, "For " + ' '.join(movie_name).upper() + " on " + url_string[6] + "\nTickets available at " + theatre_name + "\nShow time: " + show_time)
elif back_button.is_displayed():
driver.execute_script("arguments[0].click();", back_button)
bot.send_message(chatId1, "For " + ' '.join(movie_name).upper() + " on " + url_string[6] + "\nTickets available at " + theatre_name + "\nShow time: " + show_time)
bot.send_message(chatId2, "For " + ' '.join(movie_name).upper() + " on " + url_string[6] + "\nTickets available at " + theatre_name + "\nShow time: " + show_time)
except NoSuchElementException:
j = 9
time.sleep(1)
else:
theatreDone = False
else:
theatreDone = False
time.sleep(20)
driver.refresh()
startbms()
bot.polling(none_stop=False, interval=0, timeout=20)