Skip to content

Commit f78da9f

Browse files
committed
bypass consent if needed
1 parent 2ce0539 commit f78da9f

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

youtube_viewer.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def get_driver(agent, proxy, proxy_type):
258258

259259
def bypass_consent(driver):
260260
try:
261-
consent = WebDriverWait(driver, 30).until(EC.element_to_be_clickable(
261+
consent = WebDriverWait(driver, 15).until(EC.element_to_be_clickable(
262262
(By.XPATH, "//input[@type='submit' and @value='I agree']")))
263263
consent.submit()
264264
except:
@@ -325,8 +325,8 @@ def main_viewer(proxy_type, proxy, position):
325325

326326
if status == 200:
327327
try:
328-
print(bcolors.OKBLUE + f"Tried {position+1} |" +
329-
bcolors.OKGREEN + f'{proxy} | {proxy_type} --> Good Proxy | Searching for videos...' + bcolors.ENDC)
328+
print(bcolors.OKBLUE + f"Tried {position+1} | " +
329+
bcolors.OKGREEN + f"{proxy} | {proxy_type} --> Good Proxy | Searching for videos..." + bcolors.ENDC)
330330

331331
driver = get_driver(agent, proxy, proxy_type)
332332

@@ -343,10 +343,16 @@ def interceptor(request):
343343
method = 2
344344
query = choice(queries)
345345
url = f"https://www.youtube.com/results?search_query={query[0].replace(' ', '%20')}"
346-
346+
347+
348+
# driver.get('https://ipof.me')
349+
# sleep(30)
350+
347351
driver.get(url)
348352

349-
bypass_consent(driver)
353+
if 'consent' in driver.current_url:
354+
print(bcolors.OKBLUE + f"Tried {position+1} | Bypassing consent..." + bcolors.ENDC)
355+
bypass_consent(driver)
350356

351357
try:
352358
if method == 1:
@@ -395,8 +401,8 @@ def interceptor(request):
395401
video_len = video_len*uniform(.85, .95)
396402

397403
duration = strftime("%Hh:%Mm:%Ss", gmtime(video_len))
398-
print(bcolors.OKBLUE + f"Tried {position+1} |" + bcolors.OKGREEN +
399-
f' {proxy} --> Video Found : {url} | Watch Duration : {duration} ' + bcolors.ENDC)
404+
print(bcolors.OKBLUE + f"Tried {position+1} | " + bcolors.OKGREEN +
405+
f"{proxy} --> Video Found : {url} | Watch Duration : {duration} " + bcolors.ENDC)
400406

401407
check_state(driver)
402408

@@ -418,8 +424,8 @@ def interceptor(request):
418424
pass
419425

420426
except:
421-
print(bcolors.OKBLUE + f"Tried {position+1} |" + bcolors.FAIL +
422-
f' {proxy} | {proxy_type} --> Bad proxy ' + bcolors.ENDC)
427+
print(bcolors.OKBLUE + f"Tried {position+1} | " + bcolors.FAIL +
428+
f"{proxy} | {proxy_type} --> Bad proxy " + bcolors.ENDC)
423429
checked[position] = proxy_type
424430
pass
425431

0 commit comments

Comments
 (0)