Skip to content

Commit 3d722e9

Browse files
committed
updated extension
1 parent 930ec48 commit 3d722e9

File tree

3 files changed

+16
-19
lines changed

3 files changed

+16
-19
lines changed

extension/always_active.zip

4.44 KB
Binary file not shown.

extension/webrtc_control.zip

-1.11 KB
Binary file not shown.

youtube_viewer.py

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import logging
2727
import os
2828
import platform
29-
import re
3029
import shutil
3130
import sqlite3
3231
import subprocess
@@ -42,8 +41,7 @@
4241
import undetected_chromedriver as uc
4342
from fake_headers import Headers, browsers
4443
from selenium import webdriver
45-
from selenium.common.exceptions import (NoSuchElementException,
46-
TimeoutException, WebDriverException)
44+
from selenium.common.exceptions import NoSuchElementException
4745
from selenium.webdriver.common.by import By
4846
from selenium.webdriver.common.keys import Keys
4947
from selenium.webdriver.support import expected_conditions as EC
@@ -87,7 +85,7 @@ class bcolors:
8785
[ GitHub : https://github.com/MShawon/YouTube-Viewer ]
8886
""" + bcolors.ENDC)
8987

90-
SCRIPT_VERSION = '1.4.8'
88+
SCRIPT_VERSION = '1.4.9'
9189

9290
proxy = None
9391
driver = None
@@ -349,12 +347,12 @@ def check_proxy(agent, proxy, proxy_type):
349347
'User-Agent': f'{agent}',
350348
}
351349

352-
proxyDict = {
350+
proxy_dict = {
353351
"http": f"{proxy_type}://{proxy}",
354352
"https": f"{proxy_type}://{proxy}",
355353
}
356354
response = requests.get(
357-
'https://www.youtube.com/', headers=headers, proxies=proxyDict, timeout=30)
355+
'https://www.youtube.com/', headers=headers, proxies=proxy_dict, timeout=30)
358356
status = response.status_code
359357

360358
else:
@@ -380,9 +378,9 @@ def get_driver(agent, proxy, proxy_type, pluginfile):
380378

381379
if not background:
382380
options.add_extension(WEBRTC)
383-
options.add_extension(ACTIVE)
384381
options.add_extension(FINGERPRINT)
385382
options.add_extension(TIMEZONE)
383+
options.add_extension(ACTIVE)
386384

387385
if auth_required:
388386
proxy = proxy.replace('@', ':')
@@ -709,15 +707,19 @@ def main_viewer(proxy_type, proxy, position):
709707
sleep(2)
710708

711709
try:
712-
ip = re.findall(r"^.*@|(.*):", proxy)[-1]
713-
location = requests.get(f"http://ip-api.com/json/{ip}", timeout=30).json()
710+
proxy_dict = {
711+
"http": f"{proxy_type}://{proxy}",
712+
"https": f"{proxy_type}://{proxy}",
713+
}
714+
location = requests.get(
715+
"http://ip-api.com/json", proxies=proxy_dict, timeout=30).json()
714716
params = {
715717
"latitude": location['lat'],
716718
"longitude": location['lon'],
717-
"accuracy": randint(20,100)
719+
"accuracy": randint(20, 100)
718720
}
719-
print(params)
720-
driver.execute_cdp_cmd("Emulation.setGeolocationOverride", params)
721+
driver.execute_cdp_cmd(
722+
"Emulation.setGeolocationOverride", params)
721723
except:
722724
pass
723725

@@ -878,11 +880,6 @@ def main_viewer(proxy_type, proxy, position):
878880

879881
status = quit_driver(driver, pluginfile)
880882
pass
881-
882-
except (WebDriverException, TimeoutException):
883-
sleep(20)
884-
status = quit_driver(driver, pluginfile)
885-
pass
886883

887884
except Exception as e:
888885
*_, exc_tb = sys.exc_info()
@@ -1007,9 +1004,9 @@ def main():
10071004

10081005
if auth_required and background:
10091006
print(bcolors.FAIL +
1010-
"Premium proxy needs extension to work. Chrome doesn't support extension in Headless mode." + bcolors.ENDC)
1007+
"Premium proxy needs extension to work. Chrome doesn't support extension in Headless mode." + bcolors.ENDC)
10111008
print(bcolors.WARNING +
1012-
f"Either use proxy without username & password or disable headless mode" + bcolors.ENDC)
1009+
f"Either use proxy without username & password or disable headless mode" + bcolors.ENDC)
10131010
sys.exit()
10141011

10151012
if filename:

0 commit comments

Comments
 (0)