-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBot-CLI.py
142 lines (123 loc) · 4.54 KB
/
Bot-CLI.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
import time
import random
import requests
from selenium import webdriver
from selenium.webdriver.common.by import By
import chromedriver_autoinstaller
def main():
def config():
def hdls(headless):
if headless == "y":
return 1
if headless == "n":
return 0
else:
raise Exception("Only y or n is allowed")
headless = input("Would you like to run the bot in headless mode? (y/n): ")
def sdop(mute):
if mute == "y":
return 1
if mute == "n":
return 0
else:
raise Exception("Only y or n is allowed")
sound = input(
"Would you like to mute the videos while they are playing? (y/n): "
)
def strm(stream):
if stream == "y":
return 1
if stream == "n":
return 0
else:
raise Exception("Only y or n is allowed")
stream_mode = input(
"Would you like to enable stream mode for watching streams? (y/n): "
)
configs = {
"Headless": hdls(headless),
"Mute": sdop(sound),
"Stream": strm(stream_mode),
}
return configs
def update():
ghrapi = requests.get(
"https://api.github.com/repos/sryu1/YouTube_View_Bot/releases/latest"
)
current_version = "v1.3.0"
latest_version = str(ghrapi.json()["name"])
if current_version < latest_version:
print(
f"A new update ({latest_version}) has been released!\n"
f"Get the release at https://github.com/sryu1/YouTube_View_Bot/releases/tag/{latest_version}"
)
update()
configs = config()
chromedriver_autoinstaller.install()
drivers = []
sites = [
"https://search.yahoo.com/",
"https://duckduckgo.com/",
"https://www.google.com/",
"https://www.bing.com/",
"https://t.co/",
"https://youtube.com/",
"https://www.ecosia.org/",
"https://www.reddit.com/",
"https://www.twitch.tv/",
"https://www.instagram.com/",
"https://www.tiktok.com/",
"https://search.brave.com",
]
def play_video(drivers):
drivers[i].find_element(By.CLASS_NAME, "ytp-large-play-button").click()
if configs["Stream"] != 1:
viewcount = 0
views = input("how many views would you like: ")
number_of_drivers = int(input("Enter the number of tabs you want open: "))
time_to_refresh = int(input("Choose your watch time (seconds): "))
url = input("Enter Video URL: ")
for i in range(number_of_drivers):
options = webdriver.ChromeOptions()
if configs["Headless"] == 1:
options.add_argument("--headless")
if configs["Mute"] == 1:
options.add_argument("--mute-audio")
options.add_experimental_option("excludeSwitches", ["enable-logging"])
drivers.append(
webdriver.Chrome(options=options, executable_path=r"chromedriver")
)
drivers[i].get(random.choice(sites))
drivers[i].get(url)
play_video(drivers)
while True:
time.sleep(time_to_refresh)
viewcount += number_of_drivers
print("view count = " + str(viewcount))
if int(views) <= int(viewcount):
drivers[i].quit()
input("The listed amount has been viewed \nPress Enter to exit . . .")
exit()
elif int(views) > int(viewcount):
for i in range(number_of_drivers):
drivers[i].refresh()
elif configs["Stream"]:
number_of_drivers = int(
input("Enter the number of bots you would like watching the stream: ")
)
url = input("Enter Video URL: ")
for i in range(number_of_drivers):
options = webdriver.ChromeOptions()
if configs["Headless"] == 1:
options.add_argument("--headless")
if configs["Mute"] == 1:
options.add_argument("--mute-audio")
options.add_experimental_option("excludeSwitches", ["enable-logging"])
drivers.append(
webdriver.Chrome(options=options, executable_path=r"chromedriver")
)
drivers[i].get(random.choice(sites))
drivers[i].get(url)
play_video(drivers)
if __name__ == "__main__":
main()