-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyoutube_stream.py
150 lines (122 loc) Β· 5.5 KB
/
youtube_stream.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
import json
import os
from time import sleep
from threading import Thread
from selenium_driver import driver as ChromeDriver
from code_editor import generate_all_variations
from telebot import TeleBot
config = json.loads(open("./config.json", "r").read())
bot = TeleBot(config['bot_token'])
chat_id = config['chat_id']
def click(driver):
print("======== Start Tapping ========")
for _ in range(int(config['limit'] / config['multitap_level']) + 1):
driver.find_element("xpath", '//*[@id="ex1-layer"]').click()
def try_close_msg(driver):
try:
driver.find_element("xpath", '//*[@id="app"]/div[2]/div[3]/button').click()
except:
pass
sleep(1)
try:
driver.find_element("xpath", '//*[@id="app"]/div[2]/div[1]/div/div').click()
except:
pass
sleep(1)
try:
driver.find_element("xpath", '//*[@id="app"]/div[2]/div[1]/div/div').click()
except:
pass
def get_stream_link(driver):
try:
driver.find_element("xpath", '//*[@id="app"]/div[1]/div[3]/div/div[1]/div[2]/button[1]').click()
link = driver.find_element("xpath", '//*[@id="app"]/div[1]/div[3]/div/div[1]/div[2]/div[1]/div[2]/div[2]/div[1]/a').get_attribute('href')
sleep(1)
driver.find_element("xpath", '//*[@id="app"]/div[1]/div[3]/div/div[1]/div[2]/div[1]/div[1]/button').click()
with open("stream.link", "w") as f:
f.write(link)
sleep(1)
return link
except:
return "Error!"
def try_stream_code(driver, code):
try:
before = driver.find_element("xpath", '//*[@id="app"]/div[1]/div[2]/div[2]/div[1]/div[1]/h1').text
driver.find_element("xpath", '//*[@id="app"]/div[1]/div[3]/div/div[1]/div[1]').click()
sleep(1)
driver.find_element("xpath", '//*[@id="app"]/div[1]/div[3]/div/div[1]/div[2]/div[2]/div[2]/div[2]/input').send_keys(code)
driver.find_element("xpath", '//*[@id="app"]/div[1]/div[3]/div/div[1]/div[2]/button').click()
sleep(12)
btn = driver.find_element("xpath", '//*[@id="app"]/div[1]/div[3]/div/div[1]/div[2]/button')
btn_text = btn.text
try_code_list = True
possible_cases = generate_all_variations(code)
print(possible_cases)
if btn_text == "Claim":
btn.click()
try_code_list = False
sleep(2)
after = driver.find_element("xpath", '//*[@id="app"]/div[1]/div[2]/div[2]/div[1]/div[1]/h1').text
bot.send_photo(chat_id, open("./code.png", "rb"), caption=f'{code}\n\nStream code entered successfully\nbefore apply code => {before}\nafter apply code => {after}')
if try_code_list:
bot.send_photo(chat_id, open("./code.png", "rb"), caption=f'try code list\n\n{str(possible_cases)}')
for c in possible_cases:
if try_code_list:
driver.find_element("xpath", '//*[@id="app"]/div[1]/div[3]/div/div[1]/div[2]/div[2]/div[2]/div[2]/input').clear()
driver.find_element("xpath", '//*[@id="app"]/div[1]/div[3]/div/div[1]/div[2]/div[2]/div[2]/div[2]/input').send_keys(c)
driver.find_element("xpath", '//*[@id="app"]/div[1]/div[3]/div/div[1]/div[2]/button').click()
sleep(12)
btn = driver.find_element("xpath", '//*[@id="app"]/div[1]/div[3]/div/div[1]/div[2]/button')
btn_text = btn.text
if btn_text == "Claim":
btn.click()
try_code_list = False
sleep(2)
after = driver.find_element("xpath", '//*[@id="app"]/div[1]/div[2]/div[2]/div[1]/div[1]/h1').text
bot.send_photo(chat_id, open("./code.png", "rb"), caption=f'{code}\n\nStream code entered successfully ==> {c}\nbefore apply code => {before}\nafter apply code => {after}')
if try_code_list:
bot.send_photo(chat_id, open("./code.png", "rb"), caption=f'try code list Unsuccessful\n\n{str(possible_cases)}')
try:
driver.find_element("xpath", '//*[@id="app"]/div[1]/div[3]/div/div[1]/div[2]/div[1]/div/div').click()
except:
pass
with open("./code.txt", "w") as f:
f.write("0")
print("stream code entered...")
except:
print("stream code apply error")
def main():
driver = ChromeDriver()
driver.get(config['url'])
sleep(5)
try_close_msg(driver)
print(f'Stream Youtube Link ===> ', get_stream_link(driver))
refresh_time = 0
while True:
try:
print("Check Energy ...")
energy = driver.find_element("xpath", '//*[@id="app"]/div[1]/div[3]/div/div[1]/div[1]/h4').text
energy = energy.split("/")[0]
energy = int(energy)
print("energy: ", energy)
if energy > config['limit'] - 10:
click(driver)
code = open("./code.txt", "r").read()
if not code == "0":
try_stream_code(driver, code)
sleep(10)
refresh_time = refresh_time + 1
if refresh_time > 60:
print("Refresh Page, Waiting ...")
driver.get(config['url'])
refresh_time = 0
sleep(15)
try_close_msg(driver)
except:
driver.get(config['url'])
sleep(15)
try_close_msg(driver)
print("Check Energy or Tapping Proccess Error !!")
driver.quit()
Thread(target=main).start()
Thread(target=os.system("python3 youtube_stream.py"))