Skip to content

Commit 930ec48

Browse files
committed
geolocation spoofing, bug fixes
1 parent ba0e6fa commit 930ec48

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Simple program to increase YouTube views written in Python. Works with live stre
7676
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.
7777

7878
# Search
79-
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**
79+
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.
8080

8181
*If you don't know any keyword just put your `video title :::: video title` in search.txt*
8282

@@ -115,7 +115,7 @@ Simple program to increase YouTube views written in Python. Works with live stre
115115
116116
* After closing program, if chromedrivers are still running. You may want to double click **killdrive.bat** to close all chrome instances.
117117
118-
* *urls.txt* or *search.txt* can't be empty. Otherwise you will see errors.
118+
* *urls.txt* or *search.txt* can't be empty. Otherwise you will see errors. Use both for better results.
119119
120120
* ## Usage
121121
* 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
147147
```
148148
ps aux | awk '/chrome/ { print $2 } ' | xargs kill -9
149149
```
150-
* *urls.txt* or *search.txt* can't be empty. Otherwise you will see errors.
150+
* *urls.txt* or *search.txt* can't be empty. Otherwise you will see errors. Use both for better results.
151151
152152
* ## Usage
153153
* Open command prompt in YouTube-Viewer folder and run

youtube_viewer.py

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
SOFTWARE.
2323
"""
24-
2524
import concurrent.futures.thread
2625
import json
2726
import logging
2827
import os
2928
import platform
29+
import re
3030
import shutil
3131
import sqlite3
3232
import subprocess
@@ -35,14 +35,15 @@
3535
from concurrent.futures import ThreadPoolExecutor, as_completed
3636
from contextlib import closing
3737
from datetime import datetime
38-
from random import choice, randint, uniform, choices
38+
from random import choice, choices, randint, uniform
3939
from time import gmtime, sleep, strftime
4040

4141
import requests
4242
import undetected_chromedriver as uc
4343
from fake_headers import Headers, browsers
4444
from selenium import webdriver
45-
from selenium.common.exceptions import NoSuchElementException
45+
from selenium.common.exceptions import (NoSuchElementException,
46+
TimeoutException, WebDriverException)
4647
from selenium.webdriver.common.by import By
4748
from selenium.webdriver.common.keys import Keys
4849
from selenium.webdriver.support import expected_conditions as EC
@@ -86,7 +87,7 @@ class bcolors:
8687
[ GitHub : https://github.com/MShawon/YouTube-Viewer ]
8788
""" + bcolors.ENDC)
8889

89-
SCRIPT_VERSION = '1.4.7'
90+
SCRIPT_VERSION = '1.4.8'
9091

9192
proxy = None
9293
driver = None
@@ -513,7 +514,7 @@ def bypass_signin(driver):
513514
def skip_initial_ad(driver, position, video):
514515
try:
515516
video_len = duration_dict[video]
516-
if video_len > 60:
517+
if video_len > 30:
517518
skip_ad = WebDriverWait(driver, 15).until(EC.element_to_be_clickable(
518519
(By.CLASS_NAME, "ytp-ad-skip-button-container")))
519520

@@ -706,6 +707,20 @@ def main_viewer(proxy_type, proxy, position):
706707
# sleep(30)
707708

708709
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+
709724
driver.get(url)
710725

711726
if 'consent' in driver.current_url:
@@ -863,6 +878,11 @@ def main_viewer(proxy_type, proxy, position):
863878

864879
status = quit_driver(driver, pluginfile)
865880
pass
881+
882+
except (WebDriverException, TimeoutException):
883+
sleep(20)
884+
status = quit_driver(driver, pluginfile)
885+
pass
866886

867887
except Exception as e:
868888
*_, exc_tb = sys.exc_info()
@@ -985,6 +1005,13 @@ def main():
9851005
bandwidth = config["bandwidth"]
9861006
threads = config["threads"]
9871007

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+
9881015
if filename:
9891016
if category == 'r':
9901017
proxy_list = [filename]

0 commit comments

Comments
 (0)