diff --git a/README.md b/README.md index 9be0383..87780c4 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ Simple program to increase YouTube views written in Python. Works with live stre 2) If you have any external link which will redirect to your youtube video you can use that too. Example : when you post a YouTube video link in **twitter** and you hit play on twitter, you will get a link like this `https://t.co/xxxxxxxxxx?amp=1`. This is helpful because YouTube will see that views are coming from External Source like twitter in this example. # Search - Program can search youtube with keyword and find video with video title. To do this you need to know what keyword can find your video on youtube search engine. Also you need to provide **exact** video title.Put keyword and title like this format `keyword :::: video title` in **search.txt** + Program can search youtube with the keyword you want and find video with video title. To do this you need to know what keyword can find your video on youtube search engine. Also you need to provide **exact** video title. Put keyword and title like this format `keyword :::: video title` in **search.txt**. You can use same `video title` for multiple `keyword` too. *If you don't know any keyword just put your `video title :::: video title` in search.txt* @@ -115,7 +115,7 @@ Simple program to increase YouTube views written in Python. Works with live stre * After closing program, if chromedrivers are still running. You may want to double click **killdrive.bat** to close all chrome instances. - * *urls.txt* or *search.txt* can't be empty. Otherwise you will see errors. + * *urls.txt* or *search.txt* can't be empty. Otherwise you will see errors. Use both for better results. * ## Usage * Open command prompt in YouTube-Viewer folder and run @@ -147,7 +147,7 @@ Simple program to increase YouTube views written in Python. Works with live stre ``` ps aux | awk '/chrome/ { print $2 } ' | xargs kill -9 ``` - * *urls.txt* or *search.txt* can't be empty. Otherwise you will see errors. + * *urls.txt* or *search.txt* can't be empty. Otherwise you will see errors. Use both for better results. * ## Usage * Open command prompt in YouTube-Viewer folder and run diff --git a/youtube_viewer.py b/youtube_viewer.py index b146e81..fc64db3 100644 --- a/youtube_viewer.py +++ b/youtube_viewer.py @@ -21,12 +21,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ - import concurrent.futures.thread import json import logging import os import platform +import re import shutil import sqlite3 import subprocess @@ -35,14 +35,15 @@ from concurrent.futures import ThreadPoolExecutor, as_completed from contextlib import closing from datetime import datetime -from random import choice, randint, uniform, choices +from random import choice, choices, randint, uniform from time import gmtime, sleep, strftime import requests import undetected_chromedriver as uc from fake_headers import Headers, browsers from selenium import webdriver -from selenium.common.exceptions import NoSuchElementException +from selenium.common.exceptions import (NoSuchElementException, + TimeoutException, WebDriverException) from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support import expected_conditions as EC @@ -86,7 +87,7 @@ class bcolors: [ GitHub : https://github.com/MShawon/YouTube-Viewer ] """ + bcolors.ENDC) -SCRIPT_VERSION = '1.4.7' +SCRIPT_VERSION = '1.4.8' proxy = None driver = None @@ -513,7 +514,7 @@ def bypass_signin(driver): def skip_initial_ad(driver, position, video): try: video_len = duration_dict[video] - if video_len > 60: + if video_len > 30: skip_ad = WebDriverWait(driver, 15).until(EC.element_to_be_clickable( (By.CLASS_NAME, "ytp-ad-skip-button-container"))) @@ -706,6 +707,20 @@ def main_viewer(proxy_type, proxy, position): # sleep(30) sleep(2) + + try: + ip = re.findall(r"^.*@|(.*):", proxy)[-1] + location = requests.get(f"http://ip-api.com/json/{ip}", timeout=30).json() + params = { + "latitude": location['lat'], + "longitude": location['lon'], + "accuracy": randint(20,100) + } + print(params) + driver.execute_cdp_cmd("Emulation.setGeolocationOverride", params) + except: + pass + driver.get(url) if 'consent' in driver.current_url: @@ -863,6 +878,11 @@ def main_viewer(proxy_type, proxy, position): status = quit_driver(driver, pluginfile) pass + + except (WebDriverException, TimeoutException): + sleep(20) + status = quit_driver(driver, pluginfile) + pass except Exception as e: *_, exc_tb = sys.exc_info() @@ -985,6 +1005,13 @@ def main(): bandwidth = config["bandwidth"] threads = config["threads"] + if auth_required and background: + print(bcolors.FAIL + + "Premium proxy needs extension to work. Chrome doesn't support extension in Headless mode." + bcolors.ENDC) + print(bcolors.WARNING + + f"Either use proxy without username & password or disable headless mode" + bcolors.ENDC) + sys.exit() + if filename: if category == 'r': proxy_list = [filename]