7
7
import chromedriver_autoinstaller
8
8
9
9
10
- def config ():
11
- if not os .path .isfile ('config.json' ):
12
- def hdls (headless ):
13
- if headless == "y" :
14
- return True
15
- if headless == "n" :
16
- return False
17
-
18
- headless = input (
19
- "Would you like to run the bot in headless mode? (y/n): " )
20
-
21
- def sdop (mute ):
22
- if mute == "y" :
23
- return True
24
- if mute == "n" :
25
- return False
26
-
27
- sound = input (
28
- "Would you like to mute the videos while they are playing? (y/n): " )
29
- configs = {
30
- "Headless" : str (hdls (headless )),
31
- "Mute" : str (sdop (sound ))
32
- }
33
- json_file = json .dumps (configs )
34
- with open ("config.json" , "w" ) as jsonfile :
35
- jsonfile .write (json_file )
36
- else :
37
- config_options = input (
38
- "Would you like to use the previous settings for Headless mode and Sound? (y/n): " )
39
- if config_options == "y" :
40
- pass
41
- else :
10
+ def main ():
11
+ def config ():
12
+ if not os .path .isfile ('config.json' ):
42
13
def hdls (headless ):
43
14
if headless == "y" :
44
15
return True
@@ -63,70 +34,100 @@ def sdop(mute):
63
34
json_file = json .dumps (configs )
64
35
with open ("config.json" , "w" ) as jsonfile :
65
36
jsonfile .write (json_file )
66
-
67
-
68
- config ()
69
-
70
- chromedriver_autoinstaller .install ()
71
- viewcount = 0
72
- views = input ("how many views would you like: " )
73
- number_of_drivers = int (input ("Enter the number of tabs you want open: " ))
74
- time_to_refresh = int (input ("Choose your watch time (seconds): " ))
75
- url = input ("Enter Video URL: " )
76
- drivers = []
77
- sites = ['https://search.yahoo.com/' , 'https://duckduckgo.com/' , 'https://www.google.com/' ,
78
- 'https://www.bing.com/' , 'https://t.co/' , 'https://youtube.com' ]
79
-
80
- wsviews = open ("Bot Status/views.txt" , 'w' )
81
- wsurl = open ("Bot Status/url.txt" , 'w' )
82
- wsviews .write (views )
83
- wsviews .close ()
84
- wsurl .write (url )
85
- wsurl .close ()
86
-
87
- with open ("config.json" , "r" ) as jsonfile :
88
- json_options = json .load (jsonfile )
89
- jsonfile .close ()
90
-
91
-
92
- def wsviewcount ():
93
- wsvc = open ("Bot Status/viewcount.txt" , 'w' )
94
- wsvc .write (str (viewcount ))
95
- wsvc .close ()
96
-
97
-
98
- def play_video (drivers ):
99
- ActionChains (drivers [i ]) \
100
- .send_keys ("k" ) \
101
- .perform ()
102
-
103
-
104
- for i in range (number_of_drivers ):
105
- options = webdriver .ChromeOptions ()
106
- if json_options ["Headless" ] == "True" :
107
- options .add_argument ("--headless" )
108
- if json_options ["Mute" ] == "False" :
109
- pass
110
- else :
111
- options .add_argument ("--mute-audio" )
112
- options .add_experimental_option ("excludeSwitches" , ["enable-logging" ])
113
- drivers .append (webdriver .Chrome (options = options ,
114
- executable_path = r"chromedriver" ))
115
- drivers [i ].get (random .choice (sites ))
116
- drivers [i ].get (url )
117
- play_video (drivers )
118
-
119
- while True :
120
- time .sleep (time_to_refresh )
121
- viewcount += number_of_drivers
122
- wsviewcount ()
123
-
124
- print ("view count = " + str (viewcount ))
125
- if int (views ) <= int (viewcount ):
126
- drivers [i ].quit ()
127
- print ("the listed amount has been viewed" )
128
- os .system ("pause" )
129
- exit ()
130
- elif int (views ) > int (viewcount ):
131
- for i in range (number_of_drivers ):
132
- drivers [i ].refresh ()
37
+ else :
38
+ config_options = input (
39
+ "Would you like to use the previous settings for Headless mode and Sound? (y/n): " )
40
+ if config_options == "y" :
41
+ pass
42
+ else :
43
+ def hdls (headless ):
44
+ if headless == "y" :
45
+ return True
46
+ if headless == "n" :
47
+ return False
48
+
49
+ headless = input (
50
+ "Would you like to run the bot in headless mode? (y/n): " )
51
+
52
+ def sdop (mute ):
53
+ if mute == "y" :
54
+ return True
55
+ if mute == "n" :
56
+ return False
57
+
58
+ sound = input (
59
+ "Would you like to mute the videos while they are playing? (y/n): " )
60
+ configs = {
61
+ "Headless" : str (hdls (headless )),
62
+ "Mute" : str (sdop (sound ))
63
+ }
64
+ json_file = json .dumps (configs )
65
+ with open ("config.json" , "w" ) as jsonfile :
66
+ jsonfile .write (json_file )
67
+
68
+ config ()
69
+
70
+ chromedriver_autoinstaller .install ()
71
+ viewcount = 0
72
+ views = input ("how many views would you like: " )
73
+ number_of_drivers = int (input ("Enter the number of tabs you want open: " ))
74
+ time_to_refresh = int (input ("Choose your watch time (seconds): " ))
75
+ url = input ("Enter Video URL: " )
76
+ drivers = []
77
+ sites = ['https://search.yahoo.com/' , 'https://duckduckgo.com/' , 'https://www.google.com/' ,
78
+ 'https://www.bing.com/' , 'https://t.co/' , 'https://youtube.com' ]
79
+
80
+ wsviews = open ("Bot Status/views.txt" , 'w' )
81
+ wsurl = open ("Bot Status/url.txt" , 'w' )
82
+ wsviews .write (views )
83
+ wsviews .close ()
84
+ wsurl .write (url )
85
+ wsurl .close ()
86
+
87
+ with open ("config.json" , "r" ) as jsonfile :
88
+ json_options = json .load (jsonfile )
89
+ jsonfile .close ()
90
+
91
+ def wsviewcount ():
92
+ wsvc = open ("Bot Status/viewcount.txt" , 'w' )
93
+ wsvc .write (str (viewcount ))
94
+ wsvc .close ()
95
+
96
+ def play_video (drivers ):
97
+ ActionChains (drivers [i ]) \
98
+ .send_keys ("k" ) \
99
+ .perform ()
100
+
101
+ for i in range (number_of_drivers ):
102
+ options = webdriver .ChromeOptions ()
103
+ if json_options ["Headless" ] == "True" :
104
+ options .add_argument ("--headless" )
105
+ if json_options ["Mute" ] == "False" :
106
+ pass
107
+ else :
108
+ options .add_argument ("--mute-audio" )
109
+ options .add_experimental_option ("excludeSwitches" , ["enable-logging" ])
110
+ drivers .append (webdriver .Chrome (options = options ,
111
+ executable_path = r"chromedriver" ))
112
+ drivers [i ].get (random .choice (sites ))
113
+ drivers [i ].get (url )
114
+ play_video (drivers )
115
+
116
+ while True :
117
+ time .sleep (time_to_refresh )
118
+ viewcount += number_of_drivers
119
+ wsviewcount ()
120
+
121
+ print ("view count = " + str (viewcount ))
122
+ if int (views ) <= int (viewcount ):
123
+ drivers [i ].quit ()
124
+ print ("the listed amount has been viewed" )
125
+ os .system ("pause" )
126
+ exit ()
127
+ elif int (views ) > int (viewcount ):
128
+ for i in range (number_of_drivers ):
129
+ drivers [i ].refresh ()
130
+
131
+
132
+ if __name__ == "__main__" :
133
+ main ()
0 commit comments