|
21 | 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
22 | 22 | SOFTWARE. |
23 | 23 | """ |
24 | | - |
25 | 24 | import concurrent.futures.thread |
26 | 25 | import json |
27 | 26 | import logging |
28 | 27 | import os |
29 | 28 | import platform |
| 29 | +import re |
30 | 30 | import shutil |
31 | 31 | import sqlite3 |
32 | 32 | import subprocess |
|
35 | 35 | from concurrent.futures import ThreadPoolExecutor, as_completed |
36 | 36 | from contextlib import closing |
37 | 37 | from datetime import datetime |
38 | | -from random import choice, randint, uniform, choices |
| 38 | +from random import choice, choices, randint, uniform |
39 | 39 | from time import gmtime, sleep, strftime |
40 | 40 |
|
41 | 41 | import requests |
42 | 42 | import undetected_chromedriver as uc |
43 | 43 | from fake_headers import Headers, browsers |
44 | 44 | from selenium import webdriver |
45 | | -from selenium.common.exceptions import NoSuchElementException |
| 45 | +from selenium.common.exceptions import (NoSuchElementException, |
| 46 | + TimeoutException, WebDriverException) |
46 | 47 | from selenium.webdriver.common.by import By |
47 | 48 | from selenium.webdriver.common.keys import Keys |
48 | 49 | from selenium.webdriver.support import expected_conditions as EC |
@@ -86,7 +87,7 @@ class bcolors: |
86 | 87 | [ GitHub : https://github.com/MShawon/YouTube-Viewer ] |
87 | 88 | """ + bcolors.ENDC) |
88 | 89 |
|
89 | | -SCRIPT_VERSION = '1.4.7' |
| 90 | +SCRIPT_VERSION = '1.4.8' |
90 | 91 |
|
91 | 92 | proxy = None |
92 | 93 | driver = None |
@@ -513,7 +514,7 @@ def bypass_signin(driver): |
513 | 514 | def skip_initial_ad(driver, position, video): |
514 | 515 | try: |
515 | 516 | video_len = duration_dict[video] |
516 | | - if video_len > 60: |
| 517 | + if video_len > 30: |
517 | 518 | skip_ad = WebDriverWait(driver, 15).until(EC.element_to_be_clickable( |
518 | 519 | (By.CLASS_NAME, "ytp-ad-skip-button-container"))) |
519 | 520 |
|
@@ -706,6 +707,20 @@ def main_viewer(proxy_type, proxy, position): |
706 | 707 | # sleep(30) |
707 | 708 |
|
708 | 709 | sleep(2) |
| 710 | + |
| 711 | + try: |
| 712 | + ip = re.findall(r"^.*@|(.*):", proxy)[-1] |
| 713 | + location = requests.get(f"http://ip-api.com/json/{ip}", timeout=30).json() |
| 714 | + params = { |
| 715 | + "latitude": location['lat'], |
| 716 | + "longitude": location['lon'], |
| 717 | + "accuracy": randint(20,100) |
| 718 | + } |
| 719 | + print(params) |
| 720 | + driver.execute_cdp_cmd("Emulation.setGeolocationOverride", params) |
| 721 | + except: |
| 722 | + pass |
| 723 | + |
709 | 724 | driver.get(url) |
710 | 725 |
|
711 | 726 | if 'consent' in driver.current_url: |
@@ -863,6 +878,11 @@ def main_viewer(proxy_type, proxy, position): |
863 | 878 |
|
864 | 879 | status = quit_driver(driver, pluginfile) |
865 | 880 | pass |
| 881 | + |
| 882 | + except (WebDriverException, TimeoutException): |
| 883 | + sleep(20) |
| 884 | + status = quit_driver(driver, pluginfile) |
| 885 | + pass |
866 | 886 |
|
867 | 887 | except Exception as e: |
868 | 888 | *_, exc_tb = sys.exc_info() |
@@ -985,6 +1005,13 @@ def main(): |
985 | 1005 | bandwidth = config["bandwidth"] |
986 | 1006 | threads = config["threads"] |
987 | 1007 |
|
| 1008 | + if auth_required and background: |
| 1009 | + print(bcolors.FAIL + |
| 1010 | + "Premium proxy needs extension to work. Chrome doesn't support extension in Headless mode." + bcolors.ENDC) |
| 1011 | + print(bcolors.WARNING + |
| 1012 | + f"Either use proxy without username & password or disable headless mode" + bcolors.ENDC) |
| 1013 | + sys.exit() |
| 1014 | + |
988 | 1015 | if filename: |
989 | 1016 | if category == 'r': |
990 | 1017 | proxy_list = [filename] |
|
0 commit comments