-
Notifications
You must be signed in to change notification settings - Fork 36
/
main.py
227 lines (172 loc) · 10.3 KB
/
main.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
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
import requests
import warnings
import random
from selenium.webdriver.common.action_chains import ActionChains
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from colorama import Fore
from pystyle import Center, Colors, Colorate
import os
import time
warnings.filterwarnings("ignore", category=DeprecationWarning)
def check_for_updates():
try:
r = requests.get("https://raw.githubusercontent.com/Kichi779/Twitch-Viewer-Bot/main/version.txt")
remote_version = r.content.decode('utf-8').strip()
local_version = open('version.txt', 'r').read().strip()
if remote_version != local_version:
print("A new version is available. Please download the latest version from GitHub.")
time.sleep(3)
return False
return True
except:
return True
def save_settings(twitch_username, set_160p):
with open('settings.txt', 'w') as file:
file.write(f"Twitch Username: {twitch_username}\n")
file.write(f"Set 160p: {set_160p}\n")
def load_settings():
try:
with open('settings.txt', 'r') as file:
lines = file.readlines()
if len(lines) >= 2:
twitch_username = lines[0].split(': ')[1].strip()
set_160p = lines[1].split(': ')[1].strip()
return twitch_username, set_160p
except:
pass
return None, None
def set_stream_quality(driver, quality):
if quality == "yes":
element_xpath = "//div[@data-a-target='player-overlay-click-handler']"
element = driver.find_element(By.XPATH, element_xpath)
actions = ActionChains(driver)
actions.move_to_element(element).perform()
settings_button = driver.find_element(By.XPATH, "//button[@aria-label='Settings']")
settings_button.click()
wait = WebDriverWait(driver, 10)
quality_option = wait.until(EC.element_to_be_clickable((By.XPATH, "//div[text()='Quality']")))
quality_option.click()
time.sleep(15)
quality_levels = wait.until(EC.presence_of_all_elements_located((By.XPATH, "//div[contains(@class, 'video-quality-option')]")))
target_quality = "160p"
for level in quality_levels:
if target_quality in level.text:
level.click()
break
def main():
if not check_for_updates():
return
twitch_username, set_160p = load_settings()
def print_announcement():
try:
r = requests.get("https://raw.githubusercontent.com/Kichi779/Twitch-Viewer-Bot/main/announcement.txt", headers={"Cache-Control": "no-cache"})
announcement = r.content.decode('utf-8').strip()
return announcement
except:
print("Could not retrieve announcement from GitHub.\n")
def main():
if not check_for_updates():
return
print_announcement()
twitch_username, set_160p = load_settings()
os.system(f"title Kichi779 - Twitch Viewer Bot @kichi#0779 ")
print(Colorate.Vertical(Colors.green_to_cyan, Center.XCenter("""
▄█ ▄█▄ ▄█ ▄████████ ▄█ █▄ ▄█
███ ▄███▀ ███ ███ ███ ███ ███ ███
███▐██▀ ███▌ ███ █▀ ███ ███ ███▌
▄█████▀ ███▌ ███ ▄███▄▄▄▄███▄▄ ███▌
▀▀█████▄ ███▌ ███ ▀▀███▀▀▀▀███▀ ███▌
███▐██▄ ███ ███ █▄ ███ ███ ███
███ ▀███▄ ███ ███ ███ ███ ███ ███
███ ▀█▀ █▀ ████████▀ ███ █▀ █▀
▀
Improvements can be made to the code. If you're getting an error, visit my discord.
Discord discord.gg/fesaScZqpn
Github github.com/kichi779 """)))
announcement = print_announcement()
print("")
print(Colors.red, Center.XCenter("ANNOUNCEMENT"))
print(Colors.yellow, Center.XCenter(f"{announcement}"))
print("")
print("")
proxy_servers = ['https://www.blockaway.net', 'https://www.croxyproxy.com', 'https://www.croxyproxy.rocks', 'https://www.croxy.network', 'https://www.croxy.org', 'https://www.youtubeunblocked.live', 'https://www.croxyproxy.net']
def selectRandom(proxy_servers):
return random.choice(proxy_servers)
proxy_url = selectRandom(proxy_servers)
print(Colors.red, "Proxy servers are randomly selected every time")
if twitch_username is None or set_160p is None:
twitch_username = input(Colorate.Vertical(Colors.green_to_blue, "Enter your channel name (e.g Kichi779): "))
set_160p = input(Colorate.Vertical(Colors.purple_to_red,"Do you want to set the stream quality to 160p? (yes/no): "))
save_settings(twitch_username, set_160p)
else:
use_settings = input(Colorate.Vertical(Colors.green_to_blue, "Do you want to use your saved settings? (yes/no): "))
if use_settings.lower() == "no":
twitch_username = input(Colorate.Vertical(Colors.green_to_blue, "Enter your channel name (e.g Kichi779): "))
set_160p = input(Colorate.Vertical(Colors.purple_to_red,"Do you want to set the stream quality to 160p? (yes/no): "))
save_settings(twitch_username, set_160p)
proxy_count = int(input(Colorate.Vertical(Colors.cyan_to_blue, "How many proxy sites do you want to open? (Viewer to send)")))
os.system("cls")
print(Colorate.Vertical(Colors.green_to_cyan, Center.XCenter("""
▄█ ▄█▄ ▄█ ▄████████ ▄█ █▄ ▄█
███ ▄███▀ ███ ███ ███ ███ ███ ███
███▐██▀ ███▌ ███ █▀ ███ ███ ███▌
▄█████▀ ███▌ ███ ▄███▄▄▄▄███▄▄ ███▌
▀▀█████▄ ███▌ ███ ▀▀███▀▀▀▀███▀ ███▌
███▐██▄ ███ ███ █▄ ███ ███ ███
███ ▀███▄ ███ ███ ███ ███ ███ ███
███ ▀█▀ █▀ ████████▀ ███ █▀ █▀
▀
Improvements can be made to the code. If you're getting an error, visit my discord.
Discord discord.gg/UkSJP8RUxc
Github github.com/kichi779 """)))
print('')
print('')
print(Colors.red, Center.XCenter("Viewers Send. Please don't hurry. If the viewers does not arrive, turn it off and on and do the same operations"))
chrome_path = 'C:\Program Files\Google\Chrome\Application\chrome.exe'
driver_path = 'chromedriver.exe'
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option('excludeSwitches', ['enable-logging'])
chrome_options.add_argument('--disable-logging')
chrome_options.add_argument("--lang=en")
chrome_options.add_argument('--log-level=3')
chrome_options.add_argument('--disable-extensions')
chrome_options.add_argument("--mute-audio")
chrome_options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome(options=chrome_options)
driver.get(proxy_url)
for i in range(proxy_count):
random_proxy_url = selectRandom(proxy_servers) # Select a random proxy server for this tab
driver.execute_script("window.open('" + random_proxy_url + "')")
driver.switch_to.window(driver.window_handles[-1])
driver.get(random_proxy_url)
text_box = driver.find_element(By.ID, 'url')
text_box.send_keys(f'www.twitch.tv/{twitch_username}')
text_box.send_keys(Keys.RETURN)
time.sleep(10)
set_stream_quality(driver, set_160p)
input(Colorate.Vertical(Colors.red_to_blue, "Viewers have all been sent. You can press enter to withdraw the views and the program will close."))
driver.quit()
if __name__ == '__main__':
main()
# ==========================================
# Copyright 2023 Kichi779
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# ==========================================