Skip to content

Commit

Permalink
geolocation spoofing, bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MShawon committed Jul 16, 2021
1 parent ba0e6fa commit 930ec48
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
37 changes: 32 additions & 5 deletions youtube_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")))

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 930ec48

Please sign in to comment.