-
Notifications
You must be signed in to change notification settings - Fork 0
/
bitchute-uploader.py
executable file
·210 lines (190 loc) · 8.14 KB
/
bitchute-uploader.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
#!/usr/bin/python
import argparse
import sys
import pytest
import time
import json
import os.path
import shutil
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.chrome.options import Options
parse = argparse.ArgumentParser()
parse.add_argument("-n", "--name", required=True, type=str, help="Set Video title for the Video at Bitchute!")
parse.add_argument("-f", "--file", required=True, type=str, help="Set the upload Video for Bitchute!")
parse.add_argument("-t", "--thumbnail", required=True, type=str, help="Set the Thumbnail image of the Video!")
parse.add_argument("-e", "--email", required=True, type=str, help="Set the login E-Mail Address for Bitchute!")
parse.add_argument("-p", "--password", required=True, type=str, help="Set the login Passwort for Bitchute!")
parse.add_argument("-v", "--visibly_advice", required=True, type=str, help="Set the Video content view advice for shocking videos! [10, 40 or 70]")
args = parse.parse_args()
file_backup_folder = os.path.dirname(args.file) + "/"+ "finished_transfer_movies" + "/" + os.path.basename(args.file)
class TestBitchuteUploadClass(object):
def __init__(self, name, file, thumb, email, password, visibly_advice):
self.name = name
self.file = file
self.thumb = thumb
self.email = email
self.password = password
self.visibly_advice = visibly_advice
def setup_method(self, method):
self.driver = webdriver.Chrome()
self.vars = {}
def teardown_method(self, method):
self.driver.quit()
def test_bitchuteUploadClass(self):
while True:
try:
self.driver.get("https://www.bitchute.com/")
print(" ** Connection to bitchute.com succeeds!")
print(" ** Upload Video: " + self.name + "!")
except:
time.sleep(2.0)
print(" ** Network connection failure!")
time.sleep(4.0)
print(" ** Retry connecting to bitchute.com!")
continue
else:
break
while True:
try:
#self.driver.minimize_window()
self.driver.set_window_size(880, 640)
self.driver.set_window_position(90, 90)
except:
continue
else:
break
## Login process
while True:
try:
self.driver.find_element(By.LINK_TEXT, "Login").click()
WebDriverWait(self.driver, 30).until(expected_conditions.visibility_of_element_located((By.XPATH, "//input[@id=\'id_username\']")))
self.driver.find_element(By.XPATH, "//input[@id=\'id_username\']").click()
self.driver.find_element(By.CSS_SELECTOR, "#id_username").send_keys(self.email)
self.driver.find_element(By.XPATH, "//input[@id=\'id_password\']").click()
self.driver.find_element(By.CSS_SELECTOR, "#id_password").send_keys(self.password)
#self.driver.set_timeout(60) # seconds
self.driver.find_element(By.ID, "auth_submit").click()
WebDriverWait(self.driver, 30).until(expected_conditions.visibility_of_element_located((By.CSS_SELECTOR, ".fa-upload > path")))
except:
continue
else:
break
## Check bitchute Upload bottom and try to click it - on timeout or failure retry it, till will succeed!
while True:
# Go to upload page if possible!
while True:
try:
self.driver.find_element(By.CSS_SELECTOR, ".fa-upload > path").click()
#self.driver.set_timeout(60) # seconds
WebDriverWait(self.driver, 30).until(expected_conditions.visibility_of_element_located((By.ID, "publish")))
except TimeoutException as ex:
continue
except:
self.driver.back()
continue
else:
break
break
## If not failure on connectinng to bitchute upload subdomain page!
##Continue workflow - on Subdomain with Upload interface!
while True:
try:
self.driver.find_element(By.XPATH, "//input[@id=\'title\']").send_keys(self.name)
self.driver.find_element(By.XPATH, "//input[@id=\'title\']").click()
self.driver.find_element(By.XPATH, "//option[@value=\'"+ self.visibly_advice + "\']").click()
except:
continue
else:
break
#self.driver.find_element(By.XPATH, "//label[contains(.,\'Publish right away\')]").click()
while True:
try:
WebDriverWait(self.driver, 30).until(expected_conditions.visibility_of_element_located((By.XPATH, "//div[@id=\'videoInput\']/div/label")))
self.driver.find_element(By.NAME, "thumbnailInput").send_keys(self.thumb)
time.sleep(5.0)
while True:
try:
WebDriverWait(self.driver, 30).until(expected_conditions.visibility_of_element_located((By.XPATH, "(//button[@type=\'button\'])[8]")))
except:
try:
WebDriverWait(self.driver, 30).until(expected_conditions.visibility_of_element_located((By.XPATH, "(//button[@type=\'button\'])[7]")))
self.driver.find_element(By.CSS_SELECTOR, ".filepond--action-remove-item").click()
WebDriverWait(self.driver, 30).until(expected_conditions.visibility_of_element_located((By.XPATH, "//div[@id=\'videoInput\']/div/label")))
self.driver.find_element(By.NAME, "thumbnailInput").send_keys(self.thumb)
#self.driver.find_element(By.XPATH, "(//button[@type=\'button\'])[7]").click()
continue
except:
continue
else:
break
break
except:
continue
else:
break
while True:
try:
WebDriverWait(self.driver, 30).until(expected_conditions.visibility_of_element_located((By.XPATH, "//div[@id=\'videoInput\']/div/label")))
self.driver.find_element(By.NAME, "videoInput").send_keys(self.file)
time.sleep(5.0)
while True:
try:
WebDriverWait(self.driver, 30).until(expected_conditions.visibility_of_element_located((By.XPATH, "(//button[@type=\'button\'])[7]")))
except:
try:
WebDriverWait(self.driver, 30).until(expected_conditions.visibility_of_element_located((By.XPATH, "(//button[@type=\'button\'])[6]")))
self.driver.find_element(By.XPATH, "(//button[@type=\'button\'])[6]").click()
continue
except:
continue
else:
break
break
except:
continue
else:
break
while True:
try:
title = self.driver.title
if title == "Upload":
print("Click Upload Bottum")
time.sleep(2.0)
self.driver.find_element(By.XPATH, "//button[@type=\'submit\']").click()
else:
print("Upload of: " + self.name + " is complete and succeeds!")
break
except:
continue
time.sleep(4.0)
while True:
try:
self.driver.find_element(By.CSS_SELECTOR, "#notifylink path").click()
title = self.driver.title
if title == "Notifications - BitChute":
self.driver.close()
break
else:
continue
except:
continue
Bitchute = TestBitchuteUploadClass(args.name, args.file, args.thumbnail, args.email, args.password, args.visibly_advice)
Bitchute.setup_method("")
while True:
try:
Bitchute.test_bitchuteUploadClass()
except:
print("Retry Upload")
else:
print ("Move " + args.file + " to " + file_backup_folder)
shutil.move(args.file, file_backup_folder)
break
Bitchute.teardown_method("")